Content negotiation: serve LLM-optimized .md docs when agents request Accept: text/markdown
#8969
RaphaelGimenez
started this conversation in
AI and LLM usage feedback
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Mantine already generates LLM-optimized docs at
/llms/{page}.md. But agents need to know about the/llms/prefix. Content negotiation would let agents get markdown from the same URL they'd use in a browser — just by sendingAccept: text/markdown.Problem
Today, when an agent (Cursor, Claude, ChatGPT, etc.) fetches a Mantine docs page, it gets the full HTML — navigation, sidebar, footer, JS bundles (~500KB+). This wastes context tokens and makes answers less accurate. The agent has to explicitly know about
/llms.txtor/llms/{page}.mdpaths.With content negotiation, an agent can simply
curl https://mantine.dev/core/button -H "accept: text/markdown"and get back the clean.mdversion automatically — no site-specific knowledge needed.Proposed implementation
1. Next.js rewrite for
Accept: text/markdownIn
next.config.ts, add a rewrite that detects theAcceptheader and routes to the existing/llms/endpoint:Since Mantine's
.mdfiles already exist at/llms/{section}-{page}.md, the mapping from docs URLs (e.g.,/core/button) to/llms/core-button.mdis straightforward.2. Add
<link rel="alternate">for agent discoveryFor agents that don't send
Accept: text/markdown, add a discovery link in the HTML<head>:(Plus per-page variants pointing to
/llms/{page}.md)Prior art
What already exists (just needs wiring)
/llms/{page}.md— per-page LLM docs already generated on every release/llms.txt— index of all LLM doc pages/llms-full.txt— single consolidated fileI'm willing to submit a PR
Happy to implement this. The change is small and contained to the
next.config.tsrewrites + potentially a<link>tag in the layout.All reactions