import fs from "node:fs"; import path from "node:path"; import { renderFooter, renderPrimaryNav, renderSidebar } from "./components.mjs"; const repoRoot = process.cwd(); const legacyHtmlRoot = path.join(repoRoot, "archive-source"); function walk(dir) { return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => { const fullPath = path.join(dir, entry.name); if (entry.isDirectory()) { return walk(fullPath); } return fullPath.endsWith(".html") ? [fullPath] : []; }); } function toPathname(filePath) { const relativePath = path.relative(legacyHtmlRoot, filePath).split(path.sep).join("/"); return `/${relativePath === "index.html" ? "index.html" : relativePath}`; } let updated = 0; for (const filePath of walk(legacyHtmlRoot)) { const pathname = toPathname(filePath); let html = fs.readFileSync(filePath, "utf8"); const original = html; html = html.replace(/