Skip to content

Commit

Permalink
Fix autogenerated sidebar bug with index routes in subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed May 26, 2023
1 parent 51fe914 commit d8a171b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-pigs-trade.md
@@ -0,0 +1,5 @@
---
"@astrojs/starlight": patch
---

Fix autogenerated sidebar bug with index routes in subdirectories
2 changes: 2 additions & 0 deletions packages/starlight/utils/navigation.ts
Expand Up @@ -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鈥檛 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.
Expand Down

0 comments on commit d8a171b

Please sign in to comment.