Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions scripts/html/index.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
import { execFile } from 'node:child_process';
import { cp, readFile, writeFile } from 'node:fs/promises';
import { cp, readFile } from 'node:fs/promises';
import { statSync } from 'node:fs';
import { promisify } from 'node:util';

const execFileAsync = promisify(execFile);

// TODO: Have doc-kit understand that some pages don't have meaningful information
// The llms-txt generator lists every page with a depth-1 heading. JSX-driven
// pages like the homepage produce entries with no title or description — drop
// them, they carry no information for LLMs.
const cleanLlmsTxt = async path => {
const content = await readFile(path, 'utf8');
const cleaned = content
.split('\n')
.filter(line => !line.startsWith('- []('))
.join('\n');
await writeFile(path, cleaned);
};

const runDocKit = version =>
execFileAsync(
'npx',
Expand Down Expand Up @@ -51,10 +38,8 @@ const versions = JSON.parse(await readFile('./versions.json'));

for (const version of versions) {
await runDocKit(version);
await cleanLlmsTxt(`./out/docs/api/v${version.match(/\d+/)[0]}.x/llms.txt`);
}
await runDocKit();
await cleanLlmsTxt('./out/llms.txt');

// Publish the markdown sources next to the rendered pages so the llms.txt
// links (`{path}.md`) resolve to LLM-friendly raw markdown.
Expand Down
Loading