If it helps, I wrote this for myself
import path from "path";
import fs from "fs";
async function getMarkdownFilesRecursive(dir: string): Promise<string[]> {
const entries = await fs.promises.readdir(dir, { withFileTypes: true });
const filesArray = await Promise.all(
entries.map(async (entry) => {
const fullPath = path.join(dir, entry.name);
if (
entry.isFile() &&
entry.name.startsWith("page") &&
entry.name.endsWith(".md")
) {
return [fullPath];
}
if (entry.isDirectory()) {
return getMarkdownFilesRecursive(fullPath);
}
return [];
}),
);
return filesArray.flat();
}
export async function getMarkdownAbsolutePaths() {
const projectRoot = process.cwd();
const contentDir = path.join(projectRoot, "content");
const files = await getMarkdownFilesRecursive(contentDir);
return files
}
since I wanted only any page.md under the content directory at root (i figure using nextjs conventions might be good, esp since index.md breaks sometimes and i like to bundle assets in the same directory). Might eventually add i18n with page.<lang>.md but idk yet. Potentially just using fs read dir sync is simpler 
This could be modified pretty trivially to support what you want?