@@ -13,18 +13,6 @@ import {
1313 SidebarScope ,
1414 SidebarTrigger ,
1515} from '@askrjs/themes/components' ;
16- import {
17- BookOpenIcon ,
18- CompassIcon ,
19- Layers3Icon ,
20- LibraryIcon ,
21- MonitorIcon ,
22- PanelsTopLeftIcon ,
23- RocketIcon ,
24- RouteIcon ,
25- ServerIcon ,
26- WrenchIcon ,
27- } from '@askrjs/lucide' ;
2816import { SiteLayout } from '../site-layout' ;
2917import {
3018 docsByRoute ,
@@ -35,84 +23,44 @@ import {
3523
3624function DocsNavigation ( { close } : { close ?: ( ) => void } ) {
3725 const activePath = resolveDocsRoute ( currentRoute ( ) ) ;
38- const sectionIcons = [
39- BookOpenIcon ,
40- RocketIcon ,
41- Layers3Icon ,
42- RouteIcon ,
43- MonitorIcon ,
44- ServerIcon ,
45- PanelsTopLeftIcon ,
46- WrenchIcon ,
47- CompassIcon ,
48- LibraryIcon ,
49- ] as const ;
5026
5127 return (
5228 < SidebarContent as = "nav" aria-label = "Documentation navigation" >
53- { docsSections . map ( ( section , sectionIndex ) => {
54- const active = section . pages . some ( ( page ) => page . route === activePath ) ;
55- const SectionIcon = sectionIcons [ sectionIndex ] ?? BookOpenIcon ;
56- const subsections = section . pages . reduce ( ( groups , page ) => {
57- const label = page . navSection ?? section . label ;
58- const pages = groups . get ( label ) ?? [ ] ;
59- pages . push ( page ) ;
60- groups . set ( label , pages ) ;
61- return groups ;
62- } , new Map < string , ( typeof section . pages ) [ number ] [ ] > ( ) ) ;
63-
29+ { docsSections . map ( ( section ) => {
6430 return (
65- < SidebarGroup data-nav-section = { section . id } >
66- < SidebarMenu >
67- < SidebarMenuItem >
68- < SidebarMenuButton asChild active = { active } >
69- < Link href = { section . landingRoute } onClick = { close } >
70- < SectionIcon size = { 18 } aria-hidden = "true" />
71- < span > { section . label } </ span >
72- </ Link >
73- </ SidebarMenuButton >
74- </ SidebarMenuItem >
75- </ SidebarMenu >
76- { active && (
77- < SidebarGroupContent >
78- { Array . from ( subsections ) . map ( ( [ label , pages ] ) => (
79- < div >
80- { label !== section . label && (
81- < SidebarGroupLabel > { label } </ SidebarGroupLabel >
82- ) }
83- < SidebarMenu >
84- { pages . map ( ( page ) => (
85- < SidebarMenuItem >
86- < SidebarMenuButton
87- asChild
88- active = { page . route === activePath }
89- size = "sm"
31+ < SidebarGroup key = { section . id } data-nav-section = { section . id } >
32+ < SidebarGroupLabel > { section . label } </ SidebarGroupLabel >
33+ < SidebarGroupContent >
34+ < SidebarMenu >
35+ { section . pages . map ( ( page ) => (
36+ < SidebarMenuItem key = { page . route } >
37+ < SidebarMenuButton
38+ asChild
39+ active = { page . route === activePath }
40+ size = "sm"
41+ >
42+ < Link
43+ href = { page . route }
44+ aria-current = {
45+ page . route === activePath ? 'page' : undefined
46+ }
47+ onClick = { close }
48+ >
49+ < span > { page . title } </ span >
50+ { page . status !== 'stable' && (
51+ < span
52+ class = "docs-sidebar-nav__status"
53+ title = { page . status }
9054 >
91- < Link
92- href = { page . route }
93- aria-current = {
94- page . route === activePath ? 'page' : undefined
95- }
96- onClick = { close }
97- >
98- < span > { page . title } </ span >
99- { page . status !== 'stable' && (
100- < span
101- class = "docs-sidebar-nav__status"
102- title = { page . status }
103- >
104- •
105- </ span >
106- ) }
107- </ Link >
108- </ SidebarMenuButton >
109- </ SidebarMenuItem >
110- ) ) }
111- </ SidebarMenu >
112- </ div >
55+ •
56+ </ span >
57+ ) }
58+ </ Link >
59+ </ SidebarMenuButton >
60+ </ SidebarMenuItem >
11361 ) ) }
114- </ SidebarGroupContent >
115- ) }
62+ </ SidebarMenu >
63+ </ SidebarGroupContent >
11664 </ SidebarGroup >
11765 ) ;
11866 } ) }
@@ -130,7 +78,7 @@ function TableOfContents() {
13078 < p > On this page</ p >
13179 < ul >
13280 { headings . map ( ( heading ) => (
133- < li >
81+ < li key = { heading . id } >
13482 < a href = { `#${ heading . id } ` } > { heading . title } </ a >
13583 </ li >
13684 ) ) }
0 commit comments