From d8b9f3260daaceed8a31eedcc44bd00733f96254 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Thu, 25 May 2023 13:17:15 +0200 Subject: Fix false positive in sidebar autogeneration logic --- .changeset/metal-needles-shout.md | 5 +++++ packages/starlight/utils/navigation.ts | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/metal-needles-shout.md diff --git a/.changeset/metal-needles-shout.md b/.changeset/metal-needles-shout.md new file mode 100644 index 00000000..4ea11e12 --- /dev/null +++ b/.changeset/metal-needles-shout.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Fix false positive in sidebar autogeneration logic diff --git a/packages/starlight/utils/navigation.ts b/packages/starlight/utils/navigation.ts index ae4f918b..1d5a1764 100644 --- a/packages/starlight/utils/navigation.ts +++ b/packages/starlight/utils/navigation.ts @@ -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', -- cgit