11---
2+ import MobileMenuFooter from ' virtual:starlight/components/MobileMenuFooter' ;
3+ import SidebarPersister from ' ./SidebarPersister.astro' ;
4+ import SidebarSublist from ' ./SidebarSublist.astro' ;
5+
6+ let { sidebar } = Astro .locals .starlightRoute ;
7+
8+ // Filter sidebar items per path
29const path = Astro .url .pathname ;
310
4- // Determine which top-level sections are visible
5- let allowedSections = [" root" ];
6- if (path .startsWith (" /truetech/" )) allowedSections = [" truetech" ];
7- if (path .startsWith (" /gamingforge/" )) allowedSections = [" gamingforge" ];
8- if (path .startsWith (" /lifeforge/" )) allowedSections = [" lifeforge" ];
11+ if (path .startsWith (' /truetech/' )) {
12+ sidebar = sidebar .filter (item => item .autogenerate ?.directory ?.startsWith (' truetech' ));
13+ } else if (path .startsWith (' /gamingforge/' )) {
14+ sidebar = sidebar .filter (item => item .autogenerate ?.directory ?.startsWith (' gamingforge' ));
15+ } else if (path .startsWith (' /lifeforge/' )) {
16+ sidebar = sidebar .filter (item => item .autogenerate ?.directory ?.startsWith (' lifeforge' ));
17+ } else {
18+ // root or default
19+ sidebar = sidebar .filter (item => ! item .autogenerate ?.directory ?.includes (' truetech' ) &&
20+ ! item .autogenerate ?.directory ?.includes (' gamingforge' ) &&
21+ ! item .autogenerate ?.directory ?.includes (' lifeforge' ));
22+ }
923---
1024
11- <Sidebar let:item >
12- { item && (! item .directory || allowedSections .includes (item .directory .split (" /" )[0 ])) && (
13- <li >
14- <a href = { item .href } >{ item .label } </a >
15- { item .children && item .children .length > 0 && (
16- <ul >
17- { item .children .map ((child : any ) => (
18- <li ><a href = { child .href } >{ child .label } </a ></li >
19- ))}
20- </ul >
21- )}
22- </li >
23- )}
24- </Sidebar >
25+ <SidebarPersister >
26+ <SidebarSublist sublist ={ sidebar } />
27+ </SidebarPersister >
28+
29+ <div class =" md:sl-hidden" >
30+ <MobileMenuFooter />
31+ </div >
0 commit comments