Skip to content

refactor(docs): build llms.txt only while prerendering - #42

Merged
vite-hub[bot] merged 1 commit into
mainfrom
refactor/llms-prerender-route
Nov 21, 2026
Merged

vite-hub[bot] merged 1 commit into
mainfrom
refactor/llms-prerender-route

Conversation

@onmax

@onmax onmax commented Nov 21, 2026

Copy link
Copy Markdown
Owner

The Worker bundle shipped a /llms.txt handler that only answered 404. Every page and llms.txt are prerendered, and load-pages.ts returns nothing outside dev and prerender. Now that route is built only while prerendering. The site comes out the same.

ViteHub documents this pattern since vite-hub/vitehub#5173 ("Content only at build" in the Content configure docs). This PR renames server/routes/llms.txt.get.ts to llms.txt.get.prerender.ts. The route imports server/pages.ts directly, without the loadPages() guard. In the installed Nitro (3.0.261103-rc, the version locked since #40), parseScanPath reads .prerender as an env suffix. initNitroRouting then keeps the route only when the preset is nitro-prerender.

load-pages.ts stays. /search.json, /api/pages/** and the .md middleware must also work in nuxi dev, so they keep the import.meta.dev || import.meta.prerender guard, which is the same guard the ViteHub docs show. Middleware can't take an env suffix in Nitro. Content, Comark and Shiki were already out of the Worker bundle. This PR only removes the llms.txt route code.

No ViteHub pin change: the site stays on @vite-hub/content ^0.3.1 from #40.

Verified, Node 24.21.0, Linux, clean builds (dist, .nuxt, the Nuxt cache and .generated removed before each):

  • pnpm docs:generate on main and on this branch: 98 routes each, the same 122 public files. llms.txt, search.json, every .md copy and _headers are byte-identical. The HTML and _payload.json files differ only in the build ID, prerenderedAt and island UIDs.
  • Server bundle: _routes/llms.txt.mjs and its router entry are gone, and docs/dist/server goes from 972,941 to 971,696 bytes. On both builds, a grep of the server .mjs files finds no page text ("Smaller, faster drop-ins", "## Sitemap", the llms.txt intro), no defineContent, no comark-content and no shiki.
  • wrangler@4.158.0 dev -c docs/dist/server/wrangler.json: /, /tinyaml/guide/getting-started/, /tinylinkify/compatibility/, /search.json, /llms.txt, /index.md and /tinyaml/guide/api.md answer 200 with the right content types. The served llms.txt is byte-identical to the main build. Accept: text/markdown on / answers Markdown, /nope/ answers 404, and Host: tinyaml.onmax.me gets a 301 to https://tiny.onmax.me/guide/.

pnpm docs:dev still fails with "Unrecognized import attributes specified" in workerd, the same way as on main (noted in #40). /llms.txt now answers 404 in dev instead of 500, as expected for a .prerender route.

Not checked: a deploy. Merging deploys through Workers Builds.

Prepared with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

Rename the route to llms.txt.get.prerender.ts. Nitro adds a route with the
.prerender suffix to the prerender build only, so the Worker bundle has no
llms.txt handler and the route imports server/pages.ts directly.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-21T11:43:38.187191Z
We couldn’t complete this review. Comment @codex review to try again.
5b61347 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@pkg-pr-new

pkg-pr-new Bot commented Nov 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

tinyaml

pnpm add https://pkg.pr.new/onmax/tiny/tinyaml@42

tinyini

pnpm add https://pkg.pr.new/onmax/tiny/tinyini@42

tinyjson5

pnpm add https://pkg.pr.new/onmax/tiny/tinyjson5@42

tinylinkify

pnpm add https://pkg.pr.new/onmax/tiny/tinylinkify@42

tinyswap

pnpm add https://pkg.pr.new/onmax/tiny/tinyswap@42

commit: 5b61347

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. No P0 or P1 findings.

Approach: Sound — Nitro’s .prerender suffix keeps the handler out of the Worker bundle while preserving /llms.txt as a public asset.

Reviewed changes — I traced the route from Nuxt’s prerender configuration through to the generated Worker.

  • Sitemap route: pnpm docs:generate prerendered 98 routes and produced llms.txt without bundling its handler. Local Wrangler returned 200 for both GET and HEAD, and the GET body matched the generated file byte for byte. The route is intentionally unavailable in nuxi dev.
  • Other content routes: Search, the page API, and the Markdown middleware still use the existing loadPages() guard. /search.json and /index.md both returned 200 in the local Worker.

Pullfrog  | View workflow run | Using gpt-6.2-sol(high) | 𝕏

@vite-hub

vite-hub Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

@vite-hub
vite-hub Bot merged commit f19096b into main Nov 21, 2026
11 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant