From c54bfb6f95e8994df5096f0d007c05d47a78bd07 Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Mon, 10 Nov 2025 13:09:37 +0100 Subject: [PATCH 1/2] scripts: fix incorrect Releases page link in LLMS.txt --- scripts/generate-llms-txt.js | 38 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/scripts/generate-llms-txt.js b/scripts/generate-llms-txt.js index f98000e2da9..f54b5f2b2fe 100644 --- a/scripts/generate-llms-txt.js +++ b/scripts/generate-llms-txt.js @@ -36,6 +36,7 @@ const INPUT_FILE_PATHS = [ const SLUG_TO_URL = { 'architecture-overview': 'overview', 'architecture-glossary': 'glossary', + 'releases/releases': 'releases', }; // Function to convert the TypeScript sidebar config to JSON @@ -249,45 +250,47 @@ function generateMarkdown(sidebarConfig, docPath, prefix, unavailableUrls) { ); // Process each item in the category - reorderedArray.forEach(item => { + for (const item of reorderedArray) { if (typeof item === 'string') { - // This is a direct page reference const fullDocPath = `${docPath}${mapDocPath(item, prefix)}`; if (!isEntryUnavailable(unavailableUrls, fullDocPath)) { - const {title, slug} = extractMetadataFromMarkdown(fullDocPath); - markdown += `- [${title}](${URL_PREFIX}${prefix}/${slug ?? item})\n`; + if (item.includes('/')) { + const pathChunks = item.split('/'); + if (pathChunks[0] === pathChunks[1]) { + markdown += appendPageLink(fullDocPath, prefix, pathChunks[0]); + continue; + } + } + markdown += appendPageLink(fullDocPath, prefix, item); } } else if (typeof item === 'object') { if (item.type === 'doc' && item.id) { - // This is a doc reference with an explicit ID const fullDocPath = `${docPath}${mapDocPath(item, prefix)}`; if (!isEntryUnavailable(unavailableUrls, fullDocPath)) { - const {title, slug} = extractMetadataFromMarkdown(fullDocPath); - markdown += `- [${title}](${URL_PREFIX}${prefix}/${slug ?? item.id})\n`; + markdown += appendPageLink(fullDocPath, prefix, item.id); } } else if (item.type === 'category' && Array.isArray(item.items)) { - // This is a category with nested items markdown += `#### ${item.label}\n\n`; item.items.forEach(nestedItem => { if (typeof nestedItem === 'string') { const fullDocPath = `${docPath}${mapDocPath(nestedItem, prefix)}`; if (!isEntryUnavailable(unavailableUrls, fullDocPath)) { - const {title, slug} = - extractMetadataFromMarkdown(fullDocPath); - markdown += `- [${title}](${URL_PREFIX}${prefix}/${slug ?? nestedItem})\n`; + markdown += appendPageLink(fullDocPath, prefix, nestedItem); } } else if (nestedItem.type === 'doc' && nestedItem.id) { const fullDocPath = `${docPath}${mapDocPath(nestedItem, prefix)}`; if (!isEntryUnavailable(unavailableUrls, fullDocPath)) { - const {title, slug} = - extractMetadataFromMarkdown(fullDocPath); - markdown += `- [${title}](${URL_PREFIX}${prefix}/${slug ?? nestedItem.id})\n`; + markdown += appendPageLink( + fullDocPath, + prefix, + nestedItem.id + ); } } }); } } - }); + } }); }); @@ -295,6 +298,11 @@ function generateMarkdown(sidebarConfig, docPath, prefix, unavailableUrls) { return markdown.replace(/(#+ .*)\n/g, '\n$1\n').replace(/\n(\n)+/g, '\n\n'); } +function appendPageLink(fullDocPath, prefix, fsPath) { + const {title, slug} = extractMetadataFromMarkdown(fullDocPath); + return `- [${title}](${URL_PREFIX}${prefix}/${slug ?? fsPath})\n`; +} + async function generateOutput() { const results = []; const promises = []; From 3f8fd525e89ec73d929521cb0e116089d6c9c073 Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Tue, 11 Nov 2025 12:18:59 +0100 Subject: [PATCH 2/2] add types to helper --- scripts/src/generate-llms-txt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/src/generate-llms-txt.ts b/scripts/src/generate-llms-txt.ts index 6c8e5ec18f3..2eb18ae16d3 100644 --- a/scripts/src/generate-llms-txt.ts +++ b/scripts/src/generate-llms-txt.ts @@ -325,7 +325,7 @@ function generateMarkdown( return markdown.replace(/(#+ .*)\n/g, '\n$1\n').replace(/\n(\n)+/g, '\n\n'); } -function appendPageLink(fullDocPath, prefix, fsPath) { +function appendPageLink(fullDocPath: string, prefix: string, fsPath: string) { const {title, slug} = extractMetadataFromMarkdown(fullDocPath); return `- [${title}](${URL_PREFIX}${prefix}/${slug ?? fsPath})\n`; }