// Every file in the repo's docs/ has to actually be reachable from the built // site — otherwise a new doc page can be added to docs/ and silently never // get a route, a link, or a mention in the /docs/ index. import { readFileSync, readdirSync } from "node:fs"; import { join } from "node:path"; import { distDir, repoRoot, requireDist, fail, report } from "./lib.mjs"; requireDist(); const docsDir = join(repoRoot, "docs"); const slugs = readdirSync(docsDir) .filter((name) => name.endsWith(".md")) .map((name) => name.replace(/\.md$/, "")); if (slugs.length === 0) { fail(`no markdown files found in ${docsDir}`); } const indexHtml = readFileSync(join(distDir, "docs", "index.html"), "utf8"); for (const slug of slugs) { const pagePath = join(distDir, "docs", slug, "index.html"); try { readFileSync(pagePath); } catch { fail(`docs/${slug}.md has no built page at dist/docs/${slug}/index.html`); continue; } if (!indexHtml.includes(`/docs/${slug}/`)) { fail(`dist/docs/index.html does not link to /docs/${slug}/`); } } report("check-docs-coverage");