#!/usr/bin/env node /** * Migrate custom / to Fumadocs' * native / . The step title becomes an h3 inside the * so Fumadocs' `.fd-step` counter styling applies naturally: * * * * body * * * * ↓ * * * * ### Create the metric * * body * * * * yarn node scripts/timeline-to-steps.mjs */ import { readdirSync, readFileSync, writeFileSync, statSync } from "node:fs"; import { join } from "node:path"; function transform(src) { let out = src; // \n### ...\n out = out.replace( //g, (_m, title) => `\n### ${title}\n`, ); // \n### ...\n out = out.replace( //g, (_m, title) => `\n### ${title}\n`, ); // \n### {...}\n (rare) out = out.replace( //g, (_m, expr) => `\n### {${expr}}\n`, ); // Bare (no title) → out = out.replace(//g, ""); out = out.replace(/<\/TimelineItem>/g, ""); out = out.replace(//g, ""); out = out.replace(/<\/Timeline>/g, ""); return out; } function walk(dir) { for (const entry of readdirSync(dir)) { const full = join(dir, entry); const s = statSync(full); if (s.isDirectory()) walk(full); else if (full.endsWith(".mdx")) processFile(full); } } let changed = 0; function processFile(path) { const src = readFileSync(path, "utf8"); const out = transform(src); if (out !== src) { writeFileSync(path, out); changed += 1; console.log("·", path); } } walk("content"); console.log(`\n${changed} file(s) updated.`);