diff --git a/src/components/overrides/Sidebar.astro b/src/components/overrides/Sidebar.astro index 935fa4926f1995..ca0a4555b7725a 100644 --- a/src/components/overrides/Sidebar.astro +++ b/src/components/overrides/Sidebar.astro @@ -5,7 +5,7 @@ import Default from "@astrojs/starlight/components/Sidebar.astro"; import { Icon as AstroIcon } from "astro-icon/components"; import { lookupProductTitle } from "~/util/sidebar"; -const [product, module] = Astro.url.pathname.split("/").slice(1, -1); +const [product, module] = Astro.url.pathname.split("/").filter(Boolean); --- (); export async function getSidebar(context: AstroGlobal) { const pathname = context.url.pathname; - const segments = pathname.split("/").slice(1, -1); + const segments = pathname.split("/").filter(Boolean); const product = segments.at(0); @@ -96,9 +96,14 @@ function setSidebarCurrentEntry( pathname: string, ): boolean { for (const entry of sidebar) { - if (entry.type === "link" && entry.href === pathname) { - entry.isCurrent = true; - return true; + if (entry.type === "link") { + const href = entry.href; + + // Compare with and without trailing slash + if (href === pathname || href.slice(0, -1) === href) { + entry.isCurrent = true; + return true; + } } if (