File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,26 @@ import {
1313import tsconfigBase from "../../../tsconfig.base.json" with { type : "json" } ;
1414import { MarkdownTransform , clercImports } from "../plugins/markdown-transform" ;
1515
16+ const flattenItems = (
17+ items : DefaultTheme . SidebarItem [ ] ,
18+ ) : DefaultTheme . SidebarItem [ ] =>
19+ items
20+ . flatMap ( ( item ) => {
21+ if ( item . items && ! item . link ) {
22+ return flattenItems ( item . items ) ;
23+ }
24+
25+ if ( item . items ) {
26+ return {
27+ ...item ,
28+ items : flattenItems ( item . items ) ,
29+ } ;
30+ }
31+
32+ return item ;
33+ } )
34+ . toSorted ( ( a , b ) => a . text ! . localeCompare ( b . text ! ) ) ;
35+
1636export function getTypedocSidebar ( pkg : string ) {
1737 const filepath = path . resolve (
1838 import . meta. dirname ,
@@ -27,9 +47,7 @@ export function getTypedocSidebar(pkg: string) {
2747 readFileSync ( filepath , "utf-8" ) ,
2848 ) as DefaultTheme . SidebarItem [ ] ;
2949
30- return items
31- . flatMap ( ( i ) => i . items ! )
32- . toSorted ( ( a , b ) => a . text ! . localeCompare ( b . text ! ) ) ;
50+ return flattenItems ( items ) ;
3351 } catch ( error ) {
3452 console . error ( `Failed to load typedoc sidebar for ${ pkg } :` , error ) ;
3553
You can’t perform that action at this time.
0 commit comments