diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-08-14 03:12:00 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-08-14 03:12:00 +0300 |
| commit | b710176fd23f4dfa3b3c2fa9b0c326b11dd5fd17 (patch) | |
| tree | 0561310dd2a46e012c81de4e30c8e7ba838f1b9a /website/scripts | |
| parent | 1bfabbab3fc9a79bf3b93f5dc3962fb8e7afea50 (diff) | |
fix(docs): apply llms patch during website builds
Diffstat (limited to 'website/scripts')
| -rw-r--r-- | website/scripts/patch-starlight-llms.mjs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/website/scripts/patch-starlight-llms.mjs b/website/scripts/patch-starlight-llms.mjs new file mode 100644 index 00000000..16d3ba9b --- /dev/null +++ b/website/scripts/patch-starlight-llms.mjs @@ -0,0 +1,24 @@ +import { readFile, writeFile } from 'node:fs/promises'; +import { resolve } from 'node:path'; + +const path = resolve('node_modules/starlight-llms-txt/llms-full.txt.ts'); +const original = await readFile(path, 'utf8'); +const importLine = "import { starlightLllmsTxtContext } from 'virtual:starlight-llms-txt/context';"; +const excludeLine = '\t\texclude: starlightLllmsTxtContext.exclude,'; + +if (original.includes(importLine) && original.includes(excludeLine)) process.exit(0); + +const withImport = original.replace( + "import { generateLlmsTxt } from './generator';", + `${importLine}\nimport { generateLlmsTxt } from './generator';`, +); +const patched = withImport.replace( + '\t\tdescription: `This is the full developer documentation for ${getSiteTitle()}`,', + '\t\tdescription: `This is the full developer documentation for ${getSiteTitle()}`,\n' + excludeLine, +); + +if (patched === original || !patched.includes(importLine) || !patched.includes(excludeLine)) { + throw new Error('starlight-llms-txt changed: update the stable-only llms-full compatibility patch'); +} + +await writeFile(path, patched, 'utf8'); |
