summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Swithinbank2023-05-26 12:00:05 +0200
committerChris Swithinbank2023-05-26 12:00:05 +0200
commitd8a171b6b45c73151485fe8f08630fb6a1cc12a6 (patch)
tree0ad02349e078aeba9de59b44bd620bb154b49a40
parent51fe91468fea125ec33cb6d6b1b66f147302fdc0 (diff)
downloadIT.starlight-d8a171b6b45c73151485fe8f08630fb6a1cc12a6.tar.gz
IT.starlight-d8a171b6b45c73151485fe8f08630fb6a1cc12a6.tar.bz2
IT.starlight-d8a171b6b45c73151485fe8f08630fb6a1cc12a6.zip
Fix autogenerated sidebar bug with index routes in subdirectories
-rw-r--r--.changeset/lovely-pigs-trade.md5
-rw-r--r--packages/starlight/utils/navigation.ts2
2 files changed, 7 insertions, 0 deletions
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.