zudoku 0.19.0 → 0.20.1

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 (68) hide show
  1. package/dist/cli/common/outdated.js +2 -1
  2. package/dist/cli/common/outdated.js.map +1 -1
  3. package/dist/config/common.d.ts +8 -0
  4. package/dist/config/common.js +2 -0
  5. package/dist/config/common.js.map +1 -0
  6. package/dist/config/config.d.ts +3 -2
  7. package/dist/config/loader.d.ts +12 -0
  8. package/dist/config/loader.js +117 -0
  9. package/dist/config/loader.js.map +1 -0
  10. package/dist/config/validators/common.d.ts +4651 -0
  11. package/dist/config/validators/common.js +269 -0
  12. package/dist/config/validators/common.js.map +1 -0
  13. package/dist/config/validators/validate.d.ts +350 -584
  14. package/dist/config/validators/validate.js +9 -246
  15. package/dist/config/validators/validate.js.map +1 -1
  16. package/dist/lib/components/Heading.d.ts +1 -1
  17. package/dist/lib/components/TopNavigation.d.ts +1 -1
  18. package/dist/lib/components/navigation/SidebarCategory.d.ts +1 -2
  19. package/dist/lib/components/navigation/SidebarCategory.js +3 -4
  20. package/dist/lib/components/navigation/SidebarCategory.js.map +1 -1
  21. package/dist/lib/components/navigation/SidebarItem.d.ts +1 -3
  22. package/dist/lib/components/navigation/SidebarItem.js +4 -9
  23. package/dist/lib/components/navigation/SidebarItem.js.map +1 -1
  24. package/dist/lib/components/navigation/SidebarWrapper.js +1 -1
  25. package/dist/lib/components/navigation/SidebarWrapper.js.map +1 -1
  26. package/dist/lib/core/ZudokuContext.d.ts +1 -1
  27. package/dist/lib/plugins/markdown/index.d.ts +1 -1
  28. package/dist/lib/plugins/markdown/resolver.js.map +1 -1
  29. package/dist/lib/plugins/redirect/index.d.ts +1 -1
  30. package/dist/lib/ui/Command.d.ts +1 -1
  31. package/dist/lib/util/MdxComponents.d.ts +2 -3
  32. package/dist/lib/util/MdxComponents.js.map +1 -1
  33. package/dist/vite/build.js +4 -1
  34. package/dist/vite/build.js.map +1 -1
  35. package/dist/vite/config.d.ts +1 -3
  36. package/dist/vite/config.js +2 -4
  37. package/dist/vite/config.js.map +1 -1
  38. package/dist/vite/dev-server.js.map +1 -1
  39. package/dist/vite/output.d.ts +1 -1
  40. package/dist/vite/output.js.map +1 -1
  41. package/dist/vite/plugin-config-reload.d.ts +1 -2
  42. package/dist/vite/plugin-config-reload.js.map +1 -1
  43. package/dist/vite/plugin.d.ts +1 -2
  44. package/dist/vite/plugin.js.map +1 -1
  45. package/dist/vite/prerender.d.ts +2 -1
  46. package/dist/vite/prerender.js +2 -2
  47. package/dist/vite/prerender.js.map +1 -1
  48. package/dist/vite/sitemap.d.ts +1 -1
  49. package/dist/zuplo/env.d.ts +6 -0
  50. package/dist/zuplo/env.js +9 -0
  51. package/dist/zuplo/env.js.map +1 -0
  52. package/dist/zuplo/with-zuplo.d.ts +2 -2
  53. package/dist/zuplo/with-zuplo.js.map +1 -1
  54. package/lib/Markdown-ievDDhFT.js.map +1 -1
  55. package/lib/zudoku.components.js +259 -271
  56. package/lib/zudoku.components.js.map +1 -1
  57. package/lib/zudoku.plugin-markdown.js.map +1 -1
  58. package/lib/zudoku.plugin-redirect.js.map +1 -1
  59. package/package.json +2 -2
  60. package/src/lib/components/TopNavigation.tsx +1 -1
  61. package/src/lib/components/navigation/SidebarCategory.tsx +7 -9
  62. package/src/lib/components/navigation/SidebarItem.tsx +3 -16
  63. package/src/lib/components/navigation/SidebarWrapper.tsx +1 -1
  64. package/src/lib/core/ZudokuContext.ts +1 -1
  65. package/src/lib/plugins/markdown/index.tsx +1 -1
  66. package/src/lib/plugins/markdown/resolver.ts +2 -4
  67. package/src/lib/plugins/redirect/index.tsx +1 -1
  68. package/src/lib/util/MdxComponents.tsx +2 -5
@@ -1 +1 @@
1
- {"version":3,"file":"zudoku.plugin-markdown.js","sources":["../src/lib/plugins/markdown/resolver.ts","../src/lib/plugins/markdown/index.tsx"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport {\n ZudokuConfig,\n ZudokuDocsConfig,\n} from \"../../../config/validators/validate.js\";\n\nconst DEFAULT_DOCS_FILES = \"/pages/**/*.{md,mdx}\";\n\n// TODO: This should be dynamic based on the glob selector\nconst SUPPORTED_EXTENSIONS = [\".md\", \".mdx\"];\n\n/**\n * Utilities for resolving markdown file paths and routes\n */\nexport class DocResolver {\n constructor(private config: ZudokuConfig) {}\n\n fileMap = new Map<string, string>();\n\n /**\n * Gets the default docs config from the zudoku config\n */\n getDocsConfigs() {\n const docsConfigs: ZudokuDocsConfig[] = this.config.docs\n ? Array.isArray(this.config.docs)\n ? this.config.docs\n : [this.config.docs]\n : [{ files: DEFAULT_DOCS_FILES }];\n\n return docsConfigs;\n }\n\n /**\n * Resolves the first matching file system path for a given docId\n * @param docId - The docId to resolve\n * @returns\n */\n resolveFilePath(docId: string) {\n const docsConfigs = this.getDocsConfigs();\n let fsPath: string | undefined;\n\n docsConfigs.forEach(({ files: fileGlob }) => {\n if (fsPath) {\n return;\n }\n const rootDir = DocResolver.getRootDir(fileGlob);\n for (const ext of SUPPORTED_EXTENSIONS) {\n if (fsPath) {\n return;\n }\n const checkPath = path.join(rootDir, `${docId}${ext}`);\n if (fs.existsSync(checkPath)) {\n fsPath = checkPath;\n }\n }\n });\n\n return fsPath;\n }\n\n /**\n * Gets the root directory from a files glob\n */\n private static getRootDir(filesGlob: string) {\n let rootDir = filesGlob.split(\"**\")[0];\n if (!rootDir) {\n throw new Error(\"Invalid files glob. Must have '**' in the path.\");\n }\n rootDir = rootDir.replace(\"/**\", \"/\");\n return rootDir;\n }\n\n /**\n * Resolves the route path for a given file system path\n * @param options - The options to resolve the route path\n * @returns The string route path\n */\n static resolveRoutePath({\n filesGlob,\n fsPath,\n }: {\n filesGlob: string;\n fsPath: string;\n }) {\n const rootDir = this.getRootDir(filesGlob);\n const re = new RegExp(`^${rootDir}(.*).mdx?`);\n const match = fsPath.match(re);\n const routePath = match?.at(1);\n return routePath;\n }\n}\n","import type { Toc } from \"@stefanprobst/rehype-extract-toc\";\nimport type { MDXProps } from \"mdx/types.js\";\nimport { RouteObject } from \"react-router-dom\";\nimport { ZudokuDocsConfig } from \"../../../config/validators/validate.js\";\nimport type { ZudokuPlugin } from \"../../core/plugins.js\";\nimport { DocResolver } from \"./resolver.js\";\n\nexport interface MarkdownPluginOptions extends ZudokuDocsConfig {\n fileImports: Record<string, () => Promise<MDXImport>>;\n}\nexport type MarkdownPluginDefaultOptions = Pick<\n Frontmatter,\n \"toc\" | \"disablePager\"\n>;\n\nexport type Frontmatter = {\n title?: string;\n description?: string;\n category?: string;\n toc?: boolean;\n disablePager?: boolean;\n};\n\nexport type MDXImport = {\n tableOfContents: Toc;\n frontmatter: Frontmatter;\n excerpt?: string;\n default: (props: MDXProps) => JSX.Element;\n};\n\nexport const markdownPlugin = (\n options: MarkdownPluginOptions[],\n): ZudokuPlugin => ({\n getRoutes: () => {\n const routeMap = new Map<string, RouteObject>();\n options.forEach(({ fileImports, files, defaultOptions }) =>\n Object.entries(fileImports).flatMap(([file, importPromise]) => {\n const routePath = DocResolver.resolveRoutePath({\n filesGlob: files,\n fsPath: file,\n });\n\n if (!routePath) return [];\n\n if (routeMap.has(routePath)) {\n // eslint-disable-next-line no-console\n console.warn(\n `Duplicate route path found for ${routePath}. Skipping file at '${file}'.`,\n );\n return [];\n }\n\n const route: RouteObject = {\n path: routePath,\n lazy: async () => {\n const { MdxPage } = await import(\"./MdxPage.js\");\n const { default: Component, ...props } = await importPromise();\n return {\n element: (\n <MdxPage\n file={file}\n mdxComponent={Component}\n {...props}\n defaultOptions={defaultOptions}\n />\n ),\n };\n },\n };\n routeMap.set(routePath, route);\n }),\n );\n return [...routeMap.values()];\n },\n});\n"],"names":["DEFAULT_DOCS_FILES","SUPPORTED_EXTENSIONS","DocResolver","config","__publicField","docId","docsConfigs","fsPath","fileGlob","rootDir","ext","checkPath","path","fs","filesGlob","re","match","markdownPlugin","options","routeMap","fileImports","files","defaultOptions","file","importPromise","routePath","route","MdxPage","Component","props","jsx"],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AAO,MAAMQ,CAAE;AAEtB,WADWC,KAAA,gBAAAA,EAAO,GAAG;AAAA,EAE9B;AACF;AC7Da,MAAAC,IAAiB,CAC5BC,OACkB;AAAA,EAClB,WAAW,MAAM;AACT,UAAAC,wBAAe;AACb,WAAAD,EAAA;AAAA,MAAQ,CAAC,EAAE,aAAAE,GAAa,OAAAC,GAAO,gBAAAC,QACrC,OAAO,QAAQF,CAAW,EAAE,QAAQ,CAAC,CAACG,GAAMC,CAAa,MAAM;AACvD,cAAAC,IAAYvB,EAAY,iBAAiB;AAAA,UAC7C,WAAWmB;AAAA,UACX,QAAQE;AAAA,QAAA,CACT;AAEG,YAAA,CAACE,EAAW,QAAO;AAEnB,YAAAN,EAAS,IAAIM,CAAS;AAEhB,yBAAA;AAAA,YACN,kCAAkCA,CAAS,uBAAuBF,CAAI;AAAA,UAAA,GAEjE;AAGT,cAAMG,IAAqB;AAAA,UACzB,MAAMD;AAAA,UACN,MAAM,YAAY;AAChB,kBAAM,EAAE,SAAAE,EAAA,IAAY,MAAM,OAAO,uBAAc,GACzC,EAAE,SAASC,GAAW,GAAGC,EAAM,IAAI,MAAML;AACxC,mBAAA;AAAA,cACL,SACEM,gBAAAA,EAAA;AAAA,gBAACH;AAAA,gBAAA;AAAA,kBACC,MAAAJ;AAAA,kBACA,cAAcK;AAAA,kBACb,GAAGC;AAAA,kBACJ,gBAAAP;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA;AAAA,UAGN;AAAA,QAAA;AAEO,QAAAH,EAAA,IAAIM,GAAWC,CAAK;AAAA,MAAA,CAC9B;AAAA,IAAA,GAEI,CAAC,GAAGP,EAAS,OAAA,CAAQ;AAAA,EAC9B;AACF;"}
1
+ {"version":3,"file":"zudoku.plugin-markdown.js","sources":["../src/lib/plugins/markdown/resolver.ts","../src/lib/plugins/markdown/index.tsx"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { ZudokuDocsConfig } from \"../../../config/validators/common.js\";\nimport { ZudokuConfig } from \"../../../config/validators/validate.js\";\n\nconst DEFAULT_DOCS_FILES = \"/pages/**/*.{md,mdx}\";\n\n// TODO: This should be dynamic based on the glob selector\nconst SUPPORTED_EXTENSIONS = [\".md\", \".mdx\"];\n\n/**\n * Utilities for resolving markdown file paths and routes\n */\nexport class DocResolver {\n constructor(private config: ZudokuConfig) {}\n\n fileMap = new Map<string, string>();\n\n /**\n * Gets the default docs config from the zudoku config\n */\n getDocsConfigs() {\n const docsConfigs: ZudokuDocsConfig[] = this.config.docs\n ? Array.isArray(this.config.docs)\n ? this.config.docs\n : [this.config.docs]\n : [{ files: DEFAULT_DOCS_FILES }];\n\n return docsConfigs;\n }\n\n /**\n * Resolves the first matching file system path for a given docId\n * @param docId - The docId to resolve\n * @returns\n */\n resolveFilePath(docId: string) {\n const docsConfigs = this.getDocsConfigs();\n let fsPath: string | undefined;\n\n docsConfigs.forEach(({ files: fileGlob }) => {\n if (fsPath) {\n return;\n }\n const rootDir = DocResolver.getRootDir(fileGlob);\n for (const ext of SUPPORTED_EXTENSIONS) {\n if (fsPath) {\n return;\n }\n const checkPath = path.join(rootDir, `${docId}${ext}`);\n if (fs.existsSync(checkPath)) {\n fsPath = checkPath;\n }\n }\n });\n\n return fsPath;\n }\n\n /**\n * Gets the root directory from a files glob\n */\n private static getRootDir(filesGlob: string) {\n let rootDir = filesGlob.split(\"**\")[0];\n if (!rootDir) {\n throw new Error(\"Invalid files glob. Must have '**' in the path.\");\n }\n rootDir = rootDir.replace(\"/**\", \"/\");\n return rootDir;\n }\n\n /**\n * Resolves the route path for a given file system path\n * @param options - The options to resolve the route path\n * @returns The string route path\n */\n static resolveRoutePath({\n filesGlob,\n fsPath,\n }: {\n filesGlob: string;\n fsPath: string;\n }) {\n const rootDir = this.getRootDir(filesGlob);\n const re = new RegExp(`^${rootDir}(.*).mdx?`);\n const match = fsPath.match(re);\n const routePath = match?.at(1);\n return routePath;\n }\n}\n","import type { Toc } from \"@stefanprobst/rehype-extract-toc\";\nimport type { MDXProps } from \"mdx/types.js\";\nimport { RouteObject } from \"react-router-dom\";\nimport { ZudokuDocsConfig } from \"../../../config/validators/common.js\";\nimport type { ZudokuPlugin } from \"../../core/plugins.js\";\nimport { DocResolver } from \"./resolver.js\";\n\nexport interface MarkdownPluginOptions extends ZudokuDocsConfig {\n fileImports: Record<string, () => Promise<MDXImport>>;\n}\nexport type MarkdownPluginDefaultOptions = Pick<\n Frontmatter,\n \"toc\" | \"disablePager\"\n>;\n\nexport type Frontmatter = {\n title?: string;\n description?: string;\n category?: string;\n toc?: boolean;\n disablePager?: boolean;\n};\n\nexport type MDXImport = {\n tableOfContents: Toc;\n frontmatter: Frontmatter;\n excerpt?: string;\n default: (props: MDXProps) => JSX.Element;\n};\n\nexport const markdownPlugin = (\n options: MarkdownPluginOptions[],\n): ZudokuPlugin => ({\n getRoutes: () => {\n const routeMap = new Map<string, RouteObject>();\n options.forEach(({ fileImports, files, defaultOptions }) =>\n Object.entries(fileImports).flatMap(([file, importPromise]) => {\n const routePath = DocResolver.resolveRoutePath({\n filesGlob: files,\n fsPath: file,\n });\n\n if (!routePath) return [];\n\n if (routeMap.has(routePath)) {\n // eslint-disable-next-line no-console\n console.warn(\n `Duplicate route path found for ${routePath}. Skipping file at '${file}'.`,\n );\n return [];\n }\n\n const route: RouteObject = {\n path: routePath,\n lazy: async () => {\n const { MdxPage } = await import(\"./MdxPage.js\");\n const { default: Component, ...props } = await importPromise();\n return {\n element: (\n <MdxPage\n file={file}\n mdxComponent={Component}\n {...props}\n defaultOptions={defaultOptions}\n />\n ),\n };\n },\n };\n routeMap.set(routePath, route);\n }),\n );\n return [...routeMap.values()];\n },\n});\n"],"names":["DEFAULT_DOCS_FILES","SUPPORTED_EXTENSIONS","DocResolver","config","__publicField","docId","docsConfigs","fsPath","fileGlob","rootDir","ext","checkPath","path","fs","filesGlob","re","match","markdownPlugin","options","routeMap","fileImports","files","defaultOptions","file","importPromise","routePath","route","MdxPage","Component","props","jsx"],"mappings":";;;;;AAKA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E;AAEtB,WADWC,KAAA,gBAAAA,EAAO,GAAG;AAAA,EAE9B;AACF;AC3Da,MAAAC,IAAiB,CAC5BC,OACkB;AAAA,EAClB,WAAW,MAAM;AACT,UAAAC,wBAAe;AACb,WAAAD,EAAA;AAAA,MAAQ,CAAC,EAAE,aAAAE,GAAa,OAAAC,GAAO,gBAAAC,QACrC,OAAO,QAAQF,CAAW,EAAE,QAAQ,CAAC,CAACG,GAAMC,CAAa,MAAM;AACvD,cAAAC,IAAYvB,EAAY,iBAAiB;AAAA,UAC7C,WAAWmB;AAAA,UACX,QAAQE;AAAA,QAAA,CACT;AAEG,YAAA,CAACE,EAAW,QAAO;AAEnB,YAAAN,EAAS,IAAIM,CAAS;AAEhB,yBAAA;AAAA,YACN,kCAAkCA,CAAS,uBAAuBF,CAAI;AAAA,UAAA,GAEjE;AAGT,cAAMG,IAAqB;AAAA,UACzB,MAAMD;AAAA,UACN,MAAM,YAAY;AAChB,kBAAM,EAAE,SAAAE,EAAA,IAAY,MAAM,OAAO,uBAAc,GACzC,EAAE,SAASC,GAAW,GAAGC,EAAM,IAAI,MAAML;AACxC,mBAAA;AAAA,cACL,SACEM,gBAAAA,EAAA;AAAA,gBAACH;AAAA,gBAAA;AAAA,kBACC,MAAAJ;AAAA,kBACA,cAAcK;AAAA,kBACb,GAAGC;AAAA,kBACJ,gBAAAP;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA;AAAA,UAGN;AAAA,QAAA;AAEO,QAAAH,EAAA,IAAIM,GAAWC,CAAK;AAAA,MAAA,CAC9B;AAAA,IAAA,GAEI,CAAC,GAAGP,EAAS,OAAA,CAAQ;AAAA,EAC9B;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"zudoku.plugin-redirect.js","sources":["../src/lib/plugins/redirect/index.tsx"],"sourcesContent":["import { redirect } from \"react-router-dom\";\nimport { ZudokuRedirect } from \"../../../config/validators/validate.js\";\nimport type { ZudokuPlugin } from \"../../core/plugins.js\";\n\nexport const redirectPlugin = (options: {\n redirects: ZudokuRedirect[];\n}): ZudokuPlugin => {\n return {\n getRoutes: () =>\n options.redirects.map(({ from, to }) => ({\n path: from,\n loader: () => redirect(to, 301),\n })),\n };\n};\n"],"names":["redirectPlugin","options","from","to","redirect"],"mappings":";AAIa,MAAAA,IAAiB,CAACC,OAGtB;AAAA,EACL,WAAW,MACTA,EAAQ,UAAU,IAAI,CAAC,EAAE,MAAAC,GAAM,IAAAC,SAAU;AAAA,IACvC,MAAMD;AAAA,IACN,QAAQ,MAAME,EAASD,GAAI,GAAG;AAAA,EAAA,EAC9B;AAAA;"}
1
+ {"version":3,"file":"zudoku.plugin-redirect.js","sources":["../src/lib/plugins/redirect/index.tsx"],"sourcesContent":["import { redirect } from \"react-router-dom\";\nimport { ZudokuRedirect } from \"../../../config/validators/common.js\";\nimport type { ZudokuPlugin } from \"../../core/plugins.js\";\n\nexport const redirectPlugin = (options: {\n redirects: ZudokuRedirect[];\n}): ZudokuPlugin => {\n return {\n getRoutes: () =>\n options.redirects.map(({ from, to }) => ({\n path: from,\n loader: () => redirect(to, 301),\n })),\n };\n};\n"],"names":["redirectPlugin","options","from","to","redirect"],"mappings":";AAIa,MAAAA,IAAiB,CAACC,OAGtB;AAAA,EACL,WAAW,MACTA,EAAQ,UAAU,IAAI,CAAC,EAAE,MAAAC,GAAM,IAAAC,SAAU;AAAA,IACvC,MAAMD;AAAA,IACN,QAAQ,MAAME,EAASD,GAAI,GAAG;AAAA,EAAA,EAC9B;AAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.19.0",
3
+ "version": "0.20.1",
4
4
  "type": "module",
5
5
  "homepage": "https://zudoku.dev",
6
6
  "repository": {
@@ -153,7 +153,6 @@
153
153
  "@types/react": "18.3.11",
154
154
  "@types/react-dom": "18.3.1",
155
155
  "@vitejs/plugin-react": "4.3.4",
156
- "@zudoku/config": "0.19.0",
157
156
  "@zudoku/httpsnippet": "10.0.9",
158
157
  "@zudoku/react-helmet-async": "2.0.4",
159
158
  "autoprefixer": "10.4.20",
@@ -204,6 +203,7 @@
204
203
  "strip-ansi": "7.1.0",
205
204
  "tailwind-merge": "2.5.4",
206
205
  "tailwindcss": "3.4.13",
206
+ "tsx": "^4.19.2",
207
207
  "ulidx": "2.4.1",
208
208
  "unist-util-visit": "5.0.0",
209
209
  "urql": "4.1.0",
@@ -1,7 +1,7 @@
1
1
  import { cx } from "class-variance-authority";
2
2
  import { Suspense } from "react";
3
3
  import { NavLink, useNavigation } from "react-router-dom";
4
- import { TopNavigationItem } from "../../config/validators/validate.js";
4
+ import { TopNavigationItem } from "../../config/validators/common.js";
5
5
  import { useAuth } from "../authentication/hook.js";
6
6
  import { ZudokuError } from "../util/invariant.js";
7
7
  import { joinPath } from "../util/joinPath.js";
@@ -10,11 +10,9 @@ import { useIsCategoryOpen } from "./utils.js";
10
10
 
11
11
  export const SidebarCategory = ({
12
12
  category,
13
- level,
14
13
  onRequestClose,
15
14
  }: {
16
15
  category: SidebarItemCategory;
17
- level: number;
18
16
  onRequestClose?: () => void;
19
17
  }) => {
20
18
  const isCategoryOpen = useIsCategoryOpen(category);
@@ -67,7 +65,6 @@ export const SidebarCategory = ({
67
65
  onClick={() => setHasInteracted(true)}
68
66
  className={navigationListItem({
69
67
  isActive: false,
70
- isTopLevel: level === 0,
71
68
  className: [
72
69
  "text-start",
73
70
  isCollapsible
@@ -79,10 +76,7 @@ export const SidebarCategory = ({
79
76
  {category.icon && (
80
77
  <category.icon
81
78
  size={16}
82
- className={cn(
83
- "align-[-0.125em] -translate-x-1",
84
- isActive && "text-primary",
85
- )}
79
+ className={cn("align-[-0.125em] ", isActive && "text-primary")}
86
80
  />
87
81
  )}
88
82
  {category.link?.type === "doc" ? (
@@ -118,9 +112,14 @@ export const SidebarCategory = ({
118
112
  className={cn(
119
113
  // CollapsibleContent class is used to animate and it should only be applied when the user has triggered the toggle
120
114
  hasInteracted && "CollapsibleContent",
115
+ "ms-6 my-1",
121
116
  )}
122
117
  >
123
- <ul className="mt-1 border-l ms-0.5">
118
+ <ul
119
+ className={
120
+ "relative after:absolute after:-left-[--padding-nav-item] after:translate-x-[1.5px] after:top-0 after:bottom-0 after:w-px after:bg-border"
121
+ }
122
+ >
124
123
  {category.items.map((item) => (
125
124
  <SidebarItem
126
125
  key={
@@ -129,7 +128,6 @@ export const SidebarCategory = ({
129
128
  item.label
130
129
  }
131
130
  onRequestClose={onRequestClose}
132
- level={level + 1}
133
131
  item={item}
134
132
  />
135
133
  ))}
@@ -13,10 +13,6 @@ export const navigationListItem = cva(
13
13
  "flex items-center gap-2 px-[--padding-nav-item] py-1.5 rounded-lg hover:bg-accent transition-colors duration-300",
14
14
  {
15
15
  variants: {
16
- isTopLevel: {
17
- true: "font-medium -mx-[--padding-nav-item]",
18
- false: "-mr-[--padding-nav-item] ml-[--padding-nav-item]",
19
- },
20
16
  isActive: {
21
17
  true: "text-primary font-medium",
22
18
  false: "text-foreground/80",
@@ -36,11 +32,9 @@ export const DATA_ANCHOR_ATTR = "data-anchor";
36
32
 
37
33
  export const SidebarItem = ({
38
34
  item,
39
- level = 0,
40
35
  onRequestClose,
41
36
  }: {
42
37
  item: SidebarItemType;
43
- level?: number;
44
38
  onRequestClose?: () => void;
45
39
  }) => {
46
40
  const { activeAnchor } = useViewportAnchor();
@@ -49,18 +43,12 @@ export const SidebarItem = ({
49
43
  switch (item.type) {
50
44
  case "category":
51
45
  return (
52
- <SidebarCategory
53
- category={item}
54
- level={level}
55
- onRequestClose={onRequestClose}
56
- />
46
+ <SidebarCategory category={item} onRequestClose={onRequestClose} />
57
47
  );
58
48
  case "doc":
59
49
  return (
60
50
  <NavLink
61
- className={({ isActive }) =>
62
- navigationListItem({ isActive, isTopLevel: level === 0 })
63
- }
51
+ className={({ isActive }) => navigationListItem({ isActive })}
64
52
  to={joinPath(item.id)}
65
53
  onClick={onRequestClose}
66
54
  >
@@ -84,7 +72,6 @@ export const SidebarItem = ({
84
72
  {...{ [DATA_ANCHOR_ATTR]: item.href.slice(1) }}
85
73
  className={navigationListItem({
86
74
  isActive: item.href.slice(1) === activeAnchor,
87
- isTopLevel: level === 0,
88
75
  className: item.badge?.placement !== "start" && "justify-between",
89
76
  })}
90
77
  onClick={onRequestClose}
@@ -120,7 +107,7 @@ export const SidebarItem = ({
120
107
  </NavLink>
121
108
  ) : (
122
109
  <a
123
- className={navigationListItem({ isTopLevel: level === 0 })}
110
+ className={navigationListItem()}
124
111
  href={item.href}
125
112
  target="_blank"
126
113
  rel="noopener noreferrer"
@@ -13,7 +13,7 @@ export const SidebarWrapper = forwardRef<
13
13
  data-navigation={String(pushMainContent)}
14
14
  className={cn(
15
15
  "scrollbar peer hidden lg:flex flex-col fixed text-sm overflow-y-auto shrink-0",
16
- "px-[--padding-nav-item] -mx-[--padding-nav-item] pb-20 mt-[--padding-content-top]",
16
+ "-mx-[--padding-nav-item] pb-20 mt-[--padding-content-top]",
17
17
  "w-[--side-nav-width] h-[calc(100%-var(--header-height))] scroll-pt-2 gap-2",
18
18
  className,
19
19
  )}
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
+ import { TopNavigationItem } from "../../config/validators/common.js";
2
3
  import type { SidebarConfig } from "../../config/validators/SidebarSchema.js";
3
- import { TopNavigationItem } from "../../config/validators/validate.js";
4
4
  import { type AuthenticationProvider } from "../authentication/authentication.js";
5
5
  import type { ComponentsContextType } from "../components/context/ComponentsContext.js";
6
6
  import { Slotlets } from "../components/SlotletProvider.js";
@@ -1,7 +1,7 @@
1
1
  import type { Toc } from "@stefanprobst/rehype-extract-toc";
2
2
  import type { MDXProps } from "mdx/types.js";
3
3
  import { RouteObject } from "react-router-dom";
4
- import { ZudokuDocsConfig } from "../../../config/validators/validate.js";
4
+ import { ZudokuDocsConfig } from "../../../config/validators/common.js";
5
5
  import type { ZudokuPlugin } from "../../core/plugins.js";
6
6
  import { DocResolver } from "./resolver.js";
7
7
 
@@ -1,9 +1,7 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import {
4
- ZudokuConfig,
5
- ZudokuDocsConfig,
6
- } from "../../../config/validators/validate.js";
3
+ import { ZudokuDocsConfig } from "../../../config/validators/common.js";
4
+ import { ZudokuConfig } from "../../../config/validators/validate.js";
7
5
 
8
6
  const DEFAULT_DOCS_FILES = "/pages/**/*.{md,mdx}";
9
7
 
@@ -1,5 +1,5 @@
1
1
  import { redirect } from "react-router-dom";
2
- import { ZudokuRedirect } from "../../../config/validators/validate.js";
2
+ import { ZudokuRedirect } from "../../../config/validators/common.js";
3
3
  import type { ZudokuPlugin } from "../../core/plugins.js";
4
4
 
5
5
  export const redirectPlugin = (options: {
@@ -1,14 +1,11 @@
1
- import { MDXProvider } from "@mdx-js/react";
2
- import type { ComponentProps } from "react";
1
+ import { MDXComponents } from "mdx/types.js";
3
2
  import { Link } from "react-router-dom";
4
3
  import { Heading } from "../components/Heading.js";
5
4
  import { InlineCode } from "../components/InlineCode.js";
6
5
  import { SyntaxHighlight } from "../components/SyntaxHighlight.js";
7
6
  import { Callout } from "../ui/Callout.js";
8
7
 
9
- export type MdxComponentsType = ComponentProps<
10
- typeof MDXProvider
11
- >["components"];
8
+ export type MdxComponentsType = Readonly<MDXComponents> | null | undefined;
12
9
 
13
10
  export const MdxComponents = {
14
11
  // @ts-expect-error Node is not in types but still gets passed