11import SideBar from '@node-core/ui-components/Containers/Sidebar' ;
2- import { relative } from '@node-core/doc-kit/src/utils/url.mjs' ;
3- import { pages } from '#theme/config' ;
4-
5- /** @type {Array<[string, string]> } */
6- const categories = [
7- [ 'getting-started' , 'Getting Started' ] ,
8- [ 'command-line' , 'Command Line' ] ,
9- [ 'http' , 'HTTP' ] ,
10- [ 'manipulating-files' , 'Manipulating Files' ] ,
11- [ 'asynchronous-work' , 'Asynchronous Work' ] ,
12- [ 'typescript' , 'TypeScript' ] ,
13- [ 'modules' , 'Modules' ] ,
14- [ 'diagnostics' , 'Diagnostics' ] ,
15- [ 'test-runner' , 'Test Runner' ] ,
16- ] ;
17-
18- /** @type {Map<string, Array<{ heading: string, path: string }>> } */
19- const byDir = new Map ( ) ;
20- for ( const [ heading , path ] of pages ) {
21- const dir = path . split ( '/' ) [ 1 ] ;
22- if ( ! byDir . has ( dir ) ) byDir . set ( dir , [ ] ) ;
23- byDir . get ( dir ) . push ( { heading, path } ) ;
24- }
2+ import { sidebar } from '../../site.json' with { type : 'json' } ;
253
264/** @param {string } url */
275const redirect = url => ( window . location . href = url ) ;
@@ -31,26 +9,12 @@ const PrefetchLink = props => <a {...props} rel="prefetch" />;
319/**
3210 * Sidebar component for MDX documentation with page navigation
3311 */
34- export default ( { metadata } ) => {
35- const { path : currentPath , basename } = metadata ;
36- const pathname = `${ basename } .html` ;
37-
38- const groups = categories . map ( ( [ dir , title ] ) => ( {
39- groupName : title ,
40- items : byDir . get ( dir ) . map ( ( { heading, path } ) => ( {
41- label : heading ,
42- link :
43- currentPath === path ? pathname : `${ relative ( path , currentPath ) } .html` ,
44- } ) ) ,
45- } ) ) ;
46-
47- return (
48- < SideBar
49- pathname = { pathname }
50- groups = { groups }
51- onSelect = { redirect }
52- as = { PrefetchLink }
53- title = "Navigation"
54- />
55- ) ;
56- } ;
12+ export default ( { metadata } ) => (
13+ < SideBar
14+ pathname = { `/learn${ metadata . path } ` }
15+ groups = { sidebar }
16+ onSelect = { redirect }
17+ as = { PrefetchLink }
18+ title = "Navigation"
19+ />
20+ ) ;
0 commit comments