fix(prerender): emit per-section /docs/<slug>.md mirrors (fix llms.txt 404)#198
Merged
Conversation
…t 404) Bug-3 (bug-hunt follow-up 2026-06-06). The agent-facing troubleshooting guide is linked from llms.txt as https://instanode.dev/docs/troubleshooting-deploys.md, but that nested per-section .md route returned 404 (verified live). Only /docs.md (the concatenated mirror) and the legal /docs/public/*.md statics resolved — the main docs sections had no per-section .md mirror. Fix (canonical, lower-risk): Step 6b of emitMarkdownRoutes now emits /docs/<slug>.md for every .content/docs section, mirroring the existing blog/use-case per-slug .md pattern and the legal /docs/public/*.md precedent (GH Pages serves the nested file directly). Each mirror is the standalone section: an H1 from the frontmatter title + the body with YAML frontmatter stripped — so an agent can fetch ONE section instead of the whole concatenated doc. The llms.txt reference now 200s as-is, so NO public/llms.txt edit and NO content-repo llms.txt change are needed (the URL was always correct; the route was missing). writeRouteMd() gains an includeInAggregate flag (default true); the per-section docs pass false so /llms-full.txt isn't bloated with duplicate docs content (each section already appears in the /docs.md aggregate entry). Verified the aggregate carries /docs.md once and no per-section duplicate. Tests (src/prerender.test.ts): three source guards pin the emission loop, the includeInAggregate=false aggregate exclusion, and the title+body mirror shape. Proven fail-before/pass-after by stashing the prerender.mjs change. Guards are deterministic (no filesystem/build dependency) so they run identically under `npm run gate` and the build-less coverage job — full patch coverage. The existing llmsContract.test.ts keeps the troubleshooting-deploys reference pinned in public/llms.txt, so URL and contract stay in lock-step. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mastermanas805
enabled auto-merge (squash)
June 6, 2026 06:10
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug-3 (bug-hunt follow-up, 2026-06-06). The agent-facing troubleshooting guide is linked from
llms.txtashttps://instanode.dev/docs/troubleshooting-deploys.md, but that nested per-section.mdroute returns 404 (verified live). Only/docs.md(the concatenated mirror) and the legal/docs/public/*.mdstatics resolved — the main docs sections had no per-section.mdmirror.Live evidence (before)
Fix (canonical, lower-risk)
Step 6b of
emitMarkdownRoutesnow emits/docs/<slug>.mdfor every.content/docssection, mirroring the existing blog/use-case per-slug.mdpattern and the legal/docs/public/*.mdprecedent (GH Pages serves the nested file directly). Each mirror is the standalone section: an H1 from the frontmatter title + the body with YAML frontmatter stripped — so an agent can fetch ONE section instead of the whole concatenated doc.The
llms.txtreference now 200s as-is, so nopublic/llms.txtedit and no content-repollms.txtchange are needed — the URL was always correct; the route was the thing missing. (Chose making the route resolve over rewriting the URL: it's the canonical fix, keeps the contract intact, and matches the legal-docs precedent.)writeRouteMd()gains anincludeInAggregateflag (defaulttrue); the per-section docs passfalseso/llms-full.txtisn't bloated with duplicate docs content (each section already appears in the/docs.mdaggregate entry). Verified the aggregate carries/docs.mdonce and zero per-section duplicates.Tests — fail-before / pass-after (proven)
src/prerender.test.ts— three source guards pin the emission loop, theincludeInAggregate=falseaggregate exclusion, and the title+body mirror shape. Proven by stashing theprerender.mjschange (all 3 fail against old code). The guards are deterministic (no filesystem/build dependency) so they run identically undernpm run gateand the build-less coverage job — full patch coverage. The existingllmsContract.test.tskeepstroubleshooting-deployspinned inpublic/llms.txt, so URL and contract stay in lock-step.Full
npm run gateGREEN (tsc + build + prerender + 1133 vitest). Build locally producesdist/docs/troubleshooting-deploys.md(5527 bytes, standalone H1). Will live-verify the URL 200s after deploy.🤖 Generated with Claude Code