zudoku 0.47.1 → 0.48.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.
- package/dist/app/ZuploBuildConfig.d.ts +11 -121
- package/dist/app/ZuploBuildConfig.js +8 -8
- package/dist/app/ZuploBuildConfig.js.map +1 -1
- package/dist/app/demo.js +4 -3
- package/dist/app/demo.js.map +1 -1
- package/dist/app/entry.client.d.ts +0 -2
- package/dist/app/entry.client.js +0 -2
- package/dist/app/entry.client.js.map +1 -1
- package/dist/app/entry.server.d.ts +0 -2
- package/dist/app/entry.server.js +0 -2
- package/dist/app/entry.server.js.map +1 -1
- package/dist/app/env.d.ts +7 -7
- package/dist/app/env.js +8 -0
- package/dist/app/env.js.map +1 -1
- package/dist/app/main.d.ts +1 -0
- package/dist/app/main.js +6 -5
- package/dist/app/main.js.map +1 -1
- package/dist/app/standalone.js +4 -3
- package/dist/app/standalone.js.map +1 -1
- package/dist/config/loader.js +1 -2
- package/dist/config/loader.js.map +1 -1
- package/dist/config/validators/BuildSchema.d.ts +20 -44
- package/dist/config/validators/BuildSchema.js +3 -14
- package/dist/config/validators/BuildSchema.js.map +1 -1
- package/dist/config/validators/InputNavigationSchema.d.ts +7217 -0
- package/dist/config/validators/InputNavigationSchema.js +74 -0
- package/dist/config/validators/InputNavigationSchema.js.map +1 -0
- package/dist/config/validators/InputNavigationSchema.test-d.d.ts +1 -0
- package/dist/config/validators/InputNavigationSchema.test-d.js +146 -0
- package/dist/config/validators/InputNavigationSchema.test-d.js.map +1 -0
- package/dist/config/validators/NavigationSchema.d.ts +44 -0
- package/dist/config/validators/NavigationSchema.js +95 -0
- package/dist/config/validators/NavigationSchema.js.map +1 -0
- package/dist/config/validators/icon-types.d.ts +2 -1
- package/dist/config/validators/icon-types.js +1775 -1
- package/dist/config/validators/icon-types.js.map +1 -1
- package/dist/config/validators/validate.d.ts +451 -5666
- package/dist/config/validators/validate.js +59 -66
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/config/validators/validate.test.js +0 -2
- package/dist/config/validators/validate.test.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/auth/issuer.js +1 -1
- package/dist/lib/auth/issuer.js.map +1 -1
- package/dist/lib/auth/issuer.test.js +1 -1
- package/dist/lib/auth/issuer.test.js.map +1 -1
- package/dist/lib/authentication/components/CallbackHandler.js +1 -1
- package/dist/lib/authentication/components/CallbackHandler.js.map +1 -1
- package/dist/lib/components/BuildCheck.js +1 -1
- package/dist/lib/components/BuildCheck.js.map +1 -1
- package/dist/lib/components/Framed.d.ts +7 -0
- package/dist/lib/components/Framed.js +26 -0
- package/dist/lib/components/Framed.js.map +1 -0
- package/dist/lib/components/Header.js +10 -9
- package/dist/lib/components/Header.js.map +1 -1
- package/dist/lib/components/Heading.d.ts +6 -2
- package/dist/lib/components/Heading.js +2 -2
- package/dist/lib/components/Heading.js.map +1 -1
- package/dist/lib/components/Main.js +4 -4
- package/dist/lib/components/Main.js.map +1 -1
- package/dist/lib/components/MobileTopNavigation.js +6 -5
- package/dist/lib/components/MobileTopNavigation.js.map +1 -1
- package/dist/lib/components/PageProgress.d.ts +1 -0
- package/dist/lib/components/PageProgress.js +20 -0
- package/dist/lib/components/PageProgress.js.map +1 -0
- package/dist/lib/components/TopNavigation.d.ts +2 -3
- package/dist/lib/components/TopNavigation.js +45 -44
- package/dist/lib/components/TopNavigation.js.map +1 -1
- package/dist/lib/components/context/ZudokuContext.d.ts +3 -7
- package/dist/lib/components/context/ZudokuContext.js +44 -26
- package/dist/lib/components/context/ZudokuContext.js.map +1 -1
- package/dist/lib/components/navigation/Navigation.d.ts +5 -0
- package/dist/lib/components/navigation/Navigation.js +12 -0
- package/dist/lib/components/navigation/Navigation.js.map +1 -0
- package/dist/lib/components/navigation/{SidebarBadge.d.ts → NavigationBadge.d.ts} +1 -1
- package/dist/lib/components/navigation/{SidebarBadge.js → NavigationBadge.js} +2 -2
- package/dist/lib/components/navigation/NavigationBadge.js.map +1 -0
- package/dist/lib/components/navigation/NavigationCategory.d.ts +5 -0
- package/dist/lib/components/navigation/{SidebarCategory.js → NavigationCategory.js} +14 -12
- package/dist/lib/components/navigation/NavigationCategory.js.map +1 -0
- package/dist/lib/components/navigation/NavigationItem.d.ts +6 -0
- package/dist/lib/components/navigation/NavigationItem.js +47 -0
- package/dist/lib/components/navigation/NavigationItem.js.map +1 -0
- package/dist/lib/components/navigation/{SidebarWrapper.d.ts → NavigationWrapper.d.ts} +1 -1
- package/dist/lib/components/navigation/{SidebarWrapper.js → NavigationWrapper.js} +3 -3
- package/dist/lib/components/navigation/NavigationWrapper.js.map +1 -0
- package/dist/lib/components/navigation/utils.d.ts +7 -9
- package/dist/lib/components/navigation/utils.js +17 -17
- package/dist/lib/components/navigation/utils.js.map +1 -1
- package/dist/lib/core/ZudokuContext.d.ts +6 -8
- package/dist/lib/core/ZudokuContext.js +5 -7
- package/dist/lib/core/ZudokuContext.js.map +1 -1
- package/dist/lib/core/plugins.d.ts +2 -2
- package/dist/lib/hooks/useEvent.test.js +5 -3
- package/dist/lib/hooks/useEvent.test.js.map +1 -1
- package/dist/lib/plugins/api-catalog/Catalog.d.ts +1 -1
- package/dist/lib/plugins/api-catalog/index.d.ts +6 -6
- package/dist/lib/plugins/api-catalog/index.js +10 -10
- package/dist/lib/plugins/api-catalog/index.js.map +1 -1
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js +6 -6
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -1
- package/dist/lib/plugins/custom-pages/index.d.ts +3 -2
- package/dist/lib/plugins/custom-pages/index.js +15 -8
- package/dist/lib/plugins/custom-pages/index.js.map +1 -1
- package/dist/lib/plugins/markdown/MdxPage.js +6 -3
- package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
- package/dist/lib/plugins/markdown/index.d.ts +2 -1
- package/dist/lib/plugins/markdown/index.js +9 -26
- package/dist/lib/plugins/markdown/index.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.js +1 -1
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/SchemaList.js +1 -1
- package/dist/lib/plugins/openapi/SchemaList.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.d.ts +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.js +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/graphql.d.ts +3 -3
- package/dist/lib/plugins/openapi/graphql/graphql.js +2 -2
- package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
- package/dist/lib/plugins/openapi/index.d.ts +3 -3
- package/dist/lib/plugins/openapi/index.js +9 -9
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/interfaces.d.ts +3 -3
- package/dist/lib/plugins/openapi/schema/SchemaView.js +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
- package/dist/lib/plugins/openapi/util/createNavigationCategory.d.ts +9 -0
- package/dist/lib/plugins/openapi/util/{createSidebarCategory.js → createNavigationCategory.js} +5 -4
- package/dist/lib/plugins/openapi/util/createNavigationCategory.js.map +1 -0
- package/dist/lib/plugins/openapi/util/getRoutes.js +2 -2
- package/dist/lib/plugins/openapi/util/getRoutes.js.map +1 -1
- package/dist/lib/plugins/openapi/util/methodColorMap.d.ts +1 -1
- package/dist/lib/ui/CodeBlock.js +1 -1
- package/dist/lib/ui/CodeBlock.js.map +1 -1
- package/dist/lib/util/MdxComponents.d.ts +6 -0
- package/dist/lib/util/MdxComponents.js +4 -2
- package/dist/lib/util/MdxComponents.js.map +1 -1
- package/dist/lib/util/useScrollToAnchor.js +3 -3
- package/dist/lib/util/useScrollToAnchor.js.map +1 -1
- package/dist/vite/api/SchemaManager.d.ts +4 -4
- package/dist/vite/api/SchemaManager.js +19 -19
- package/dist/vite/api/SchemaManager.js.map +1 -1
- package/dist/vite/api/SchemaManager.test.js +4 -4
- package/dist/vite/api/SchemaManager.test.js.map +1 -1
- package/dist/vite/config.js +1 -0
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/css/plugin.js +11 -0
- package/dist/vite/css/plugin.js.map +1 -1
- package/dist/vite/plugin-api.js +8 -8
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/plugin-config-reload.js +2 -0
- package/dist/vite/plugin-config-reload.js.map +1 -1
- package/dist/vite/plugin-custom-pages.js +2 -2
- package/dist/vite/plugin-custom-pages.js.map +1 -1
- package/dist/vite/plugin-docs.js +61 -59
- package/dist/vite/plugin-docs.js.map +1 -1
- package/dist/vite/plugin-mdx.js +4 -2
- package/dist/vite/plugin-mdx.js.map +1 -1
- package/dist/vite/{plugin-sidebar.d.ts → plugin-navigation.d.ts} +1 -1
- package/dist/vite/{plugin-sidebar.js → plugin-navigation.js} +20 -19
- package/dist/vite/plugin-navigation.js.map +1 -0
- package/dist/vite/plugin-theme.d.ts +8 -0
- package/dist/vite/plugin-theme.js +223 -0
- package/dist/vite/plugin-theme.js.map +1 -0
- package/dist/vite/plugin-theme.test.d.ts +1 -0
- package/dist/vite/plugin-theme.test.js +270 -0
- package/dist/vite/plugin-theme.test.js.map +1 -0
- package/dist/vite/plugin.js +4 -6
- package/dist/vite/plugin.js.map +1 -1
- package/dist/vite/shadcn-registry.d.ts +45 -0
- package/dist/vite/shadcn-registry.js +29 -0
- package/dist/vite/shadcn-registry.js.map +1 -0
- package/lib/Drawer-BzkOKwgC.js.map +1 -1
- package/lib/{Markdown-r4buN85T.js → Markdown-DCAIYXF5.js} +885 -840
- package/lib/Markdown-DCAIYXF5.js.map +1 -0
- package/lib/{MdxPage-DYKsTerz.js → MdxPage-Cf9YXWoC.js} +30 -30
- package/lib/MdxPage-Cf9YXWoC.js.map +1 -0
- package/lib/OasProvider-JMVTfG6_.js +35 -0
- package/lib/OasProvider-JMVTfG6_.js.map +1 -0
- package/lib/{OperationList-BCVHtZNK.js → OperationList-m4tFCI4S.js} +8 -8
- package/lib/{OperationList-BCVHtZNK.js.map → OperationList-m4tFCI4S.js.map} +1 -1
- package/lib/{RouteGuard-B7GVW4oL.js → RouteGuard-gV7nvzi7.js} +2 -2
- package/lib/{RouteGuard-B7GVW4oL.js.map → RouteGuard-gV7nvzi7.js.map} +1 -1
- package/lib/{SchemaList-1oJKvBxh.js → SchemaList-_wRy4aQ0.js} +20 -20
- package/lib/SchemaList-_wRy4aQ0.js.map +1 -0
- package/lib/{SchemaView-CTqaB-79.js → SchemaView-CRl_cQYH.js} +13 -13
- package/lib/{SchemaView-CTqaB-79.js.map → SchemaView-CRl_cQYH.js.map} +1 -1
- package/lib/{SignUp-CRIKdWt9.js → SignUp-B6w5AwHM.js} +2 -2
- package/lib/{SignUp-CRIKdWt9.js.map → SignUp-B6w5AwHM.js.map} +1 -1
- package/lib/{Slot-B5qSAnwR.js → Slot-BkYrj_uC.js} +4 -4
- package/lib/{Slot-B5qSAnwR.js.map → Slot-BkYrj_uC.js.map} +1 -1
- package/lib/{SyntaxHighlight-CqKHkyEy.js → SyntaxHighlight-CH9OUJre.js} +2 -2
- package/lib/{SyntaxHighlight-CqKHkyEy.js.map → SyntaxHighlight-CH9OUJre.js.map} +1 -1
- package/lib/{Toc-lxYQEOzX.js → Toc-DRxqEsFc.js} +2 -2
- package/lib/{Toc-lxYQEOzX.js.map → Toc-DRxqEsFc.js.map} +1 -1
- package/lib/{circular-ZGGPtwMq.js → circular-wJaV4vh_.js} +2 -2
- package/lib/{circular-ZGGPtwMq.js.map → circular-wJaV4vh_.js.map} +1 -1
- package/lib/clerk-yAKDC3Qz.js.map +1 -1
- package/lib/{createServer-DUBpXfvA.js → createServer-DN5AJLcN.js} +3 -3
- package/lib/{createServer-DUBpXfvA.js.map → createServer-DN5AJLcN.js.map} +1 -1
- package/lib/{errors-D27ZTQgx.js → errors-D_5vKvUq.js} +10 -10
- package/lib/{errors-D27ZTQgx.js.map → errors-D_5vKvUq.js.map} +1 -1
- package/lib/hook-CHXroBFt.js +1503 -0
- package/lib/hook-CHXroBFt.js.map +1 -0
- package/lib/index-CrcNWbel.js.map +1 -1
- package/lib/{index-Cucjfk3D.js → index-DJVaRmzI.js} +63 -62
- package/lib/index-DJVaRmzI.js.map +1 -0
- package/lib/index-QzXzw_ra.js.map +1 -1
- package/lib/{mutation-C1XCQTQL.js → mutation-BpcyTgWI.js} +2 -2
- package/lib/{mutation-C1XCQTQL.js.map → mutation-BpcyTgWI.js.map} +1 -1
- package/lib/ui/CodeBlock.js +7 -7
- package/lib/ui/CodeBlock.js.map +1 -1
- package/lib/ui/SyntaxHighlight.js +2 -2
- package/lib/{useMutation-BKvPttRn.js → useMutation-N4ockVKi.js} +3 -3
- package/lib/{useMutation-BKvPttRn.js.map → useMutation-N4ockVKi.js.map} +1 -1
- package/lib/zudoku.auth-auth0.js +1 -1
- package/lib/zudoku.auth-azureb2c.js +2 -2
- package/lib/zudoku.auth-clerk.js +2 -2
- package/lib/zudoku.auth-openid.js +2 -2
- package/lib/zudoku.components.js +2756 -3423
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.hooks.js +2 -2
- package/lib/zudoku.plugin-api-catalog.js +44 -44
- package/lib/zudoku.plugin-api-catalog.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +84 -73
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-custom-pages.js +22 -16
- package/lib/zudoku.plugin-custom-pages.js.map +1 -1
- package/lib/zudoku.plugin-markdown.js +20 -69
- package/lib/zudoku.plugin-markdown.js.map +1 -1
- package/lib/zudoku.plugin-openapi.js +5 -5
- package/lib/zudoku.plugin-search-pagefind.js +2 -2
- package/lib/zudoku.plugins.js.map +1 -1
- package/package.json +16 -13
- package/src/app/ZuploBuildConfig.ts +8 -8
- package/src/app/defaultTheme.css +68 -49
- package/src/app/demo.tsx +4 -3
- package/src/app/entry.client.tsx +0 -2
- package/src/app/entry.server.tsx +0 -2
- package/src/app/env.ts +8 -0
- package/src/app/main.css +6 -52
- package/src/app/main.tsx +7 -5
- package/src/app/standalone.tsx +4 -3
- package/src/lib/auth/issuer.test.ts +1 -1
- package/src/lib/auth/issuer.ts +1 -1
- package/src/lib/authentication/components/CallbackHandler.tsx +1 -1
- package/src/lib/components/BuildCheck.tsx +1 -1
- package/src/lib/components/Framed.tsx +51 -0
- package/src/lib/components/Header.tsx +5 -3
- package/src/lib/components/Heading.tsx +7 -3
- package/src/lib/components/Main.tsx +8 -8
- package/src/lib/components/MobileTopNavigation.tsx +16 -11
- package/src/lib/components/PageProgress.tsx +28 -0
- package/src/lib/components/TopNavigation.tsx +57 -66
- package/src/lib/components/context/ZudokuContext.ts +50 -32
- package/src/lib/components/navigation/{Sidebar.tsx → Navigation.tsx} +18 -16
- package/src/lib/components/navigation/{SidebarBadge.tsx → NavigationBadge.tsx} +1 -1
- package/src/lib/components/navigation/{SidebarCategory.tsx → NavigationCategory.tsx} +16 -14
- package/src/lib/components/navigation/{SidebarItem.tsx → NavigationItem.tsx} +23 -17
- package/src/lib/components/navigation/{SidebarWrapper.tsx → NavigationWrapper.tsx} +2 -2
- package/src/lib/components/navigation/utils.ts +27 -28
- package/src/lib/core/ZudokuContext.ts +9 -15
- package/src/lib/core/plugins.ts +2 -2
- package/src/lib/hooks/useEvent.test.tsx +7 -5
- package/src/lib/plugins/api-catalog/Catalog.tsx +1 -1
- package/src/lib/plugins/api-catalog/index.tsx +19 -19
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +14 -10
- package/src/lib/plugins/custom-pages/index.tsx +20 -11
- package/src/lib/plugins/markdown/MdxPage.tsx +6 -3
- package/src/lib/plugins/markdown/index.tsx +19 -40
- package/src/lib/plugins/openapi/OperationList.tsx +1 -1
- package/src/lib/plugins/openapi/OperationListItem.tsx +1 -1
- package/src/lib/plugins/openapi/SchemaList.tsx +2 -2
- package/src/lib/plugins/openapi/graphql/gql.ts +5 -5
- package/src/lib/plugins/openapi/graphql/graphql.ts +6 -6
- package/src/lib/plugins/openapi/index.tsx +11 -11
- package/src/lib/plugins/openapi/interfaces.ts +3 -3
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +1 -1
- package/src/lib/plugins/openapi/util/{createSidebarCategory.tsx → createNavigationCategory.tsx} +6 -5
- package/src/lib/plugins/openapi/util/getRoutes.tsx +2 -2
- package/src/lib/plugins/openapi/util/methodColorMap.tsx +1 -1
- package/src/lib/ui/CodeBlock.tsx +1 -1
- package/src/lib/util/MdxComponents.tsx +13 -2
- package/src/lib/util/useScrollToAnchor.ts +3 -3
- package/dist/config/validators/InputSidebarSchema.d.ts +0 -220
- package/dist/config/validators/InputSidebarSchema.js +0 -63
- package/dist/config/validators/InputSidebarSchema.js.map +0 -1
- package/dist/config/validators/SidebarSchema.d.ts +0 -46
- package/dist/config/validators/SidebarSchema.js +0 -118
- package/dist/config/validators/SidebarSchema.js.map +0 -1
- package/dist/lib/components/navigation/Sidebar.d.ts +0 -5
- package/dist/lib/components/navigation/Sidebar.js +0 -10
- package/dist/lib/components/navigation/Sidebar.js.map +0 -1
- package/dist/lib/components/navigation/SidebarBadge.js.map +0 -1
- package/dist/lib/components/navigation/SidebarCategory.d.ts +0 -5
- package/dist/lib/components/navigation/SidebarCategory.js.map +0 -1
- package/dist/lib/components/navigation/SidebarItem.d.ts +0 -6
- package/dist/lib/components/navigation/SidebarItem.js +0 -44
- package/dist/lib/components/navigation/SidebarItem.js.map +0 -1
- package/dist/lib/components/navigation/SidebarWrapper.js.map +0 -1
- package/dist/lib/plugins/markdown/resolver.d.ts +0 -32
- package/dist/lib/plugins/markdown/resolver.js +0 -46
- package/dist/lib/plugins/markdown/resolver.js.map +0 -1
- package/dist/lib/plugins/openapi/util/createSidebarCategory.d.ts +0 -9
- package/dist/lib/plugins/openapi/util/createSidebarCategory.js.map +0 -1
- package/dist/vite/plugin-configure-tailwind.d.ts +0 -2
- package/dist/vite/plugin-configure-tailwind.js +0 -38
- package/dist/vite/plugin-configure-tailwind.js.map +0 -1
- package/dist/vite/plugin-sidebar.js.map +0 -1
- package/dist/vite/plugin-theme-css.d.ts +0 -5
- package/dist/vite/plugin-theme-css.js +0 -77
- package/dist/vite/plugin-theme-css.js.map +0 -1
- package/lib/Markdown-r4buN85T.js.map +0 -1
- package/lib/MdxPage-DYKsTerz.js.map +0 -1
- package/lib/OasProvider-8vNiLpIG.js +0 -33
- package/lib/OasProvider-8vNiLpIG.js.map +0 -1
- package/lib/SchemaList-1oJKvBxh.js.map +0 -1
- package/lib/hook-7wZANGJP.js +0 -1483
- package/lib/hook-7wZANGJP.js.map +0 -1
- package/lib/index-Cucjfk3D.js.map +0 -1
- package/lib/joinPath-B7kNnUX4.js +0 -8
- package/lib/joinPath-B7kNnUX4.js.map +0 -1
- package/src/lib/plugins/markdown/resolver.ts +0 -59
|
@@ -4,13 +4,13 @@ import { useNavigation } from "react-router";
|
|
|
4
4
|
import { Drawer, DrawerTrigger } from "zudoku/ui/Drawer.js";
|
|
5
5
|
import { cn } from "../util/cn.js";
|
|
6
6
|
import { useCurrentNavigation, useZudoku } from "./context/ZudokuContext.js";
|
|
7
|
-
import {
|
|
7
|
+
import { Navigation } from "./navigation/Navigation.js";
|
|
8
8
|
import { Slot } from "./Slot.js";
|
|
9
9
|
|
|
10
10
|
export const Main = ({ children }: PropsWithChildren) => {
|
|
11
11
|
const [isDrawerOpen, setDrawerOpen] = useState(false);
|
|
12
|
-
const {
|
|
13
|
-
const
|
|
12
|
+
const { navigation } = useCurrentNavigation();
|
|
13
|
+
const hasNavigation = navigation.length > 0;
|
|
14
14
|
const isNavigating = useNavigation().state === "loading";
|
|
15
15
|
const { options } = useZudoku();
|
|
16
16
|
|
|
@@ -20,13 +20,13 @@ export const Main = ({ children }: PropsWithChildren) => {
|
|
|
20
20
|
open={isDrawerOpen}
|
|
21
21
|
onOpenChange={(open) => setDrawerOpen(open)}
|
|
22
22
|
>
|
|
23
|
-
{
|
|
24
|
-
<
|
|
23
|
+
{hasNavigation && (
|
|
24
|
+
<Navigation
|
|
25
25
|
onRequestClose={() => setDrawerOpen(false)}
|
|
26
|
-
|
|
26
|
+
navigation={navigation}
|
|
27
27
|
/>
|
|
28
28
|
)}
|
|
29
|
-
{
|
|
29
|
+
{hasNavigation && (
|
|
30
30
|
<div className="lg:hidden -mx-4 px-4 py-2 sticky bg-background/80 backdrop-blur-xs z-10 top-0 start-0 end-0 border-b">
|
|
31
31
|
<DrawerTrigger className="flex items-center gap-2 px-4">
|
|
32
32
|
<PanelLeftIcon size={16} strokeWidth={1.5} />
|
|
@@ -38,7 +38,7 @@ export const Main = ({ children }: PropsWithChildren) => {
|
|
|
38
38
|
data-pagefind-body
|
|
39
39
|
className={cn(
|
|
40
40
|
"px-4 lg:pe-8 lg:px-8",
|
|
41
|
-
!
|
|
41
|
+
!hasNavigation && "col-span-full",
|
|
42
42
|
isNavigating && "animate-pulse",
|
|
43
43
|
)}
|
|
44
44
|
>
|
|
@@ -11,15 +11,19 @@ import {
|
|
|
11
11
|
import { useZudoku } from "./context/ZudokuContext.js";
|
|
12
12
|
import { PoweredByZudoku } from "./navigation/PoweredByZudoku.js";
|
|
13
13
|
import { isHiddenItem } from "./navigation/utils.js";
|
|
14
|
+
import { PageProgress } from "./PageProgress.js";
|
|
14
15
|
import { Search } from "./Search.js";
|
|
16
|
+
import { Slot } from "./Slot.js";
|
|
15
17
|
import { ThemeSwitch } from "./ThemeSwitch.js";
|
|
16
|
-
import {
|
|
18
|
+
import { TopNavItem } from "./TopNavigation.js";
|
|
17
19
|
|
|
18
20
|
export const MobileTopNavigation = () => {
|
|
19
|
-
const {
|
|
21
|
+
const { navigation, options } = useZudoku();
|
|
20
22
|
const { isAuthenticated } = useAuth();
|
|
21
23
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
22
24
|
|
|
25
|
+
const filteredItems = navigation.filter(isHiddenItem(isAuthenticated));
|
|
26
|
+
|
|
23
27
|
return (
|
|
24
28
|
<Drawer
|
|
25
29
|
direction={options.page?.dir === "rtl" ? "left" : "right"}
|
|
@@ -43,18 +47,19 @@ export const MobileTopNavigation = () => {
|
|
|
43
47
|
</VisuallyHidden>
|
|
44
48
|
<Search className="flex p-4" />
|
|
45
49
|
<ul className="flex flex-col items-center gap-4 p-4">
|
|
50
|
+
<li className="empty:hidden">
|
|
51
|
+
<Slot.Target name="top-navigation-side" />
|
|
52
|
+
</li>
|
|
46
53
|
<li>
|
|
47
54
|
<ThemeSwitch />
|
|
48
55
|
</li>
|
|
49
|
-
{
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</li>
|
|
57
|
-
))}
|
|
56
|
+
{filteredItems.map((item) => (
|
|
57
|
+
<li key={item.label}>
|
|
58
|
+
<button type="button" onClick={() => setDrawerOpen(false)}>
|
|
59
|
+
<TopNavItem {...item} />
|
|
60
|
+
</button>
|
|
61
|
+
</li>
|
|
62
|
+
))}
|
|
58
63
|
</ul>
|
|
59
64
|
</div>
|
|
60
65
|
{options.page?.showPoweredBy !== false && (
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useNProgress } from "@tanem/react-nprogress";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useNavigation } from "react-router";
|
|
4
|
+
|
|
5
|
+
export const PageProgress = () => {
|
|
6
|
+
const navigation = useNavigation();
|
|
7
|
+
const isNavigating = navigation.state === "loading";
|
|
8
|
+
// delay the animation to avoid flickering
|
|
9
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const timer = setTimeout(() => setIsAnimating(isNavigating), 200);
|
|
13
|
+
|
|
14
|
+
return () => clearTimeout(timer);
|
|
15
|
+
}, [isNavigating]);
|
|
16
|
+
|
|
17
|
+
const { isFinished, progress } = useNProgress({ isAnimating });
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
className="absolute w-0 left-0 right-0 bottom-[-1px] h-[2px] bg-primary transition-all duration-300 ease-in-out"
|
|
22
|
+
style={{
|
|
23
|
+
opacity: isFinished ? 0 : 1,
|
|
24
|
+
width: isFinished ? 0 : `${progress * 100}%`,
|
|
25
|
+
}}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -1,44 +1,19 @@
|
|
|
1
|
-
import { useNProgress } from "@tanem/react-nprogress";
|
|
2
1
|
import { cx } from "class-variance-authority";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
2
|
+
import { deepEqual } from "fast-equals";
|
|
3
|
+
import { Suspense } from "react";
|
|
4
|
+
import { NavLink } from "react-router";
|
|
5
|
+
import { type NavigationItem } from "../../config/validators/NavigationSchema.js";
|
|
6
6
|
import { useAuth } from "../authentication/hook.js";
|
|
7
7
|
import { joinUrl } from "../util/joinUrl.js";
|
|
8
8
|
import { useCurrentNavigation, useZudoku } from "./context/ZudokuContext.js";
|
|
9
|
-
import { isHiddenItem,
|
|
9
|
+
import { isHiddenItem, traverseNavigationItem } from "./navigation/utils.js";
|
|
10
10
|
import { Slot } from "./Slot.js";
|
|
11
11
|
|
|
12
|
-
export const PageProgress = () => {
|
|
13
|
-
const navigation = useNavigation();
|
|
14
|
-
const isNavigating = navigation.state === "loading";
|
|
15
|
-
// delay the animation to avoid flickering
|
|
16
|
-
const [isAnimating, setIsAnimating] = useState(false);
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
const timer = setTimeout(() => setIsAnimating(isNavigating), 100);
|
|
20
|
-
|
|
21
|
-
return () => clearTimeout(timer);
|
|
22
|
-
}, [isNavigating]);
|
|
23
|
-
|
|
24
|
-
const { isFinished, progress } = useNProgress({ isAnimating });
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<div
|
|
28
|
-
className="absolute w-0 left-0 right-0 bottom-[-1px] h-[2px] bg-primary transition-all duration-300 ease-in-out"
|
|
29
|
-
style={{
|
|
30
|
-
opacity: isFinished ? 0 : 1,
|
|
31
|
-
width: isFinished ? 0 : `${progress * 100}%`,
|
|
32
|
-
}}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
12
|
export const TopNavigation = () => {
|
|
38
|
-
const {
|
|
13
|
+
const { navigation } = useZudoku();
|
|
39
14
|
const { isAuthenticated } = useAuth();
|
|
40
15
|
|
|
41
|
-
const filteredItems =
|
|
16
|
+
const filteredItems = navigation.filter(isHiddenItem(isAuthenticated));
|
|
42
17
|
|
|
43
18
|
if (filteredItems.length === 0 || import.meta.env.MODE === "standalone") {
|
|
44
19
|
return <style>{`:root { --top-nav-height: 0px; }`}</style>;
|
|
@@ -50,7 +25,7 @@ export const TopNavigation = () => {
|
|
|
50
25
|
<nav className="text-sm">
|
|
51
26
|
<ul className="flex flex-row items-center gap-8">
|
|
52
27
|
{filteredItems.map((item) => (
|
|
53
|
-
<li key={item.
|
|
28
|
+
<li key={item.label + item.type}>
|
|
54
29
|
<TopNavItem {...item} />
|
|
55
30
|
</li>
|
|
56
31
|
))}
|
|
@@ -58,50 +33,66 @@ export const TopNavigation = () => {
|
|
|
58
33
|
</nav>
|
|
59
34
|
<Slot.Target name="top-navigation-side" />
|
|
60
35
|
</div>
|
|
61
|
-
<PageProgress />
|
|
36
|
+
{/* <PageProgress /> */}
|
|
62
37
|
</Suspense>
|
|
63
38
|
);
|
|
64
39
|
};
|
|
65
40
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
41
|
+
const getPathForItem = (item: NavigationItem): string => {
|
|
42
|
+
switch (item.type) {
|
|
43
|
+
case "doc":
|
|
44
|
+
return joinUrl(item.path);
|
|
45
|
+
case "link":
|
|
46
|
+
return item.to;
|
|
47
|
+
case "category": {
|
|
48
|
+
if (item.link?.path) {
|
|
49
|
+
return joinUrl(item.link.path);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
traverseNavigationItem(item, (child) => {
|
|
54
|
+
if (child.type !== "category") {
|
|
55
|
+
return getPathForItem(child);
|
|
56
|
+
}
|
|
57
|
+
}) ?? ""
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
case "custom-page":
|
|
61
|
+
return item.path;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const TopNavItem = (item: NavigationItem) => {
|
|
73
66
|
const currentNav = useCurrentNavigation();
|
|
74
|
-
const
|
|
75
|
-
const isActive = currentNav.topNavItem?.id === id && !isNavigating;
|
|
67
|
+
const isActiveTopNavItem = deepEqual(currentNav.topNavItem, item);
|
|
76
68
|
|
|
77
|
-
|
|
78
|
-
// We should really process this when we load the config so we can validate
|
|
79
|
-
// that the sidebar is actually set. In this case we just fall back to linking
|
|
80
|
-
// to the id if we can't resolve a sidebar.
|
|
81
|
-
const first =
|
|
82
|
-
defaultLink ??
|
|
83
|
-
(currentSidebar
|
|
84
|
-
? traverseSidebar(currentSidebar, (item) => {
|
|
85
|
-
if (item.type === "doc") return joinUrl(item.id);
|
|
86
|
-
})
|
|
87
|
-
: joinUrl(id)) ??
|
|
88
|
-
joinUrl(id);
|
|
69
|
+
const path = getPathForItem(item);
|
|
89
70
|
|
|
90
71
|
return (
|
|
91
|
-
// We don't use isActive here because it has to be inside the
|
|
92
|
-
// the top nav id doesn't necessarily start with the
|
|
72
|
+
// We don't use isActive here because it has to be inside the navigation,
|
|
73
|
+
// the top nav id doesn't necessarily start with the navigation id
|
|
93
74
|
<NavLink
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
75
|
+
viewTransition
|
|
76
|
+
to={path}
|
|
77
|
+
className={({ isActive: isActiveNavLink, isPending }) => {
|
|
78
|
+
const isActive = isActiveNavLink || isActiveTopNavItem;
|
|
79
|
+
return cx(
|
|
80
|
+
"flex items-center gap-2 lg:py-3.5 font-medium -mb-px transition duration-150 delay-75 relative",
|
|
97
81
|
isActive || isPending
|
|
98
|
-
?
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
? [
|
|
83
|
+
"text-foreground",
|
|
84
|
+
// underline with view transition animation
|
|
85
|
+
"after:content-[''] after:absolute after:bottom-0 after:left-0 after:right-0",
|
|
86
|
+
"after:h-0.5 after:bg-primary",
|
|
87
|
+
isActive && "after:[view-transition-name:top-nav-underline]",
|
|
88
|
+
isPending && "after:bg-primary/25",
|
|
89
|
+
]
|
|
90
|
+
: "text-foreground/75 hover:text-foreground",
|
|
91
|
+
);
|
|
92
|
+
}}
|
|
103
93
|
>
|
|
104
|
-
{
|
|
94
|
+
{item.icon && <item.icon size={16} className="align-[-0.125em]" />}
|
|
95
|
+
{item.label}
|
|
105
96
|
</NavLink>
|
|
106
97
|
);
|
|
107
98
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
import { matchPath, useLocation } from "react-router";
|
|
4
|
+
import { type NavigationItem } from "../../../config/validators/NavigationSchema.js";
|
|
4
5
|
import { useAuth } from "../../authentication/hook.js";
|
|
5
6
|
import type { ZudokuContext } from "../../core/ZudokuContext.js";
|
|
6
7
|
import { joinUrl } from "../../util/joinUrl.js";
|
|
7
8
|
import { CACHE_KEYS } from "../cache.js";
|
|
8
|
-
import {
|
|
9
|
+
import { traverseNavigation } from "../navigation/utils.js";
|
|
9
10
|
|
|
10
11
|
export const ZudokuReactContext = createContext<ZudokuContext | undefined>(
|
|
11
12
|
undefined,
|
|
@@ -30,8 +31,22 @@ export const useApiIdentities = () => {
|
|
|
30
31
|
});
|
|
31
32
|
};
|
|
32
33
|
|
|
34
|
+
const getItemPath = (item: NavigationItem) => {
|
|
35
|
+
switch (item.type) {
|
|
36
|
+
case "doc":
|
|
37
|
+
return joinUrl(item.path);
|
|
38
|
+
case "category":
|
|
39
|
+
return item.link ? joinUrl(item.link.path) : undefined;
|
|
40
|
+
case "link":
|
|
41
|
+
return item.to;
|
|
42
|
+
case "custom-page":
|
|
43
|
+
return item.path;
|
|
44
|
+
default:
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
33
48
|
export const useCurrentNavigation = () => {
|
|
34
|
-
const {
|
|
49
|
+
const { getPluginNavigation, navigation, options } = useZudoku();
|
|
35
50
|
const location = useLocation();
|
|
36
51
|
const auth = useAuth();
|
|
37
52
|
|
|
@@ -39,44 +54,47 @@ export const useCurrentNavigation = () => {
|
|
|
39
54
|
matchPath(route, location.pathname),
|
|
40
55
|
);
|
|
41
56
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
? joinUrl(item.id)
|
|
47
|
-
: item.type === "category" && item.link
|
|
48
|
-
? joinUrl(item.link.id)
|
|
49
|
-
: undefined;
|
|
50
|
-
|
|
51
|
-
if (itemId === location.pathname) {
|
|
52
|
-
return item;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
57
|
+
const navItem = traverseNavigation(navigation, (item, parentCategories) => {
|
|
58
|
+
if (getItemPath(item) === location.pathname) {
|
|
59
|
+
return parentCategories.at(0) ?? item;
|
|
60
|
+
}
|
|
55
61
|
});
|
|
56
|
-
const currentTopNavItem =
|
|
57
|
-
topNavigation.find((t) => t.id === currentSidebarItem?.[0]) ??
|
|
58
|
-
topNavigation.find((item) => matchPath(item.id, location.pathname));
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
currentTopNavItem &&
|
|
62
|
-
!currentSidebarItem &&
|
|
63
|
-
currentTopNavItem.id in sidebars
|
|
64
|
-
) {
|
|
65
|
-
currentSidebarItem = ["", sidebars[currentTopNavItem.id]!];
|
|
66
|
-
}
|
|
67
62
|
|
|
68
63
|
const { data } = useSuspenseQuery({
|
|
69
|
-
queryFn: () =>
|
|
70
|
-
queryKey: ["plugin-
|
|
64
|
+
queryFn: () => getPluginNavigation(location.pathname),
|
|
65
|
+
queryKey: ["plugin-navigation", location.pathname],
|
|
71
66
|
});
|
|
72
67
|
|
|
73
|
-
|
|
68
|
+
let topNavItem = navItem;
|
|
69
|
+
if (!navItem && data.length > 0) {
|
|
70
|
+
// Extract base paths from plugin navigation items
|
|
71
|
+
const pluginBasePaths = data.flatMap((item) => {
|
|
72
|
+
return getItemPath(item)?.split("?").at(0)?.split("#").at(0) ?? [];
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Find top-level nav item that matches any plugin base path
|
|
76
|
+
topNavItem = navigation
|
|
77
|
+
.flatMap((item) => {
|
|
78
|
+
const itemPath = getItemPath(item);
|
|
79
|
+
return itemPath ? [{ item, path: itemPath }] : [];
|
|
80
|
+
})
|
|
81
|
+
.sort((a, b) => b.path.length - a.path.length)
|
|
82
|
+
.find(({ path }) => {
|
|
83
|
+
return pluginBasePaths.some(
|
|
84
|
+
(basePath) =>
|
|
85
|
+
matchPath({ path, end: false }, basePath) ??
|
|
86
|
+
matchPath({ path: basePath, end: false }, path),
|
|
87
|
+
);
|
|
88
|
+
})?.item;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const hasNavigation =
|
|
74
92
|
auth.isAuthEnabled && !auth.isAuthenticated && isProtectedRoute;
|
|
75
93
|
|
|
76
94
|
return {
|
|
77
|
-
|
|
95
|
+
navigation: hasNavigation
|
|
78
96
|
? []
|
|
79
|
-
: [...(
|
|
80
|
-
topNavItem
|
|
97
|
+
: [...(navItem?.type === "category" ? navItem.items : []), ...data],
|
|
98
|
+
topNavItem,
|
|
81
99
|
};
|
|
82
100
|
};
|
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
|
2
|
-
import type {
|
|
2
|
+
import type { NavigationItem as NavigationItemType } from "../../../config/validators/NavigationSchema.js";
|
|
3
3
|
import { DrawerContent, DrawerTitle } from "../../ui/Drawer.js";
|
|
4
4
|
import { Slot } from "../Slot.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { NavigationItem } from "./NavigationItem.js";
|
|
6
|
+
import { NavigationWrapper } from "./NavigationWrapper.js";
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const Navigation = ({
|
|
9
9
|
onRequestClose,
|
|
10
|
-
|
|
10
|
+
navigation,
|
|
11
11
|
}: {
|
|
12
12
|
onRequestClose?: () => void;
|
|
13
|
-
|
|
13
|
+
navigation: NavigationItemType[];
|
|
14
14
|
}) => (
|
|
15
15
|
<>
|
|
16
|
-
<
|
|
16
|
+
<NavigationWrapper>
|
|
17
17
|
<Slot.Target name="navigation-before" />
|
|
18
|
-
{
|
|
19
|
-
<
|
|
18
|
+
{navigation.map((item) => (
|
|
19
|
+
<NavigationItem
|
|
20
20
|
key={
|
|
21
|
-
|
|
22
|
-
(
|
|
23
|
-
item.
|
|
21
|
+
item.type +
|
|
22
|
+
(item.label ?? "") +
|
|
23
|
+
("path" in item ? item.path : "") +
|
|
24
|
+
("file" in item ? item.file : "") +
|
|
25
|
+
("to" in item ? item.to : "")
|
|
24
26
|
}
|
|
25
27
|
item={item}
|
|
26
28
|
/>
|
|
27
29
|
))}
|
|
28
30
|
<Slot.Target name="navigation-after" />
|
|
29
|
-
</
|
|
31
|
+
</NavigationWrapper>
|
|
30
32
|
<DrawerContent
|
|
31
33
|
className="lg:hidden h-[100dvh] start-0 w-[320px] rounded-none"
|
|
32
34
|
aria-describedby={undefined}
|
|
33
35
|
>
|
|
34
36
|
<div className="p-4 overflow-y-auto overscroll-none">
|
|
35
37
|
<VisuallyHidden>
|
|
36
|
-
<DrawerTitle>
|
|
38
|
+
<DrawerTitle>Navigation</DrawerTitle>
|
|
37
39
|
</VisuallyHidden>
|
|
38
|
-
{
|
|
39
|
-
<
|
|
40
|
+
{navigation.map((item) => (
|
|
41
|
+
<NavigationItem
|
|
40
42
|
key={item.label}
|
|
41
43
|
item={item}
|
|
42
44
|
onRequestClose={onRequestClose}
|
|
@@ -4,17 +4,17 @@ import { ChevronRightIcon } from "lucide-react";
|
|
|
4
4
|
import { memo, useEffect, useState } from "react";
|
|
5
5
|
import { NavLink, useLocation, useMatch } from "react-router";
|
|
6
6
|
import { Button } from "zudoku/ui/Button.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { NavigationCategory as NavigationCategoryType } from "../../../config/validators/NavigationSchema.js";
|
|
8
8
|
import { cn } from "../../util/cn.js";
|
|
9
9
|
import { joinUrl } from "../../util/joinUrl.js";
|
|
10
|
-
import {
|
|
10
|
+
import { NavigationItem } from "./NavigationItem.js";
|
|
11
11
|
import { navigationListItem, useIsCategoryOpen } from "./utils.js";
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const NavigationCategoryInner = ({
|
|
14
14
|
category,
|
|
15
15
|
onRequestClose,
|
|
16
16
|
}: {
|
|
17
|
-
category:
|
|
17
|
+
category: NavigationCategoryType;
|
|
18
18
|
onRequestClose?: () => void;
|
|
19
19
|
}) => {
|
|
20
20
|
const isCategoryOpen = useIsCategoryOpen(category);
|
|
@@ -27,11 +27,11 @@ const SidebarCategoryInner = ({
|
|
|
27
27
|
!isCollapsible || !isCollapsed || isCategoryOpen,
|
|
28
28
|
);
|
|
29
29
|
const [open, setOpen] = useState(isDefaultOpen);
|
|
30
|
-
const isActive = useMatch(category.link?.
|
|
30
|
+
const isActive = useMatch(category.link?.path ?? "");
|
|
31
31
|
|
|
32
32
|
useEffect(() => {
|
|
33
|
-
// this is triggered when an item from the
|
|
34
|
-
// and the
|
|
33
|
+
// this is triggered when an item from the navigation is clicked
|
|
34
|
+
// and the navigation, enclosing this item, is not opened
|
|
35
35
|
if (isCategoryOpen) {
|
|
36
36
|
setOpen(true);
|
|
37
37
|
}
|
|
@@ -85,7 +85,7 @@ const SidebarCategoryInner = ({
|
|
|
85
85
|
{category.link?.type === "doc" ? (
|
|
86
86
|
<NavLink
|
|
87
87
|
to={{
|
|
88
|
-
pathname: joinUrl(category.link.
|
|
88
|
+
pathname: joinUrl(category.link.path),
|
|
89
89
|
search: location.search,
|
|
90
90
|
}}
|
|
91
91
|
className={styles}
|
|
@@ -123,11 +123,13 @@ const SidebarCategoryInner = ({
|
|
|
123
123
|
>
|
|
124
124
|
<ul className="relative after:absolute after:-start-(--padding-nav-item) after:translate-x-[1.5px] after:top-0 after:bottom-0 after:w-px after:bg-border">
|
|
125
125
|
{category.items.map((item) => (
|
|
126
|
-
<
|
|
126
|
+
<NavigationItem
|
|
127
127
|
key={
|
|
128
|
-
|
|
129
|
-
(
|
|
130
|
-
item.
|
|
128
|
+
item.type +
|
|
129
|
+
(item.label ?? "") +
|
|
130
|
+
("path" in item ? item.path : "") +
|
|
131
|
+
("file" in item ? item.file : "") +
|
|
132
|
+
("to" in item ? item.to : "")
|
|
131
133
|
}
|
|
132
134
|
onRequestClose={onRequestClose}
|
|
133
135
|
item={item}
|
|
@@ -139,6 +141,6 @@ const SidebarCategoryInner = ({
|
|
|
139
141
|
);
|
|
140
142
|
};
|
|
141
143
|
|
|
142
|
-
export const
|
|
144
|
+
export const NavigationCategory = memo(NavigationCategoryInner, deepEqual);
|
|
143
145
|
|
|
144
|
-
|
|
146
|
+
NavigationCategory.displayName = "NavigationCategory";
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
TooltipProvider,
|
|
9
9
|
TooltipTrigger,
|
|
10
10
|
} from "zudoku/ui/Tooltip.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type { NavigationItem as NavigationItemType } from "../../../config/validators/NavigationSchema.js";
|
|
12
12
|
import { cn } from "../../util/cn.js";
|
|
13
13
|
import { joinUrl } from "../../util/joinUrl.js";
|
|
14
14
|
import { AnchorLink } from "../AnchorLink.js";
|
|
15
15
|
import { useViewportAnchor } from "../context/ViewportAnchorContext.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { NavigationBadge } from "./NavigationBadge.js";
|
|
17
|
+
import { NavigationCategory } from "./NavigationCategory.js";
|
|
18
18
|
import { navigationListItem } from "./utils.js";
|
|
19
19
|
|
|
20
20
|
const TruncatedLabel = ({
|
|
@@ -65,11 +65,11 @@ const TruncatedLabel = ({
|
|
|
65
65
|
|
|
66
66
|
export const DATA_ANCHOR_ATTR = "data-anchor";
|
|
67
67
|
|
|
68
|
-
export const
|
|
68
|
+
export const NavigationItem = ({
|
|
69
69
|
item,
|
|
70
70
|
onRequestClose,
|
|
71
71
|
}: {
|
|
72
|
-
item:
|
|
72
|
+
item: NavigationItemType;
|
|
73
73
|
onRequestClose?: () => void;
|
|
74
74
|
}) => {
|
|
75
75
|
const location = useLocation();
|
|
@@ -78,23 +78,26 @@ export const SidebarItem = ({
|
|
|
78
78
|
switch (item.type) {
|
|
79
79
|
case "category":
|
|
80
80
|
return (
|
|
81
|
-
<
|
|
81
|
+
<NavigationCategory category={item} onRequestClose={onRequestClose} />
|
|
82
82
|
);
|
|
83
83
|
case "doc":
|
|
84
84
|
return (
|
|
85
85
|
<NavLink
|
|
86
|
+
viewTransition
|
|
86
87
|
className={({ isActive, isPending }) =>
|
|
87
88
|
navigationListItem({ isActive, isPending })
|
|
88
89
|
}
|
|
89
|
-
to={joinUrl(item.
|
|
90
|
+
to={joinUrl(item.path)}
|
|
90
91
|
onClick={onRequestClose}
|
|
91
92
|
end
|
|
92
93
|
>
|
|
93
94
|
{item.icon && <item.icon size={16} className="align-[-0.125em]" />}
|
|
94
95
|
{item.badge ? (
|
|
95
96
|
<>
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
{item.label && (
|
|
98
|
+
<TruncatedLabel label={item.label} className="flex-1" />
|
|
99
|
+
)}
|
|
100
|
+
<NavigationBadge {...item.badge} />
|
|
98
101
|
</>
|
|
99
102
|
) : (
|
|
100
103
|
item.label
|
|
@@ -102,24 +105,26 @@ export const SidebarItem = ({
|
|
|
102
105
|
</NavLink>
|
|
103
106
|
);
|
|
104
107
|
case "link":
|
|
105
|
-
|
|
108
|
+
case "custom-page": {
|
|
109
|
+
const href = item.type === "link" ? item.to : item.path;
|
|
110
|
+
return !href.startsWith("http") ? (
|
|
106
111
|
<AnchorLink
|
|
107
112
|
to={{
|
|
108
|
-
pathname:
|
|
109
|
-
hash:
|
|
113
|
+
pathname: href.split("#")[0],
|
|
114
|
+
hash: href.split("#")[1],
|
|
110
115
|
search: location.search,
|
|
111
116
|
}}
|
|
112
|
-
{...{ [DATA_ANCHOR_ATTR]:
|
|
117
|
+
{...{ [DATA_ANCHOR_ATTR]: href.split("#")[1] }}
|
|
113
118
|
className={navigationListItem({
|
|
114
|
-
isActive:
|
|
119
|
+
isActive: href === [location.pathname, activeAnchor].join("#"),
|
|
115
120
|
})}
|
|
116
121
|
onClick={onRequestClose}
|
|
117
122
|
>
|
|
118
123
|
{item.icon && <item.icon size={16} className="align-[-0.125em]" />}
|
|
119
124
|
{item.badge ? (
|
|
120
125
|
<>
|
|
121
|
-
<TruncatedLabel label={item.label} />
|
|
122
|
-
<
|
|
126
|
+
{item.label && <TruncatedLabel label={item.label} />}
|
|
127
|
+
<NavigationBadge {...item.badge} />
|
|
123
128
|
</>
|
|
124
129
|
) : (
|
|
125
130
|
<span className="break-all">{item.label}</span>
|
|
@@ -128,7 +133,7 @@ export const SidebarItem = ({
|
|
|
128
133
|
) : (
|
|
129
134
|
<a
|
|
130
135
|
className={navigationListItem()}
|
|
131
|
-
href={
|
|
136
|
+
href={href}
|
|
132
137
|
target="_blank"
|
|
133
138
|
rel="noopener noreferrer"
|
|
134
139
|
onClick={onRequestClose}
|
|
@@ -141,5 +146,6 @@ export const SidebarItem = ({
|
|
|
141
146
|
</span>
|
|
142
147
|
</a>
|
|
143
148
|
);
|
|
149
|
+
}
|
|
144
150
|
}
|
|
145
151
|
};
|