feat: Add dynamic markdown routing for llms.txt #8133
Draft
+642
−1
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.
Adds dynamic markdown routing, enabling AI agents to fetch individual doc pages as markdown via clean URLs.
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.txtIncremental Changes (vs #8130)
View only this commit to see the delta: 9cd0a28
Files 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