From 356dfe3f3fb3c5c9b15bf107c96bb2768e32b937 Mon Sep 17 00:00:00 2001 From: Kepler Vital Date: Thu, 2 Jul 2026 20:50:40 +0200 Subject: [PATCH] fix: serve spec-compliant .html.md versions of rendered pages The proposal says markdown versions of pages live at the page URL with .md appended, and that URLs without a file name should use index.html.md. The notebook-built pages (intro, core) already comply via keep-md, but index, nbdev, domains and ed only get a commonmark render named {stem}.md (or {stem}-commonmark.md when the source itself is a .md file), so index.html.md, nbdev.html.md, domains.html.md and ed.html.md were 404. Add a Quarto post-render script that copies each generated markdown output to its .html.md name. Existing URLs such as index.md and ed-commonmark.md are kept as is. --- nbs/_quarto.yml | 1 + nbs/post_render.ts | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 nbs/post_render.ts diff --git a/nbs/_quarto.yml b/nbs/_quarto.yml index ab3c7fd..98b5fe9 100644 --- a/nbs/_quarto.yml +++ b/nbs/_quarto.yml @@ -1,5 +1,6 @@ project: type: website + post-render: post_render.ts resources: - "*.txt" - "*.html" diff --git a/nbs/post_render.ts b/nbs/post_render.ts new file mode 100644 index 0000000..e5fd519 --- /dev/null +++ b/nbs/post_render.ts @@ -0,0 +1,7 @@ +// Copy generated md outputs to spec-compliant `.html.md` names (see the Proposal section in index.qmd). +const dir = Deno.env.get("QUARTO_PROJECT_OUTPUT_DIR")!; +for await (const f of Deno.readDir(dir)) { + if (!f.name.endsWith(".md") || f.name.endsWith(".html.md") || f.name === "README.md") continue; + const dst = `${dir}/${f.name.replace(/(-commonmark)?\.md$/, ".html.md")}`; + try { await Deno.stat(dst); } catch { await Deno.copyFile(`${dir}/${f.name}`, dst); } +}