| 13 | const isDocFile = (p) => p.endsWith('.md') || p.endsWith('.mdx'); |
| 14 | |
| 15 | async function listFilesRecursive(dir) { |
| 16 | const out = []; |
| 17 | async function walk(current) { |
| 18 | const entries = await fs.readdir(current, { withFileTypes: true }); |
| 19 | for (const entry of entries) { |
| 20 | const full = path.join(current, entry.name); |
| 21 | if (entry.isDirectory()) { |
| 22 | await walk(full); |
| 23 | } else if (entry.isFile() && isDocFile(full)) { |
| 24 | out.push(full); |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | await walk(dir); |
| 29 | return out; |
| 30 | } |
| 31 | |
| 32 | function parseFrontMatter(content) { |
| 33 | if (!content.startsWith('---\n')) return {}; |