Skip to content

Commit

Permalink
Fix false positive in sidebar autogeneration logic
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed May 25, 2023
1 parent 116c4f5 commit d8b9f32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/metal-needles-shout.md
@@ -0,0 +1,5 @@
---
"@astrojs/starlight": patch
---

Fix false positive in sidebar autogeneration logic
8 changes: 7 additions & 1 deletion packages/starlight/utils/navigation.ts
Expand Up @@ -65,7 +65,13 @@ function groupFromAutogenerateConfig(
): Group {
const { directory } = item.autogenerate;
const localeDir = locale ? locale + '/' + directory : directory;
const dirDocs = routes.filter((doc) => doc.slug.startsWith(localeDir));
const dirDocs = routes.filter(
(doc) =>
// Match against `foo.md` or `foo/index.md`.
doc.slug === localeDir ||
// Match against `foo/anything/else.md`.
doc.slug.startsWith(localeDir + '/')
);
const tree = treeify(dirDocs, localeDir);
return {
type: 'group',
Expand Down

0 comments on commit d8b9f32

Please sign in to comment.