@@ -15,7 +15,9 @@ import {
1515import { rendererClassic , transformerTwoslash } from "@shikijs/twoslash" ;
1616import {
1717 NormalizedSidebar ,
18+ NormalizedSidebarItem ,
1819 SidebarItemsGeneratorVersion ,
20+ SidebarItemCategory ,
1921} from "@docusaurus/plugin-content-docs/src/sidebars/types.js" ;
2022
2123function isErrorFromVersionedDocs ( options : { meta ?: { __raw ?: string } } ) {
@@ -56,45 +58,74 @@ const rehypeShikiPlugin = [
5658 } satisfies RehypeShikiOptions ,
5759] satisfies MDXPlugin ;
5860
61+ type CustomInjectedCategory = Omit < SidebarItemCategory , "items" > & {
62+ items : any ;
63+ } ;
64+
5965function injectTypeDocSidebar (
6066 version : SidebarItemsGeneratorVersion ,
6167 items : NormalizedSidebar ,
6268) : NormalizedSidebar {
69+ console . log ( version . versionName ) ;
70+ const docs_without_python_reference = [ "0.20.0" , "0.21.0" , "0.22.0" ] ;
71+
72+ const exclude_python = docs_without_python_reference . includes (
73+ version . versionName ,
74+ ) ;
75+
6376 return items . map ( ( item ) => {
6477 if ( item . customProps ?. id === "generated-api" && item . type === "category" ) {
78+ const injectedItems : ( CustomInjectedCategory | NormalizedSidebarItem ) [ ] =
79+ [
80+ {
81+ type : "category" ,
82+ label : "React Native SDK" ,
83+ link : { type : "doc" , id : "api/mobile/index" } ,
84+ items : require (
85+ `${ version . contentPath } /api/mobile/typedoc-sidebar.cjs` ,
86+ ) ,
87+ } ,
88+ {
89+ type : "category" ,
90+ label : "React SDK" ,
91+ link : { type : "doc" , id : "api/web/index" } ,
92+ items : require (
93+ `${ version . contentPath } /api/web/typedoc-sidebar.cjs` ,
94+ ) ,
95+ } ,
96+ {
97+ type : "category" ,
98+ label : "Server SDK for JS" ,
99+ link : { type : "doc" , id : "api/server/index" } ,
100+ items : require (
101+ `${ version . contentPath } /api/server/typedoc-sidebar.cjs` ,
102+ ) ,
103+ } ,
104+ ] ;
105+
106+ if ( ! exclude_python ) {
107+ injectedItems . push ( {
108+ type : "category" ,
109+ label : "Server SDK for Python" ,
110+ link : { type : "doc" , id : "api/server-python/fishjam" } ,
111+ items : [
112+ {
113+ type : "autogenerated" ,
114+ dirName : "api/server-python" ,
115+ } ,
116+ ] ,
117+ } ) ;
118+ }
119+
65120 return {
66121 ...item ,
67122 items : [
68- ...( [
69- {
70- type : "category" ,
71- label : "React Native SDK" ,
72- link : { type : "doc" , id : "api/mobile/index" } ,
73- items : require (
74- `${ version . contentPath } /api/mobile/typedoc-sidebar.cjs` ,
75- ) ,
76- } ,
77- {
78- type : "category" ,
79- label : "React SDK" ,
80- link : { type : "doc" , id : "api/web/index" } ,
81- items : require (
82- `${ version . contentPath } /api/web/typedoc-sidebar.cjs` ,
83- ) ,
84- } ,
85- {
86- type : "category" ,
87- label : "Server SDK for JS" ,
88- link : { type : "doc" , id : "api/server/index" } ,
89- items : require (
90- `${ version . contentPath } /api/server/typedoc-sidebar.cjs` ,
91- ) ,
92- } ,
93- ] as const ) ,
94- ...item . items . filter ( ( element ) => element . type == "doc" ) ,
95- ] ,
123+ ...injectedItems ,
124+ ...item . items . filter ( ( element ) => element . type === "doc" ) ,
125+ ] as NormalizedSidebar ,
96126 } ;
97127 }
128+
98129 return item ;
99130 } ) ;
100131}
0 commit comments