File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ const runLinkCheck = process.env.RUN_LINK_CHECK || false;
4444// https://astro.build/config
4545export default defineConfig ( {
4646 site : "https://developers.cloudflare.com" ,
47- trailingSlash : "always" ,
4847 markdown : {
4948 smartypants : false ,
5049 rehypePlugins : [
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import Default from "@astrojs/starlight/components/Sidebar.astro";
55import { Icon as AstroIcon } from " astro-icon/components" ;
66import { lookupProductTitle } from " ~/util/sidebar" ;
77
8- const [product, module] = Astro .url .pathname .split (" /" ).slice ( 1 , - 1 );
8+ const [product, module] = Astro .url .pathname .split (" /" ).filter ( Boolean );
99---
1010
1111<a
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ const sidebars = new Map<string, Group>();
1616
1717export async function getSidebar ( context : AstroGlobal < Props > ) {
1818 const pathname = context . url . pathname ;
19- const segments = pathname . split ( "/" ) . slice ( 1 , - 1 ) ;
19+ const segments = pathname . split ( "/" ) . filter ( Boolean ) ;
2020
2121 const product = segments . at ( 0 ) ;
2222
@@ -96,9 +96,14 @@ function setSidebarCurrentEntry(
9696 pathname : string ,
9797) : boolean {
9898 for ( const entry of sidebar ) {
99- if ( entry . type === "link" && entry . href === pathname ) {
100- entry . isCurrent = true ;
101- return true ;
99+ if ( entry . type === "link" ) {
100+ const href = entry . href ;
101+
102+ // Compare with and without trailing slash
103+ if ( href === pathname || href . slice ( 0 , - 1 ) === href ) {
104+ entry . isCurrent = true ;
105+ return true ;
106+ }
102107 }
103108
104109 if (
You can’t perform that action at this time.
0 commit comments