From 72e46823e093bcb25bef9aa2e28ec173923f9952 Mon Sep 17 00:00:00 2001 From: Marco Walz Date: Tue, 5 May 2026 09:51:36 +0200 Subject: [PATCH] fix(agent-docs): include explicit-slug sidebar entries in llms.txt sections The deriveSections() function only processed autogenerate and items entries, silently skipping { slug } entries. The References section uses explicit slugs for 15 pages, so the common-prefix fallback resolved to references/ic-interface-spec instead of references, leaving all 15 pages (plus references/index.md and references/developer-tools) out of llms.txt. Fix: collect directory prefixes from direct { slug } children when computing the common-prefix fallback for a group. This gives the References group a { dir: "references" } section entry so all 16 pages are correctly included. Also rename references/index.md title from "Reference" to "References". --- docs/references/index.md | 2 +- plugins/astro-agent-docs.mjs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/references/index.md b/docs/references/index.md index cd0b3d7..05c2b16 100644 --- a/docs/references/index.md +++ b/docs/references/index.md @@ -1,5 +1,5 @@ --- -title: "Reference" +title: "References" description: "Specifications, canister IDs, token standards, cycle costs, and technical reference for ICP" sidebar: hidden: true diff --git a/plugins/astro-agent-docs.mjs b/plugins/astro-agent-docs.mjs index 637ed4d..8dd3dde 100644 --- a/plugins/astro-agent-docs.mjs +++ b/plugins/astro-agent-docs.mjs @@ -53,8 +53,14 @@ function deriveSections(items, parentLabel = "", depth = 0) { const childSections = deriveSections(item.items, item.label, depth + 1); sections.push(...childSections); - // Add a parent fallback if children have a common directory prefix - const childDirs = childSections.map((s) => s.dir); + // Add a parent fallback if children have a common directory prefix. + // Also include directory prefixes from explicit { slug } children so that + // groups listing pages individually (rather than via autogenerate) still + // get a section entry for llms.txt prefix matching. + const directSlugDirs = item.items + .filter((c) => c.slug && c.slug.includes("/")) + .map((c) => c.slug.split("/").slice(0, -1).join("/")); + const childDirs = [...childSections.map((s) => s.dir), ...directSlugDirs]; const commonPrefix = findCommonPrefix(childDirs); if (commonPrefix) { sections.push({ dir: commonPrefix, label: item.label });