feat: Add dynamic markdown routing for llms.txt #8132
Closed
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.
Builds on #8130 (stacked PR) to add dynamic markdown routing, enabling AI agents to fetch individual doc pages as markdown via clean URLs.
Stack
Summary
/api/raw-md/[[...slug]]API route to serve markdown files dynamically/:path*.mdroutes to the API endpoint.mdformat in follow-up commitChanges Beyond Base PR (#8130)
Dynamic markdown API (
src/pages/api/raw-md/[[...slug]].ts):.md,.mdx,/index.md,/index.mdx)Refactored generation (
src/lib/llms-utils.ts):<Intro>,<Sandpack>, etc)Updated generation (
src/utils/llms.js):Routing config (
next.config.js):/:path*.md→/api/raw-md/:path*Examples
With this PR, AI agents can:
/learn.mdfor the learn index page/reference/react/hooks.mdfor specific API docs.mdformat llms.txtFiles Changed vs Base
next.config.js: rewrite rulessrc/lib/llms-utils.ts: shared markdown utilities (new)src/pages/api/raw-md/[[...slug]].ts: dynamic route handler (new)src/utils/llms.js: refactored to use shared utilsyarn.lock: updated dependenciesKnown Issues
.mdlinks instead of HTML URLsTest Plan
/learn.mdreturns markdown/reference/react/hooks.mdworks/reference/react-dom/client/createRoot.mdyarn buildcompletes successfully