Skip to content

Commit 9c29df6

Browse files
authored
fix(docs): make llms.txt crawlable and give it a real header (#179)
Fixes #170 robots.ts no longer disallows /llms.txt and /llms-full.txt. /api/ still is — it serves the search index, not readable content. A blanket User-agent: * disallow on the one file written for LLM retrieval contradicts the org's own written policy that machine-facing surfaces are first-class. llms.txt now opens with "# ObjectOS" and a one-sentence blockquote summary, taken verbatim from the marketing site's own llms.txt — the current authoritative positioning string — and kept in a single SUMMARY constant. It is deliberately not re-derived from content/docs/index.mdx, which frames the product differently; issue #171 exists because those two disagree. The link list is grouped under the section headings used in site navigation and pinned to the default locale. source.getPages() lists every language when called without one, so the previous flat list was all 335 .mdx files across 7 locales with translated titles interleaved, not 79. Rendering goes through fumadocs-core's own llms() helper. Served-body verification: /robots.txt has 0 llms mentions and keeps Disallow: /api/; /llms.txt returns 116 lines, 79 link lines, 9 headings and 0 non-default-locale links.
1 parent 93a366c commit 9c29df6

2 files changed

Lines changed: 94 additions & 7 deletions

File tree

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

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,96 @@
1+
import type { Folder } from 'fumadocs-core/page-tree';
2+
import { llms } from 'fumadocs-core/source/llms';
3+
import { i18n } from '@/lib/i18n';
14
import { source } from '@/lib/source';
25

36
export const revalidate = false;
47

8+
/**
9+
* The one place this site states what ObjectOS is.
10+
*
11+
* Taken verbatim from the marketing site's own `/llms.txt`
12+
* (`www.objectos.ai`, `src/pages/llms.txt.ts`) — the current authoritative
13+
* positioning string for the two products. It is deliberately NOT re-derived
14+
* from `content/docs/index.mdx`: that page's framing is itself under review,
15+
* and `llms.txt` must not become the place a second version of it appears.
16+
*
17+
* If the positioning changes, change this constant. Nothing else in this file
18+
* encodes it.
19+
*/
20+
const SUMMARY =
21+
'ObjectStack is the open target format and runtime for AI-written enterprise software; ObjectOS is the commercial production platform where teams build, review, deploy, and operate ObjectStack applications.';
22+
23+
/** Title line: the product this documentation is for. */
24+
const TITLE = 'ObjectOS';
25+
26+
/** Heading for the pages that sit at the tree root rather than in a section. */
27+
const ROOT_HEADING = 'Overview';
28+
29+
/**
30+
* English only, by `AGENTS.md` rule 1 — English is the single source of truth
31+
* and every `*.<locale>.mdx` is a derived artifact. `source.getPages()` and
32+
* `source.getPageTree()` list *every* language when called without one, which
33+
* is how this file used to emit all 335 pages across 7 locales as one flat
34+
* list. The locale URLs are announced at the end of the file instead.
35+
*/
36+
const LANG = i18n.defaultLanguage;
37+
38+
const OTHER_LOCALES = i18n.languages.filter((lang) => lang !== LANG);
39+
40+
function sectionHeading(folder: Folder): string {
41+
const title = source.getNodeMeta(folder, LANG)?.data.title;
42+
if (title) return title;
43+
return typeof folder.name === 'string' ? folder.name : 'Documentation';
44+
}
45+
546
export async function GET() {
6-
const lines: string[] = [];
7-
lines.push('# Documentation');
8-
lines.push('');
9-
for (const page of source.getPages()) {
10-
lines.push(`- [${page.data.title}](${page.url}): ${page.data.description}`);
47+
const generator = llms(source);
48+
const tree = source.getPageTree(LANG);
49+
50+
const lines: string[] = [
51+
`# ${TITLE}`,
52+
'',
53+
`> ${SUMMARY}`,
54+
'',
55+
'This is the ObjectOS product and developer documentation, grouped by the ' +
56+
'sections used in the site navigation. Every page below is also available ' +
57+
'as Markdown by appending `.mdx` to its URL (for example ' +
58+
'`/docs/quickstart.mdx`), and `/llms-full.txt` carries the full text of ' +
59+
'every page in one file.',
60+
];
61+
62+
// Root-level pages (index, why, quickstart, ...) come before the section
63+
// folders in the tree; collect them under one heading so the file opens with
64+
// a section rather than a bare list.
65+
const rootPages = tree.children.filter((node) => node.type === 'page');
66+
if (rootPages.length > 0) {
67+
lines.push('', `## ${ROOT_HEADING}`, '');
68+
for (const node of rootPages) lines.push(generator.indexNode(node, LANG));
69+
}
70+
71+
for (const node of tree.children) {
72+
if (node.type !== 'folder') continue;
73+
lines.push('', `## ${sectionHeading(node)}`, '');
74+
// The folder's own bullet is dropped: the heading already names it. Its
75+
// index page and children are rendered at the top level of the section,
76+
// so nested subfolders keep exactly one level of indentation.
77+
if (node.index) lines.push(generator.indexNode(node.index, LANG));
78+
for (const child of node.children) lines.push(generator.indexNode(child, LANG));
79+
}
80+
81+
if (OTHER_LOCALES.length > 0) {
82+
lines.push(
83+
'',
84+
'## Other Languages',
85+
'',
86+
`Every page above is also published under a locale prefix — for example ` +
87+
`\`/${OTHER_LOCALES[0]}/docs/quickstart\`. Available locales: ` +
88+
`${OTHER_LOCALES.map((lang) => `\`${lang}\``).join(', ')}. English is the ` +
89+
`source of truth; a page with no translation yet falls back to English.`,
90+
);
1191
}
92+
93+
lines.push('');
94+
1295
return new Response(lines.join('\n'));
1396
}

‎apps/docs/app/robots.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ export default function robots(): MetadataRoute.Robots {
99
rules: {
1010
userAgent: '*',
1111
allow: '/',
12-
// Generated text endpoints duplicate page content; keep them out of the index.
13-
disallow: ['/api/', '/llms.txt', '/llms-full.txt'],
12+
// `/llms.txt` and `/llms-full.txt` are deliberately crawlable. They exist to be
13+
// fetched by AI crawlers and answer engines, which is the audience a blanket
14+
// `User-agent: *` disallow shuts out; and a plain-text endpoint does not compete
15+
// with the HTML page for a position in a result list the way a duplicate HTML
16+
// page would. `/api/` stays out: it serves the search index, not readable content.
17+
disallow: ['/api/'],
1418
},
1519
sitemap: `${BASE}/sitemap.xml`,
1620
host: BASE,

0 commit comments

Comments
 (0)