From d8a171b6b45c73151485fe8f08630fb6a1cc12a6 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 26 May 2023 12:00:05 +0200 Subject: Fix autogenerated sidebar bug with index routes in subdirectories --- .changeset/lovely-pigs-trade.md | 5 +++++ packages/starlight/utils/navigation.ts | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 .changeset/lovely-pigs-trade.md diff --git a/.changeset/lovely-pigs-trade.md b/.changeset/lovely-pigs-trade.md new file mode 100644 index 00000000..e765c6fd --- /dev/null +++ b/.changeset/lovely-pigs-trade.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Fix autogenerated sidebar bug with index routes in subdirectories diff --git a/packages/starlight/utils/navigation.ts b/packages/starlight/utils/navigation.ts index 1d5a1764..e7e6a91e 100644 --- a/packages/starlight/utils/navigation.ts +++ b/packages/starlight/utils/navigation.ts @@ -114,6 +114,8 @@ function makeLink(href: string, label: string, currentPathname: string): Link { /** Get the segments leading to a page. */ function getBreadcrumbs(slug: string, baseDir: string): string[] { + // Index slugs will match `baseDir` and don’t include breadcrumbs. + if (slug === baseDir) return []; // Ensure base directory ends in a trailing slash. if (!baseDir.endsWith('/')) baseDir += '/'; // Strip base directory from slug if present. -- cgit