zudoku 0.13.6 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/cli.js +2 -2
  2. package/dist/app/entry.client.js +2 -2
  3. package/dist/app/entry.client.js.map +1 -1
  4. package/dist/app/entry.server.js +3 -0
  5. package/dist/app/entry.server.js.map +1 -1
  6. package/dist/app/main.d.ts +1 -0
  7. package/dist/app/main.js +7 -22
  8. package/dist/app/main.js.map +1 -1
  9. package/dist/app/standalone.js.map +1 -1
  10. package/dist/cli/common/machine-id/lib.js.map +1 -1
  11. package/dist/cli/common/outdated.js.map +1 -1
  12. package/dist/cli/common/utils/box.js.map +1 -1
  13. package/dist/config/validators/InputSidebarSchema.d.ts +2 -2
  14. package/dist/config/validators/SidebarSchema.d.ts +24 -1
  15. package/dist/config/validators/SidebarSchema.js +76 -39
  16. package/dist/config/validators/SidebarSchema.js.map +1 -1
  17. package/dist/config/validators/validate.d.ts +329 -264
  18. package/dist/config/validators/validate.js +11 -10
  19. package/dist/config/validators/validate.js.map +1 -1
  20. package/dist/index.d.ts +4 -1
  21. package/dist/index.js +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/lib/components/Header.js +5 -1
  24. package/dist/lib/components/Header.js.map +1 -1
  25. package/dist/lib/components/Heading.d.ts +1 -1
  26. package/dist/lib/components/SyntaxHighlight.js +4 -1
  27. package/dist/lib/components/SyntaxHighlight.js.map +1 -1
  28. package/dist/lib/components/TopNavigation.js +30 -5
  29. package/dist/lib/components/TopNavigation.js.map +1 -1
  30. package/dist/lib/components/context/ZudokuContext.d.ts +6 -12
  31. package/dist/lib/components/context/ZudokuContext.js +26 -20
  32. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  33. package/dist/lib/components/navigation/Sidebar.js +3 -3
  34. package/dist/lib/components/navigation/Sidebar.js.map +1 -1
  35. package/dist/lib/components/navigation/SidebarCategory.js +2 -4
  36. package/dist/lib/components/navigation/SidebarCategory.js.map +1 -1
  37. package/dist/lib/components/navigation/SidebarItem.js +1 -3
  38. package/dist/lib/components/navigation/SidebarItem.js.map +1 -1
  39. package/dist/lib/components/navigation/utils.js +10 -14
  40. package/dist/lib/components/navigation/utils.js.map +1 -1
  41. package/dist/lib/core/DevPortalContext.d.ts +3 -7
  42. package/dist/lib/core/DevPortalContext.js.map +1 -1
  43. package/dist/lib/core/plugins.d.ts +1 -0
  44. package/dist/lib/core/plugins.js.map +1 -1
  45. package/dist/lib/plugins/api-keys/CreateApiKey.js +1 -1
  46. package/dist/lib/plugins/api-keys/CreateApiKey.js.map +1 -1
  47. package/dist/lib/plugins/markdown/index.d.ts +5 -6
  48. package/dist/lib/plugins/markdown/index.js +31 -3
  49. package/dist/lib/plugins/markdown/index.js.map +1 -1
  50. package/dist/lib/plugins/markdown/resolver.d.ts +38 -0
  51. package/dist/lib/plugins/markdown/resolver.js +75 -0
  52. package/dist/lib/plugins/markdown/resolver.js.map +1 -0
  53. package/dist/lib/plugins/openapi/Endpoint.js.map +1 -1
  54. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
  55. package/dist/lib/plugins/openapi/Sidecar.js +2 -2
  56. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  57. package/dist/lib/plugins/openapi/client/worker.js.map +1 -1
  58. package/dist/lib/plugins/openapi/index.js.map +1 -1
  59. package/dist/lib/plugins/openapi/playground/Playground.js +1 -1
  60. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  61. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +1 -1
  62. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
  63. package/dist/lib/ui/Accordion.d.ts +7 -0
  64. package/dist/lib/ui/Accordion.js +14 -0
  65. package/dist/lib/ui/Accordion.js.map +1 -0
  66. package/dist/lib/ui/Alert.d.ts +8 -0
  67. package/dist/lib/ui/Alert.js +23 -0
  68. package/dist/lib/ui/Alert.js.map +1 -0
  69. package/dist/lib/ui/AlertDialog.d.ts +20 -0
  70. package/dist/lib/ui/AlertDialog.js +27 -0
  71. package/dist/lib/ui/AlertDialog.js.map +1 -0
  72. package/dist/lib/ui/AspectRatio.d.ts +3 -0
  73. package/dist/lib/ui/AspectRatio.js +4 -0
  74. package/dist/lib/ui/AspectRatio.js.map +1 -0
  75. package/dist/lib/ui/Badge.d.ts +9 -0
  76. package/dist/lib/ui/Badge.js +21 -0
  77. package/dist/lib/ui/Badge.js.map +1 -0
  78. package/dist/lib/ui/Breadcrumb.d.ts +19 -0
  79. package/dist/lib/ui/Breadcrumb.js +24 -0
  80. package/dist/lib/ui/Breadcrumb.js.map +1 -0
  81. package/dist/lib/ui/Button.d.ts +2 -3
  82. package/dist/lib/ui/Button.js +1 -1
  83. package/dist/lib/ui/Button.js.map +1 -1
  84. package/dist/lib/ui/Carousel.d.ts +18 -0
  85. package/dist/lib/ui/Carousel.js +99 -0
  86. package/dist/lib/ui/Carousel.js.map +1 -0
  87. package/dist/lib/ui/Checkbox.d.ts +4 -0
  88. package/dist/lib/ui/Checkbox.js +9 -0
  89. package/dist/lib/ui/Checkbox.js.map +1 -0
  90. package/dist/lib/ui/Collapsible.d.ts +5 -0
  91. package/dist/lib/ui/Collapsible.js +6 -0
  92. package/dist/lib/ui/Collapsible.js.map +1 -0
  93. package/dist/lib/{components → ui}/Dialog.js +2 -2
  94. package/dist/lib/ui/Dialog.js.map +1 -0
  95. package/dist/lib/ui/Form.d.ts +23 -0
  96. package/dist/lib/ui/Form.js +63 -0
  97. package/dist/lib/ui/Form.js.map +1 -0
  98. package/dist/lib/ui/HoverCard.d.ts +6 -0
  99. package/dist/lib/ui/HoverCard.js +10 -0
  100. package/dist/lib/ui/HoverCard.js.map +1 -0
  101. package/dist/lib/ui/Label.d.ts +5 -0
  102. package/dist/lib/ui/Label.js +10 -0
  103. package/dist/lib/ui/Label.js.map +1 -0
  104. package/dist/lib/ui/Pagination.d.ts +28 -0
  105. package/dist/lib/ui/Pagination.js +24 -0
  106. package/dist/lib/ui/Pagination.js.map +1 -0
  107. package/dist/lib/ui/Popover.d.ts +6 -0
  108. package/dist/lib/ui/Popover.js +10 -0
  109. package/dist/lib/ui/Popover.js.map +1 -0
  110. package/dist/lib/ui/Progress.d.ts +4 -0
  111. package/dist/lib/ui/Progress.js +8 -0
  112. package/dist/lib/ui/Progress.js.map +1 -0
  113. package/dist/lib/ui/RadioGroup.d.ts +5 -0
  114. package/dist/lib/ui/RadioGroup.js +15 -0
  115. package/dist/lib/ui/RadioGroup.js.map +1 -0
  116. package/dist/lib/ui/ScrollArea.d.ts +5 -0
  117. package/dist/lib/ui/ScrollArea.js +12 -0
  118. package/dist/lib/ui/ScrollArea.js.map +1 -0
  119. package/dist/lib/ui/Select.js.map +1 -0
  120. package/dist/lib/ui/Skeleton.d.ts +2 -0
  121. package/dist/lib/ui/Skeleton.js +7 -0
  122. package/dist/lib/ui/Skeleton.js.map +1 -0
  123. package/dist/lib/ui/Slider.d.ts +4 -0
  124. package/dist/lib/ui/Slider.js +8 -0
  125. package/dist/lib/ui/Slider.js.map +1 -0
  126. package/dist/lib/ui/Switch.d.ts +4 -0
  127. package/dist/lib/ui/Switch.js +8 -0
  128. package/dist/lib/ui/Switch.js.map +1 -0
  129. package/dist/lib/ui/Textarea.d.ts +4 -0
  130. package/dist/lib/ui/Textarea.js +9 -0
  131. package/dist/lib/ui/Textarea.js.map +1 -0
  132. package/dist/lib/ui/Toggle.d.ts +12 -0
  133. package/dist/lib/ui/Toggle.js +26 -0
  134. package/dist/lib/ui/Toggle.js.map +1 -0
  135. package/dist/lib/ui/ToggleGroup.d.ts +12 -0
  136. package/dist/lib/ui/ToggleGroup.js +21 -0
  137. package/dist/lib/ui/ToggleGroup.js.map +1 -0
  138. package/dist/lib/ui/Tooltip.d.ts +7 -0
  139. package/dist/lib/ui/Tooltip.js +11 -0
  140. package/dist/lib/ui/Tooltip.js.map +1 -0
  141. package/dist/lib/util/MdxComponents.js.map +1 -1
  142. package/dist/lib/util/useScrollToAnchor.js.map +1 -1
  143. package/dist/vite/build.js +7 -2
  144. package/dist/vite/build.js.map +1 -1
  145. package/dist/vite/config.js +11 -6
  146. package/dist/vite/config.js.map +1 -1
  147. package/dist/vite/debug.d.ts +1 -0
  148. package/dist/vite/debug.js +10 -0
  149. package/dist/vite/debug.js.map +1 -0
  150. package/dist/vite/plugin-component.js +17 -7
  151. package/dist/vite/plugin-component.js.map +1 -1
  152. package/dist/vite/plugin-config-reload.js +0 -2
  153. package/dist/vite/plugin-config-reload.js.map +1 -1
  154. package/dist/vite/plugin-docs.js +37 -26
  155. package/dist/vite/plugin-docs.js.map +1 -1
  156. package/dist/vite/plugin-frontmatter.d.ts +2 -1
  157. package/dist/vite/plugin-frontmatter.js +27 -24
  158. package/dist/vite/plugin-frontmatter.js.map +1 -1
  159. package/dist/vite/plugin-sidebar.js +7 -6
  160. package/dist/vite/plugin-sidebar.js.map +1 -1
  161. package/dist/vite/plugin.js +1 -1
  162. package/dist/vite/plugin.js.map +1 -1
  163. package/dist/vite/prerender.d.ts +5 -1
  164. package/dist/vite/prerender.js +6 -5
  165. package/dist/vite/prerender.js.map +1 -1
  166. package/lib/{utils-G5XSiZc9.js → AnchorLink-BbB2q-jx.js} +231 -275
  167. package/lib/AnchorLink-BbB2q-jx.js.map +1 -0
  168. package/lib/{AuthenticationPlugin-tBvLKsFg.js → AuthenticationPlugin-C9BHGXlE.js} +2 -2
  169. package/lib/{AuthenticationPlugin-tBvLKsFg.js.map → AuthenticationPlugin-C9BHGXlE.js.map} +1 -1
  170. package/lib/{CategoryHeading-D2WS6sRI.js → CategoryHeading-Bb9dqxD3.js} +4 -4
  171. package/lib/{CategoryHeading-D2WS6sRI.js.map → CategoryHeading-Bb9dqxD3.js.map} +1 -1
  172. package/lib/{DeveloperHint-CRiZjqd2.js → DeveloperHint-DHdLXGHA.js} +2 -2
  173. package/lib/{DeveloperHint-CRiZjqd2.js.map → DeveloperHint-DHdLXGHA.js.map} +1 -1
  174. package/lib/{Markdown-DM4zv3MA.js → Markdown-BDcCAWwm.js} +4268 -6651
  175. package/lib/Markdown-BDcCAWwm.js.map +1 -0
  176. package/lib/{MdxPage-tWI_P8wP.js → MdxPage-DKMH_t0f.js} +31 -29
  177. package/lib/{MdxPage-tWI_P8wP.js.map → MdxPage-DKMH_t0f.js.map} +1 -1
  178. package/lib/{OperationList-Cd3lue0b.js → OperationList-DnaAtLxP.js} +131 -127
  179. package/lib/OperationList-DnaAtLxP.js.map +1 -0
  180. package/lib/{Route-DI0Y0pIV.js → Route-DSbLrlig.js} +2 -2
  181. package/lib/{Route-DI0Y0pIV.js.map → Route-DSbLrlig.js.map} +1 -1
  182. package/lib/Select-Bagt3Bme.js +223 -0
  183. package/lib/Select-Bagt3Bme.js.map +1 -0
  184. package/lib/{SlotletProvider-CBqY8mp6.js → SlotletProvider-4Naek_5M.js} +4 -4
  185. package/lib/{SlotletProvider-CBqY8mp6.js.map → SlotletProvider-4Naek_5M.js.map} +1 -1
  186. package/lib/Spinner-C6zroowC.js +40 -0
  187. package/lib/Spinner-C6zroowC.js.map +1 -0
  188. package/lib/StaggeredRender-DDHSzQKE.js +17 -0
  189. package/lib/StaggeredRender-DDHSzQKE.js.map +1 -0
  190. package/lib/{ZudokuContext-DEoP3GGJ.js → ZudokuContext-BKXGJTmu.js} +460 -411
  191. package/lib/ZudokuContext-BKXGJTmu.js.map +1 -0
  192. package/lib/__vite-browser-external-BYRIRx8p.js +9 -0
  193. package/lib/__vite-browser-external-BYRIRx8p.js.map +1 -0
  194. package/lib/assets/worker-Bf8vjASY.js.map +1 -1
  195. package/lib/cn-BmFQLtkS.js +2279 -0
  196. package/lib/cn-BmFQLtkS.js.map +1 -0
  197. package/lib/hook-sn0zMTkE.js +229 -0
  198. package/lib/hook-sn0zMTkE.js.map +1 -0
  199. package/lib/{index-Bs9roz8y.js → index-B3F9d8oi.js} +1201 -1429
  200. package/lib/index-B3F9d8oi.js.map +1 -0
  201. package/lib/index-BuAyrJe3.js +46 -0
  202. package/lib/index-BuAyrJe3.js.map +1 -0
  203. package/lib/index.esm-C5mr_sKO.js +1193 -0
  204. package/lib/index.esm-C5mr_sKO.js.map +1 -0
  205. package/lib/ui/Accordion.js +47 -0
  206. package/lib/ui/Accordion.js.map +1 -0
  207. package/lib/ui/Alert.js +51 -0
  208. package/lib/ui/Alert.js.map +1 -0
  209. package/lib/ui/AlertDialog.js +114 -0
  210. package/lib/ui/AlertDialog.js.map +1 -0
  211. package/lib/ui/AspectRatio.js +6 -0
  212. package/lib/ui/AspectRatio.js.map +1 -0
  213. package/lib/ui/Badge.js +27 -0
  214. package/lib/ui/Badge.js.map +1 -0
  215. package/lib/ui/Breadcrumb.js +94 -0
  216. package/lib/ui/Breadcrumb.js.map +1 -0
  217. package/lib/ui/Button.js +49 -0
  218. package/lib/ui/Button.js.map +1 -0
  219. package/lib/ui/Callout.js +77 -0
  220. package/lib/ui/Callout.js.map +1 -0
  221. package/lib/ui/Card.js +62 -0
  222. package/lib/ui/Card.js.map +1 -0
  223. package/lib/ui/Carousel.js +1410 -0
  224. package/lib/ui/Carousel.js.map +1 -0
  225. package/lib/ui/Checkbox.js +28 -0
  226. package/lib/ui/Checkbox.js.map +1 -0
  227. package/lib/ui/Collapsible.js +8 -0
  228. package/lib/ui/Collapsible.js.map +1 -0
  229. package/lib/ui/Dialog.js +101 -0
  230. package/lib/ui/Dialog.js.map +1 -0
  231. package/lib/ui/Drawer.js +1153 -0
  232. package/lib/ui/Drawer.js.map +1 -0
  233. package/lib/ui/DropdownMenu.js +145 -0
  234. package/lib/ui/DropdownMenu.js.map +1 -0
  235. package/lib/ui/Form.js +95 -0
  236. package/lib/ui/Form.js.map +1 -0
  237. package/lib/ui/HoverCard.js +24 -0
  238. package/lib/ui/HoverCard.js.map +1 -0
  239. package/lib/ui/Input.js +22 -0
  240. package/lib/ui/Input.js.map +1 -0
  241. package/lib/ui/Label.js +20 -0
  242. package/lib/ui/Label.js.map +1 -0
  243. package/lib/ui/Pagination.js +106 -0
  244. package/lib/ui/Pagination.js.map +1 -0
  245. package/lib/ui/Popover.js +24 -0
  246. package/lib/ui/Popover.js.map +1 -0
  247. package/lib/ui/Progress.js +27 -0
  248. package/lib/ui/Progress.js.map +1 -0
  249. package/lib/ui/RadioGroup.js +32 -0
  250. package/lib/ui/RadioGroup.js.map +1 -0
  251. package/lib/ui/ScrollArea.js +39 -0
  252. package/lib/ui/ScrollArea.js.map +1 -0
  253. package/lib/ui/Select.js +122 -0
  254. package/lib/ui/Select.js.map +1 -0
  255. package/lib/ui/Skeleton.js +18 -0
  256. package/lib/ui/Skeleton.js.map +1 -0
  257. package/lib/ui/Slider.js +24 -0
  258. package/lib/ui/Slider.js.map +1 -0
  259. package/lib/ui/Switch.js +28 -0
  260. package/lib/ui/Switch.js.map +1 -0
  261. package/lib/ui/Tabs.js +47 -0
  262. package/lib/ui/Tabs.js.map +1 -0
  263. package/lib/ui/Textarea.js +21 -0
  264. package/lib/ui/Textarea.js.map +1 -0
  265. package/lib/ui/Toggle.js +38 -0
  266. package/lib/ui/Toggle.js.map +1 -0
  267. package/lib/ui/ToggleGroup.js +42 -0
  268. package/lib/ui/ToggleGroup.js.map +1 -0
  269. package/lib/ui/Tooltip.js +24 -0
  270. package/lib/ui/Tooltip.js.map +1 -0
  271. package/lib/{urql-core-KJnLL26g.js → urql-core-CqTI9H6N.js} +289 -261
  272. package/lib/urql-core-CqTI9H6N.js.map +1 -0
  273. package/lib/zudoku.auth-clerk.js +1 -1
  274. package/lib/zudoku.auth-openid.js +2 -2
  275. package/lib/zudoku.components.js +889 -2876
  276. package/lib/zudoku.components.js.map +1 -1
  277. package/lib/zudoku.openapi-worker.js +1 -1
  278. package/lib/zudoku.plugin-api-keys.js +21 -18
  279. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  280. package/lib/zudoku.plugin-custom-pages.js +14 -13
  281. package/lib/zudoku.plugin-custom-pages.js.map +1 -1
  282. package/lib/zudoku.plugin-markdown.js +93 -27
  283. package/lib/zudoku.plugin-markdown.js.map +1 -1
  284. package/lib/zudoku.plugin-openapi.js +6 -6
  285. package/package.json +30 -8
  286. package/src/app/entry.client.tsx +4 -2
  287. package/src/app/entry.server.tsx +4 -0
  288. package/src/app/main.css +4 -0
  289. package/src/app/main.tsx +10 -26
  290. package/src/app/standalone.tsx +1 -1
  291. package/src/lib/components/Header.tsx +10 -2
  292. package/src/lib/components/SyntaxHighlight.tsx +5 -1
  293. package/src/lib/components/TopNavigation.tsx +58 -24
  294. package/src/lib/components/context/ZudokuContext.ts +28 -20
  295. package/src/lib/components/navigation/Sidebar.tsx +5 -5
  296. package/src/lib/components/navigation/SidebarCategory.tsx +2 -4
  297. package/src/lib/components/navigation/SidebarItem.tsx +1 -3
  298. package/src/lib/components/navigation/utils.ts +11 -16
  299. package/src/lib/core/DevPortalContext.ts +3 -7
  300. package/src/lib/core/plugins.ts +2 -0
  301. package/src/lib/plugins/api-keys/CreateApiKey.tsx +2 -2
  302. package/src/lib/plugins/markdown/index.tsx +49 -12
  303. package/src/lib/plugins/markdown/resolver.ts +92 -0
  304. package/src/lib/plugins/openapi/Endpoint.tsx +2 -2
  305. package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +1 -1
  306. package/src/lib/plugins/openapi/Sidecar.tsx +3 -3
  307. package/src/lib/plugins/openapi/client/worker.ts +2 -2
  308. package/src/lib/plugins/openapi/index.tsx +1 -1
  309. package/src/lib/plugins/openapi/playground/Playground.tsx +3 -3
  310. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +1 -1
  311. package/src/lib/ui/Accordion.tsx +56 -0
  312. package/src/lib/ui/{Note.tsx → Alert.tsx} +11 -10
  313. package/src/lib/ui/AlertDialog.tsx +139 -0
  314. package/src/lib/ui/AspectRatio.tsx +5 -0
  315. package/src/lib/ui/Badge.tsx +36 -0
  316. package/src/lib/ui/Breadcrumb.tsx +115 -0
  317. package/src/lib/ui/Button.tsx +1 -1
  318. package/src/lib/ui/Carousel.tsx +260 -0
  319. package/src/lib/ui/Checkbox.tsx +28 -0
  320. package/src/lib/ui/Collapsible.tsx +9 -0
  321. package/src/lib/{components → ui}/Dialog.tsx +4 -3
  322. package/src/lib/ui/Form.tsx +177 -0
  323. package/src/lib/ui/HoverCard.tsx +27 -0
  324. package/src/lib/ui/Label.tsx +24 -0
  325. package/src/lib/ui/Pagination.tsx +117 -0
  326. package/src/lib/ui/Popover.tsx +29 -0
  327. package/src/lib/ui/Progress.tsx +26 -0
  328. package/src/lib/ui/RadioGroup.tsx +42 -0
  329. package/src/lib/ui/ScrollArea.tsx +46 -0
  330. package/src/lib/ui/Skeleton.tsx +15 -0
  331. package/src/lib/ui/Slider.tsx +26 -0
  332. package/src/lib/ui/Switch.tsx +27 -0
  333. package/src/lib/ui/Textarea.tsx +23 -0
  334. package/src/lib/ui/Toggle.tsx +43 -0
  335. package/src/lib/ui/ToggleGroup.tsx +59 -0
  336. package/src/lib/ui/Tooltip.tsx +28 -0
  337. package/src/lib/util/MdxComponents.tsx +0 -1
  338. package/src/lib/util/useScrollToAnchor.ts +1 -1
  339. package/dist/internal.d.ts +0 -1
  340. package/dist/internal.js +0 -2
  341. package/dist/internal.js.map +0 -1
  342. package/dist/lib/components/Dialog.js.map +0 -1
  343. package/dist/lib/components/Select.js.map +0 -1
  344. package/dist/lib/plugins/markdown/generateRoutes.d.ts +0 -3
  345. package/dist/lib/plugins/markdown/generateRoutes.js +0 -21
  346. package/dist/lib/plugins/markdown/generateRoutes.js.map +0 -1
  347. package/dist/lib/ui/Note.d.ts +0 -8
  348. package/dist/lib/ui/Note.js +0 -23
  349. package/dist/lib/ui/Note.js.map +0 -1
  350. package/lib/Input-CO-1DOZa.js +0 -2229
  351. package/lib/Input-CO-1DOZa.js.map +0 -1
  352. package/lib/Markdown-DM4zv3MA.js.map +0 -1
  353. package/lib/OperationList-Cd3lue0b.js.map +0 -1
  354. package/lib/Spinner-DFQhPMBl.js +0 -505
  355. package/lib/Spinner-DFQhPMBl.js.map +0 -1
  356. package/lib/ZudokuContext-DEoP3GGJ.js.map +0 -1
  357. package/lib/index-Bs9roz8y.js.map +0 -1
  358. package/lib/index-CBr6BM_4.js +0 -2867
  359. package/lib/index-CBr6BM_4.js.map +0 -1
  360. package/lib/index-UUT9q9f9.js +0 -124
  361. package/lib/index-UUT9q9f9.js.map +0 -1
  362. package/lib/joinPath-B7kNnUX4.js +0 -8
  363. package/lib/joinPath-B7kNnUX4.js.map +0 -1
  364. package/lib/urql-core-KJnLL26g.js.map +0 -1
  365. package/lib/utils-G5XSiZc9.js.map +0 -1
  366. package/src/lib/plugins/markdown/generateRoutes.tsx +0 -38
  367. /package/dist/lib/{components → ui}/Dialog.d.ts +0 -0
  368. /package/dist/lib/{components → ui}/Select.d.ts +0 -0
  369. /package/dist/lib/{components → ui}/Select.js +0 -0
  370. /package/src/lib/{components → ui}/Select.tsx +0 -0
package/src/app/main.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { redirect, type RouteObject } from "react-router-dom";
1
+ import { type RouteObject } from "react-router-dom";
2
2
  import { configuredApiKeysPlugin } from "virtual:zudoku-api-keys-plugin";
3
3
  import { configuredApiPlugins } from "virtual:zudoku-api-plugins";
4
4
  import { configuredAuthProvider } from "virtual:zudoku-auth";
@@ -9,11 +9,9 @@ import { configuredSearchPlugin } from "virtual:zudoku-search-plugin";
9
9
  import { configuredSidebar } from "virtual:zudoku-sidebar";
10
10
  import "virtual:zudoku-theme.css";
11
11
  import { DevPortal, Layout, RouterError } from "zudoku/components";
12
- import { isNavigationPlugin } from "zudoku/internal";
13
12
  import type { ZudokuConfig } from "../config/config.js";
14
- import { traverseSidebar } from "../lib/components/navigation/utils.js";
15
13
  import type { ZudokuContextOptions } from "../lib/core/DevPortalContext.js";
16
- import { joinPath } from "../lib/util/joinPath.js";
14
+ import { isNavigationPlugin } from "../lib/core/plugins.js";
17
15
 
18
16
  export const convertZudokuConfigToOptions = (
19
17
  config: ZudokuConfig,
@@ -67,9 +65,7 @@ export const convertZudokuConfigToOptions = (
67
65
  };
68
66
  };
69
67
 
70
- export const getRoutesByConfig = (config: ZudokuConfig): RouteObject[] => {
71
- const options = convertZudokuConfigToOptions(config);
72
-
68
+ export const getRoutesByOptions = (options: ZudokuContextOptions) => {
73
69
  const allPlugins = [
74
70
  ...(options.plugins ? options.plugins : []),
75
71
  ...(options.authentication?.getAuthenticationPlugin
@@ -77,27 +73,8 @@ export const getRoutesByConfig = (config: ZudokuConfig): RouteObject[] => {
77
73
  : []),
78
74
  ];
79
75
 
80
- const topNavRedirects =
81
- options.topNavigation?.flatMap((topNavItem) => {
82
- if (!options.sidebars?.[topNavItem.id]) return [];
83
-
84
- const first =
85
- topNavItem.default ??
86
- traverseSidebar(options.sidebars[topNavItem.id], (item) => {
87
- if (item.type === "doc") return joinPath(topNavItem.id, item.id);
88
- });
89
-
90
- if (!first) return [];
91
-
92
- return {
93
- path: topNavItem.id,
94
- loader: () => redirect(joinPath(first)),
95
- } satisfies RouteObject;
96
- }) ?? [];
97
-
98
76
  const routes = allPlugins
99
77
  .flatMap((plugin) => (isNavigationPlugin(plugin) ? plugin.getRoutes() : []))
100
- .concat(topNavRedirects)
101
78
  .concat({
102
79
  path: "*",
103
80
  loader: () => {
@@ -105,6 +82,13 @@ export const getRoutesByConfig = (config: ZudokuConfig): RouteObject[] => {
105
82
  },
106
83
  });
107
84
 
85
+ return routes;
86
+ };
87
+
88
+ export const getRoutesByConfig = (config: ZudokuConfig): RouteObject[] => {
89
+ const options = convertZudokuConfigToOptions(config);
90
+ const routes = getRoutesByOptions(options);
91
+
108
92
  return [
109
93
  {
110
94
  element: (
@@ -16,7 +16,7 @@ if (!root) {
16
16
  themeToggle();
17
17
 
18
18
  const apiUrl = root.getAttribute("data-api-url");
19
- const pageTitle = document.getElementsByTagName("title")[0].innerText;
19
+ const pageTitle = document.getElementsByTagName("title")[0]!.innerText;
20
20
  const logoUrl = root.getAttribute("data-logo-url");
21
21
 
22
22
  // IMPORTANT: This component must not contain tailwind classes
@@ -70,14 +70,22 @@ export const Header = memo(function HeaderInner() {
70
70
  {page?.logo && (
71
71
  <>
72
72
  <img
73
- src={page.logo.src.light}
73
+ src={
74
+ /https?:\/\//.test(page.logo.src.light)
75
+ ? page.logo.src.light
76
+ : import.meta.env.BASE_URL + page.logo.src.light
77
+ }
74
78
  alt={page.logo.alt ?? page.pageTitle}
75
79
  style={{ width: page.logo.width }}
76
80
  className={cn("h-10", isDark && "hidden")}
77
81
  loading="lazy"
78
82
  />
79
83
  <img
80
- src={page.logo.src.dark}
84
+ src={
85
+ /https?:\/\//.test(page.logo.src.dark)
86
+ ? page.logo.src.dark
87
+ : import.meta.env.BASE_URL + page.logo.src.dark
88
+ }
81
89
  alt={page.logo.alt ?? page.pageTitle}
82
90
  style={{ width: page.logo.width }}
83
91
  className={cn("h-10", !isDark && "hidden")}
@@ -46,6 +46,10 @@ type SyntaxHighlightProps = {
46
46
  language?: string;
47
47
  } & Omit<HighlightProps, "children" | "language">;
48
48
 
49
+ const remapLang = {
50
+ mdx: "md",
51
+ } as Record<string, string>;
52
+
49
53
  export const SyntaxHighlight = ({
50
54
  copyable = true,
51
55
  language = "plain",
@@ -61,7 +65,7 @@ export const SyntaxHighlight = ({
61
65
  return (
62
66
  <Highlight
63
67
  theme={isDark ? themes.vsDark : themes.github}
64
- language={language}
68
+ language={remapLang[language] ?? language}
65
69
  {...props}
66
70
  >
67
71
  {({ className, style, tokens, getLineProps, getTokenProps }) => (
@@ -1,8 +1,11 @@
1
1
  import { cx } from "class-variance-authority";
2
- import { NavLink } from "react-router-dom";
3
-
2
+ import { Suspense } from "react";
3
+ import { Link } from "react-router-dom";
4
4
  import { useAuth } from "../authentication/hook.js";
5
- import { useZudoku } from "./context/ZudokuContext.js";
5
+ import { TopNavigationItem } from "../../config/validators/validate.js";
6
+ import { joinPath } from "../util/joinPath.js";
7
+ import { useCurrentNavigation, useZudoku } from "./context/ZudokuContext.js";
8
+ import { traverseSidebar } from "./navigation/utils.js";
6
9
 
7
10
  export const isHiddenItem =
8
11
  (isAuthenticated?: boolean) =>
@@ -25,26 +28,57 @@ export const TopNavigation = () => {
25
28
  }
26
29
 
27
30
  return (
28
- <nav className="hidden lg:block border-b text-sm px-12 h-[--top-nav-height]">
29
- <ul className="flex flex-row items-center gap-8">
30
- {topNavigation.filter(isHiddenItem(isAuthenticated)).map((item) => (
31
- <li key={item.label}>
32
- <NavLink
33
- className={({ isActive }) =>
34
- cx(
35
- "block py-3.5 font-medium -mb-px border-b-2",
36
- isActive
37
- ? "border-primary text-foreground"
38
- : "border-transparent text-foreground/75 hover:text-foreground hover:border-accent-foreground/25",
39
- )
40
- }
41
- to={item.id}
42
- >
43
- {item.label}
44
- </NavLink>
45
- </li>
46
- ))}
47
- </ul>
48
- </nav>
31
+ <Suspense>
32
+ <nav className="hidden lg:block border-b text-sm px-12 h-[--top-nav-height]">
33
+ <ul className="flex flex-row items-center gap-8">
34
+ {topNavigation.filter(isHiddenItem(isAuthenticated)).map((item) => (
35
+ <li key={item.id}>
36
+ <TopNavItem {...item} />
37
+ </li>
38
+ ))}
39
+ </ul>
40
+ </nav>
41
+ </Suspense>
42
+ );
43
+ };
44
+
45
+ const TopNavItem = ({ id, label, default: defaultLink }: TopNavigationItem) => {
46
+ const { sidebars } = useZudoku();
47
+ const nav = useCurrentNavigation();
48
+ const currentSidebar = sidebars[id];
49
+
50
+ // TODO: This is a bit of a hack to get the first link in the sidebar
51
+ // We should really process this when we load the config so we can validate
52
+ // that the sidebar is actually set. In this case we just fall back to linking
53
+ // to the id if we can't resolve a sidebar.
54
+ const first =
55
+ defaultLink ??
56
+ (currentSidebar
57
+ ? traverseSidebar(currentSidebar, (item) => {
58
+ if (item.type === "doc") return joinPath(item.id);
59
+ })
60
+ : joinPath(id));
61
+
62
+ if (!first) {
63
+ throw new Error(
64
+ `No links found in top navigation for top navigation '${id}'. Check that the sidebar isn't empty or that a default link set.`,
65
+ );
66
+ }
67
+
68
+ // Manually set the active sidebar based on our logic of what is active
69
+ const isActive = nav.data.topNavItem?.id === id;
70
+
71
+ return (
72
+ <Link
73
+ className={cx(
74
+ "block py-3.5 font-medium -mb-px border-b-2",
75
+ isActive
76
+ ? "border-primary text-foreground"
77
+ : "border-transparent text-foreground/75 hover:text-foreground hover:border-accent-foreground/25",
78
+ )}
79
+ to={first}
80
+ >
81
+ {label}
82
+ </Link>
49
83
  );
50
84
  };
@@ -1,7 +1,9 @@
1
1
  import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
2
2
  import { createContext, useContext } from "react";
3
- import { useLocation } from "react-router-dom";
3
+ import { matchPath, useLocation } from "react-router-dom";
4
4
  import { DevPortalContext } from "../../core/DevPortalContext.js";
5
+ import { joinPath } from "../../util/joinPath.js";
6
+ import { traverseSidebar } from "../navigation/utils.js";
5
7
 
6
8
  export const ZudokuReactContext = createContext<DevPortalContext | undefined>(
7
9
  undefined,
@@ -25,34 +27,40 @@ export const useApiIdentities = () => {
25
27
  });
26
28
  };
27
29
 
28
- export const useTopNavigationItem = () => {
29
- const { topNavigation } = useZudoku();
30
+ export const useCurrentNavigation = () => {
31
+ const { getPluginSidebar, sidebars, topNavigation } = useZudoku();
30
32
  const location = useLocation();
31
33
 
32
- const firstPart = location.pathname.split("/").at(1);
33
- if (!firstPart) return;
34
+ const currentSidebarItem = Object.entries(sidebars).find(([, sidebar]) => {
35
+ return traverseSidebar(sidebar, (item) => {
36
+ const itemId =
37
+ item.type === "doc"
38
+ ? joinPath(item.id)
39
+ : item.type === "category" && item.link
40
+ ? joinPath(item.link.id)
41
+ : undefined;
34
42
 
35
- return topNavigation.find((item) => item.id === firstPart);
36
- };
37
-
38
- export const useNavigation = () => {
39
- const { getPluginSidebar, sidebars } = useZudoku();
40
- const navItem = useTopNavigationItem();
41
- const path = navItem?.id;
42
- const currentSidebar = path ? (sidebars[path] ?? []) : [];
43
- const location = useLocation();
43
+ if (itemId === location.pathname) {
44
+ return item;
45
+ }
46
+ });
47
+ });
48
+ const currentTopNavItem =
49
+ topNavigation.find((t) => t.id === currentSidebarItem?.[0]) ??
50
+ topNavigation.find((item) => matchPath(item.id, location.pathname));
44
51
 
45
52
  return useSuspenseQuery({
46
53
  queryFn: async () => {
47
- const pluginSidebar = path
48
- ? await getPluginSidebar(path)
49
- : await getPluginSidebar(location.pathname);
54
+ const pluginSidebar = await getPluginSidebar(location.pathname);
50
55
 
51
56
  return {
52
- items: [...currentSidebar, ...pluginSidebar],
53
- currentTopNavItem: navItem,
57
+ sidebar: [
58
+ ...(currentSidebarItem ? currentSidebarItem[1] : []),
59
+ ...pluginSidebar,
60
+ ],
61
+ topNavItem: currentTopNavItem,
54
62
  };
55
63
  },
56
- queryKey: ["navigation", path],
64
+ queryKey: ["navigation", location.pathname],
57
65
  });
58
66
  };
@@ -2,23 +2,23 @@ import { useRef } from "react";
2
2
 
3
3
  import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
4
4
  import { DrawerContent, DrawerTitle } from "../../ui/Drawer.js";
5
- import { useNavigation } from "../context/ZudokuContext.js";
5
+ import { useCurrentNavigation } from "../context/ZudokuContext.js";
6
6
  import { Slotlet } from "../SlotletProvider.js";
7
7
  import { SidebarItem } from "./SidebarItem.js";
8
8
  import { SidebarWrapper } from "./SidebarWrapper.js";
9
9
 
10
10
  export const Sidebar = () => {
11
11
  const navRef = useRef<HTMLDivElement | null>(null);
12
- const navigation = useNavigation();
12
+ const navigation = useCurrentNavigation();
13
13
 
14
14
  return (
15
15
  <>
16
16
  <SidebarWrapper
17
17
  ref={navRef}
18
- pushMainContent={navigation.data.items.length > 0}
18
+ pushMainContent={navigation.data.sidebar.length > 0}
19
19
  >
20
20
  <Slotlet name="zudoku-before-navigation" />
21
- {navigation.data.items.map((item) => (
21
+ {navigation.data.sidebar.map((item) => (
22
22
  <SidebarItem key={item.label} item={item} />
23
23
  ))}
24
24
  <Slotlet name="zudoku-after-navigation" />
@@ -30,7 +30,7 @@ export const Sidebar = () => {
30
30
  <VisuallyHidden>
31
31
  <DrawerTitle>Sidebar</DrawerTitle>
32
32
  </VisuallyHidden>
33
- {navigation.data.items.map((item) => (
33
+ {navigation.data.sidebar.map((item) => (
34
34
  <SidebarItem key={item.label} item={item} />
35
35
  ))}
36
36
  </DrawerContent>
@@ -5,7 +5,6 @@ import { NavLink, useMatch } from "react-router-dom";
5
5
  import type { SidebarItemCategory } from "../../../config/validators/SidebarSchema.js";
6
6
  import { cn } from "../../util/cn.js";
7
7
  import { joinPath } from "../../util/joinPath.js";
8
- import { useTopNavigationItem } from "../context/ZudokuContext.js";
9
8
  import { navigationListItem, SidebarItem } from "./SidebarItem.js";
10
9
  import { useIsCategoryOpen } from "./utils.js";
11
10
 
@@ -16,7 +15,6 @@ export const SidebarCategory = ({
16
15
  category: SidebarItemCategory;
17
16
  level: number;
18
17
  }) => {
19
- const topNavItem = useTopNavigationItem();
20
18
  const isCategoryOpen = useIsCategoryOpen(category);
21
19
  const [hasInteracted, setHasInteracted] = useState(false);
22
20
 
@@ -26,7 +24,7 @@ export const SidebarCategory = ({
26
24
  !isCollapsible || !isCollapsed || isCategoryOpen,
27
25
  );
28
26
  const [open, setOpen] = useState(isDefaultOpen);
29
- const isActive = useMatch(joinPath(topNavItem?.id, category.link?.id));
27
+ const isActive = useMatch(category.link?.id ?? "");
30
28
 
31
29
  useEffect(() => {
32
30
  // this is triggered when an item from the sidebar is clicked
@@ -87,7 +85,7 @@ export const SidebarCategory = ({
87
85
  )}
88
86
  {category.link?.type === "doc" ? (
89
87
  <NavLink
90
- to={joinPath(topNavItem?.id, category.link.id)}
88
+ to={joinPath(category.link.id)}
91
89
  className="flex-1"
92
90
  onClick={() => {
93
91
  // if it is the current path and closed then open it because there's no path change to trigger the open
@@ -6,7 +6,6 @@ import type { SidebarItem as SidebarItemType } from "../../../config/validators/
6
6
  import { joinPath } from "../../util/joinPath.js";
7
7
  import { AnchorLink } from "../AnchorLink.js";
8
8
  import { useViewportAnchor } from "../context/ViewportAnchorContext.js";
9
- import { useTopNavigationItem } from "../context/ZudokuContext.js";
10
9
  import { SidebarBadge } from "./SidebarBadge.js";
11
10
  import { SidebarCategory } from "./SidebarCategory.js";
12
11
 
@@ -43,7 +42,6 @@ export const SidebarItem = ({
43
42
  basePath?: string;
44
43
  level?: number;
45
44
  }) => {
46
- const topNavItem = useTopNavigationItem();
47
45
  const { activeAnchor } = useViewportAnchor();
48
46
  const [searchParams] = useSearchParams();
49
47
 
@@ -56,7 +54,7 @@ export const SidebarItem = ({
56
54
  className={({ isActive }) =>
57
55
  navigationListItem({ isActive, isTopLevel: level === 0 })
58
56
  }
59
- to={joinPath(topNavItem?.id, item.id)}
57
+ to={joinPath(item.id)}
60
58
  >
61
59
  {item.icon && <item.icon size={16} className="align-[-0.125em]" />}
62
60
  {item.badge ? (
@@ -4,7 +4,7 @@ import type {
4
4
  SidebarItemCategory,
5
5
  } from "../../../config/validators/SidebarSchema.js";
6
6
  import { joinPath } from "../../util/joinPath.js";
7
- import { useTopNavigationItem, useZudoku } from "../context/ZudokuContext.js";
7
+ import { useCurrentNavigation } from "../context/ZudokuContext.js";
8
8
 
9
9
  export type TraverseCallback<T> = (
10
10
  item: SidebarItem,
@@ -42,15 +42,12 @@ export const traverseSidebarItem = <T>(
42
42
 
43
43
  export const useCurrentItem = () => {
44
44
  const location = useLocation();
45
- const topNavItem = useTopNavigationItem();
46
- const { sidebars } = useZudoku();
47
- const currentSidebar = topNavItem?.id ? sidebars[topNavItem.id] : [];
45
+ const nav = useCurrentNavigation();
46
+
47
+ const currentSidebar = nav.data.sidebar;
48
48
 
49
49
  return traverseSidebar(currentSidebar, (item) => {
50
- if (
51
- item.type === "doc" &&
52
- joinPath(topNavItem?.id, item.id) === location.pathname
53
- ) {
50
+ if (item.type === "doc" && joinPath(item.id) === location.pathname) {
54
51
  return item;
55
52
  }
56
53
  });
@@ -58,18 +55,17 @@ export const useCurrentItem = () => {
58
55
 
59
56
  export const useIsCategoryOpen = (category: SidebarItemCategory) => {
60
57
  const location = useLocation();
61
- const topNavItem = useTopNavigationItem();
62
58
 
63
59
  return traverseSidebarItem(category, (item) => {
64
60
  if (item.type === "category" && item.link) {
65
- const categoryLinkPath = joinPath(topNavItem?.id, item.link.id);
61
+ const categoryLinkPath = joinPath(item.link.id);
66
62
  if (categoryLinkPath === location.pathname) {
67
63
  return true;
68
64
  }
69
65
  }
70
66
 
71
67
  if (item.type === "doc") {
72
- const docPath = joinPath(topNavItem?.id, item.id);
68
+ const docPath = joinPath(item.id);
73
69
  if (docPath === location.pathname) {
74
70
  return true;
75
71
  }
@@ -82,9 +78,8 @@ export const usePrevNext = (): {
82
78
  next?: { label: string; id: string };
83
79
  } => {
84
80
  const currentId = useLocation().pathname;
85
- const { sidebars } = useZudoku();
86
- const topNavItem = useTopNavigationItem();
87
- const currentSidebar = topNavItem?.id ? sidebars[topNavItem.id] : [];
81
+ const nav = useCurrentNavigation();
82
+ const currentSidebar = nav.data.sidebar;
88
83
 
89
84
  let prev;
90
85
  let next;
@@ -94,9 +89,9 @@ export const usePrevNext = (): {
94
89
  traverseSidebar(currentSidebar, (item) => {
95
90
  const itemId =
96
91
  item.type === "doc"
97
- ? joinPath(topNavItem?.id, item.id)
92
+ ? joinPath(item.id)
98
93
  : item.type === "category" && item.link
99
- ? joinPath(topNavItem?.id, item.link.id)
94
+ ? joinPath(item.link.id)
100
95
  : undefined;
101
96
 
102
97
  if (!itemId) return;
@@ -1,6 +1,7 @@
1
1
  import { QueryClient } from "@tanstack/react-query";
2
2
  import { ReactNode } from "react";
3
3
  import type { SidebarConfig } from "../../config/validators/SidebarSchema.js";
4
+ import { TopNavigationItem } from "../../config/validators/validate.js";
4
5
  import { type AuthenticationProvider } from "../authentication/authentication.js";
5
6
  import type { ComponentsContextType } from "../components/context/ComponentsContext.js";
6
7
  import { Slotlets } from "../components/SlotletProvider.js";
@@ -60,12 +61,7 @@ export type ZudokuContextOptions = {
60
61
  metadata?: Metadata;
61
62
  page?: Page;
62
63
  authentication?: AuthenticationProvider;
63
- topNavigation?: Array<{
64
- id: string;
65
- label: string;
66
- default?: string;
67
- display?: "auth" | "anon" | "always";
68
- }>;
64
+ topNavigation?: TopNavigationItem[];
69
65
  sidebars?: SidebarConfig;
70
66
  plugins?: DevPortalPlugin[];
71
67
  slotlets?: Slotlets;
@@ -77,7 +73,7 @@ export type ZudokuContextOptions = {
77
73
 
78
74
  export class DevPortalContext {
79
75
  public plugins: NonNullable<ZudokuContextOptions["plugins"]>;
80
- public sidebars: NonNullable<ZudokuContextOptions["sidebars"]>;
76
+ public sidebars: SidebarConfig;
81
77
  public topNavigation: NonNullable<ZudokuContextOptions["topNavigation"]>;
82
78
  public meta: ZudokuContextOptions["metadata"];
83
79
  public page: ZudokuContextOptions["page"];
@@ -11,6 +11,8 @@ export type DevPortalPlugin =
11
11
  | ApiIdentityPlugin
12
12
  | SearchProviderPlugin;
13
13
 
14
+ export type { RouteObject };
15
+
14
16
  export interface NavigationPlugin {
15
17
  getRoutes: () => RouteObject[];
16
18
  getSidebar?: (path: string) => Promise<Sidebar>;
@@ -1,7 +1,6 @@
1
1
  import { useMutation } from "@tanstack/react-query";
2
2
  import { useForm } from "react-hook-form";
3
3
  import { Link, useNavigate } from "react-router-dom";
4
- import { useZudoku } from "../../components/context/ZudokuContext.js";
5
4
  import {
6
5
  Select,
7
6
  SelectContent,
@@ -9,7 +8,8 @@ import {
9
8
  SelectItem,
10
9
  SelectTrigger,
11
10
  SelectValue,
12
- } from "../../components/Select.js";
11
+ } from "zudoku/ui/Select.js";
12
+ import { useZudoku } from "../../components/context/ZudokuContext.js";
13
13
  import { Button } from "../../ui/Button.js";
14
14
  import { Input } from "../../ui/Input.js";
15
15
  import { ApiKeyService } from "./index.js";
@@ -1,13 +1,13 @@
1
1
  import type { Toc } from "@stefanprobst/rehype-extract-toc";
2
2
  import type { MDXProps } from "mdx/types.js";
3
+ import { RouteObject } from "react-router-dom";
4
+ import { ZudokuDocsConfig } from "../../../config/validators/validate.js";
3
5
  import type { DevPortalPlugin } from "../../core/plugins.js";
4
- import { generateRoutes } from "./generateRoutes.js";
6
+ import { DocResolver } from "./resolver.js";
5
7
 
6
- export type MarkdownPluginOptions = {
7
- markdownFiles: Record<string, () => Promise<MDXImport>>;
8
- defaultOptions?: MarkdownPluginDefaultOptions;
9
- filesPath: string;
10
- };
8
+ export interface MarkdownPluginOptions extends ZudokuDocsConfig {
9
+ fileImports: Record<string, () => Promise<MDXImport>>;
10
+ }
11
11
  export type MarkdownPluginDefaultOptions = Pick<
12
12
  Frontmatter,
13
13
  "toc" | "disablePager"
@@ -27,10 +27,47 @@ export type MDXImport = {
27
27
  default: (props: MDXProps) => JSX.Element;
28
28
  };
29
29
 
30
- export const markdownPlugin = ({
31
- markdownFiles,
32
- defaultOptions,
33
- filesPath,
34
- }: MarkdownPluginOptions): DevPortalPlugin => ({
35
- getRoutes: () => generateRoutes(markdownFiles, filesPath, defaultOptions),
30
+ export const markdownPlugin = (
31
+ options: MarkdownPluginOptions[],
32
+ ): DevPortalPlugin => ({
33
+ getRoutes: () => {
34
+ const routeMap = new Map<string, RouteObject>();
35
+ options.forEach(({ fileImports, files, defaultOptions }) =>
36
+ Object.entries(fileImports).flatMap(([file, importPromise]) => {
37
+ const routePath = DocResolver.resolveRoutePath({
38
+ filesGlob: files,
39
+ fsPath: file,
40
+ });
41
+
42
+ if (!routePath) return [];
43
+
44
+ if (routeMap.has(routePath)) {
45
+ // eslint-disable-next-line no-console
46
+ console.warn(
47
+ `Duplicate route path found for ${routePath}. Skipping file at '${file}'.`,
48
+ );
49
+ return [];
50
+ }
51
+
52
+ const route: RouteObject = {
53
+ path: routePath,
54
+ lazy: async () => {
55
+ const { MdxPage } = await import("./MdxPage.js");
56
+ const { default: Component, ...props } = await importPromise();
57
+ return {
58
+ element: (
59
+ <MdxPage
60
+ mdxComponent={Component}
61
+ {...props}
62
+ defaultOptions={defaultOptions}
63
+ />
64
+ ),
65
+ };
66
+ },
67
+ };
68
+ routeMap.set(routePath, route);
69
+ }),
70
+ );
71
+ return [...routeMap.values()];
72
+ },
36
73
  });