Skip to content

Commit ebc822b

Browse files
committed
move to working custom sidebar component
1 parent f09f11d commit ebc822b

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

src/components/CustomSidebar.astro

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,17 @@
11
---
2-
const path = Astro.url.pathname;
2+
import type { Props } from '../props';
33
4-
// Get current sidebar from Starlight runtime
5-
let sidebar = Astro.locals.starlightRoute?.sidebar ?? [];
4+
import SidebarPersister from '@astrojs/starlight/components/SidebarPersister.astro';
5+
import SidebarSublist from '@astrojs/starlight/components/SidebarSublist.astro';
6+
import MobileMenuFooter from '@astrojs/starlight/components/MobileMenuFooter.astro';
67
7-
// Filter items based on the top-level path
8-
if (path.startsWith('/truetech/')) {
9-
sidebar = sidebar.filter((item: any) =>
10-
item.autogenerate?.directory?.startsWith('truetech')
11-
);
12-
} else if (path.startsWith('/gamingforge/')) {
13-
sidebar = sidebar.filter((item: any) =>
14-
item.autogenerate?.directory?.startsWith('gamingforge')
15-
);
16-
} else if (path.startsWith('/lifeforge/')) {
17-
sidebar = sidebar.filter((item: any) =>
18-
item.autogenerate?.directory?.startsWith('lifeforge')
19-
);
20-
} else {
21-
// Root site: exclude sub-project sections
22-
sidebar = sidebar.filter((item: any) =>
23-
!['truetech', 'gamingforge', 'lifeforge'].some(prefix =>
24-
item.autogenerate?.directory?.startsWith(prefix)
25-
)
26-
);
27-
}
8+
const { sidebar } = Astro.props;
289
---
2910

30-
<SidebarPersister>
31-
<SidebarSublist sublist={sidebar} />
11+
<SidebarPersister {...Astro.props}>
12+
<SidebarSublist sublist={sidebar} />
3213
</SidebarPersister>
3314

34-
<MobileMenuFooter class="md:sl-hidden" />
15+
<div class="md:sl-hidden">
16+
<MobileMenuFooter {...Astro.props} />
17+
</div>

0 commit comments

Comments
 (0)