Skip to content

Commit 7339119

Browse files
authored
fix(docs): scope the llms.txt .mdx rule so it cannot compose into a 404 (#214)
/llms.txt stated two rules -- append .mdx to a page URL, and every page is also published under a locale prefix -- over the same 79 bullets, with nothing scoping the first to English. Composing them is what a machine reader does with an llms.txt, and it yielded /zh-Hans/docs/quickstart.mdx, which 404s. The .mdx rule now states its own scope and names the exclusion. The Other Languages section is unchanged: those page URLs resolve, and it is the only place the file says translations exist. The comment above LANG in llms-full.txt/route.ts claimed locale text stays reachable through the .mdx rewrite. It does not: next.config.mjs rewrites /docs/:path*.mdx and no locale-prefixed form, and llms.mdx/docs/[[...slug]] calls source.getPage(slug) with no language argument. Corrected, with a note that this belief is what reached the served file. Verified by composing the rules from the served body: rule 1 79/79 -> 200, rule 2 79/79 -> 200 per locale, cross composition 0/79. The same probe exits 1 against the pre-change body. llms-full.txt byte-identical; llms.txt differs in one line. Closes #210
1 parent 9a5a032 commit 7339119

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

‎apps/docs/app/llms-full.txt/route.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ export const revalidate = false;
1616
* tree it returns is already per-locale, and it currently resolves to the
1717
* default language when called bare — but nothing in the API contract
1818
* promises that, so the argument stays explicit rather than relying on an
19-
* unstated default. The locale text stays reachable per page through the
20-
* `.mdx` rewrite and the locale URLs announced at the end of `llms.txt`.
19+
* unstated default. The locale text stays reachable as HTML, through the
20+
* locale URLs announced at the end of `llms.txt` — and *not* through the
21+
* `.mdx` rewrite, which is English-only in both halves: `next.config.mjs`
22+
* rewrites `/docs/:path*.mdx` and no locale-prefixed form of it, and
23+
* `llms.mdx/docs/[[...slug]]` calls `source.getPage(slug)` with no language
24+
* argument, so the default language is the only thing it can serve. This
25+
* comment used to claim the opposite, and that belief reached the served
26+
* `/llms.txt`, whose header told every machine reader to build
27+
* `/zh-Hans/docs/quickstart.mdx` — a 404.
2128
*/
2229
const LANG = i18n.defaultLanguage;
2330

‎apps/docs/app/llms.txt/route.ts‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ function absoluteNode(node: Node): Node {
8888
return node;
8989
}
9090

91+
/**
92+
* The header's two rules — append `.mdx`, and the locale prefixes announced
93+
* under Other Languages — are read by a machine that will compose them. So the
94+
* `.mdx` rule states its own scope: it used to say "appending `.mdx` to its
95+
* URL", and composed with the locale rule that licensed
96+
* `/zh-Hans/docs/quickstart.mdx`, which 404s. The rewrite in `next.config.mjs`
97+
* matches `/docs/:path*.mdx` and nothing else, and the route behind it calls
98+
* `source.getPage(slug)` with no language, so there is no locale-prefixed
99+
* `.mdx` URL to advertise and no locale text behind one.
100+
*
101+
* Keep any rewording composable with the Other Languages section: a scope this
102+
* paragraph does not state is a URL this file promises and the site does not
103+
* serve, and no gate reads prose.
104+
*/
91105
export async function GET() {
92106
const generator = llms(source);
93107
const tree = source.getPageTree(LANG);
@@ -99,10 +113,11 @@ export async function GET() {
99113
'',
100114
'This is the ObjectOS product and developer documentation, grouped by the ' +
101115
'sections used in the site navigation. Every page below is also available ' +
102-
'as Markdown by appending `.mdx` to its URL (for example ' +
103-
`\`${localeUrl(LANG, 'docs/quickstart.mdx')}\`), and ` +
116+
'as Markdown by appending `.mdx` to the URL exactly as listed (for ' +
117+
`example \`${localeUrl(LANG, 'docs/quickstart.mdx')}\`), and ` +
104118
`\`${SITE_URL}/llms-full.txt\` carries the full text of every page in ` +
105-
'one file.',
119+
'one file. Both are English-only: the locale-prefixed URLs under Other ' +
120+
'Languages below have no `.mdx` form.',
106121
];
107122

108123
// Root-level pages (index, why, quickstart, ...) come before the section

0 commit comments

Comments
 (0)