@nikala-ui/folio 0.14.0 → 0.15.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 (160) hide show
  1. package/README.md +16 -0
  2. package/dist/cli/commands/init.js +105 -51
  3. package/dist/client/app.jsx +6 -3
  4. package/dist/client/components/docs-layout-shell.d.ts +1 -0
  5. package/dist/client/components/docs-layout-shell.jsx +1 -1
  6. package/dist/client/components/docs-page-content.jsx +9 -5
  7. package/dist/client/navigation/page-navigation.js +10 -27
  8. package/dist/client/public/algolia-logo.svg +15 -0
  9. package/dist/client/public/favicon.ico +0 -0
  10. package/dist/client/public/logo.svg +11 -0
  11. package/dist/client/routing/use-docs-router.d.ts +1 -0
  12. package/dist/client/routing/use-docs-router.js +12 -3
  13. package/dist/client/style.css +139 -55
  14. package/dist/components/ui/api-table.jsx +6 -4
  15. package/dist/components/ui/code-block.jsx +6 -4
  16. package/dist/components/ui/command.jsx +9 -5
  17. package/dist/components/ui/list.jsx +3 -1
  18. package/dist/components/ui/logo.d.ts +4 -1
  19. package/dist/components/ui/logo.jsx +8 -22
  20. package/dist/components/ui/package-manager-tabs.jsx +4 -2
  21. package/dist/components/ui/pager.jsx +4 -2
  22. package/dist/components/ui/section-heading.jsx +1 -1
  23. package/dist/components/ui/sidebar.jsx +6 -3
  24. package/dist/components/ui/spinner.jsx +3 -1
  25. package/dist/components/ui/theme-toggle.jsx +14 -12
  26. package/dist/config.d.ts +1 -0
  27. package/dist/config.js +84 -29
  28. package/dist/core/content-scanner.d.ts +2 -1
  29. package/dist/core/content-scanner.js +2 -9
  30. package/dist/core/plugin/index.d.ts +2 -0
  31. package/dist/core/plugin/index.js +1 -0
  32. package/dist/core/plugin/lifecycle-error.d.ts +19 -0
  33. package/dist/core/plugin/lifecycle-error.js +28 -0
  34. package/dist/core/plugin/lifecycle-snapshot.d.ts +1 -0
  35. package/dist/core/plugin/lifecycle-snapshot.js +156 -0
  36. package/dist/core/plugin/lifecycle.d.ts +34 -0
  37. package/dist/core/plugin/lifecycle.js +170 -0
  38. package/dist/core/route-tree.d.ts +3 -2
  39. package/dist/core/route-tree.js +40 -10
  40. package/dist/index.d.ts +7 -4
  41. package/dist/index.js +4 -3
  42. package/dist/plugin.d.ts +60 -0
  43. package/dist/plugin.js +51 -0
  44. package/dist/plugins/i18n/components/site-language-switcher.d.ts +10 -0
  45. package/dist/plugins/i18n/components/site-language-switcher.jsx +39 -0
  46. package/dist/plugins/i18n/constants.d.ts +1 -0
  47. package/dist/plugins/i18n/constants.js +1 -0
  48. package/dist/plugins/i18n/index.d.ts +11 -0
  49. package/dist/plugins/i18n/index.js +89 -0
  50. package/dist/plugins/i18n/navigation.d.ts +5 -0
  51. package/dist/plugins/i18n/navigation.js +33 -0
  52. package/dist/plugins/i18n/runtime.d.ts +19 -0
  53. package/dist/plugins/i18n/runtime.jsx +65 -0
  54. package/dist/plugins/i18n/site-locale.d.ts +12 -0
  55. package/dist/plugins/i18n/site-locale.js +119 -0
  56. package/dist/search/provider.d.ts +9 -0
  57. package/dist/search/provider.js +4 -2
  58. package/dist/server/index.d.ts +4 -1
  59. package/dist/server/index.js +69 -33
  60. package/dist/server/module-serialization.d.ts +6 -0
  61. package/dist/server/module-serialization.js +26 -0
  62. package/dist/server/plugin/components.d.ts +7 -0
  63. package/dist/server/plugin/components.js +82 -0
  64. package/dist/server/plugin/constants.d.ts +17 -0
  65. package/dist/server/plugin/constants.js +21 -0
  66. package/dist/server/{plugin.d.ts → plugin/index.d.ts} +3 -1
  67. package/dist/server/plugin/index.js +166 -0
  68. package/dist/server/plugin/lifecycle.d.ts +32 -0
  69. package/dist/server/plugin/lifecycle.js +110 -0
  70. package/dist/server/plugin/styles.d.ts +3 -0
  71. package/dist/server/plugin/styles.js +22 -0
  72. package/dist/server/plugin/virtual-modules.d.ts +11 -0
  73. package/dist/server/plugin/virtual-modules.js +121 -0
  74. package/dist/server/seo.d.ts +4 -0
  75. package/dist/server/seo.js +87 -0
  76. package/dist/templates/env.d.ts +26 -0
  77. package/dist/templates/locales/en.json +77 -0
  78. package/dist/themes/default/components/docs-landing-body.d.ts +17 -0
  79. package/dist/themes/default/components/docs-landing-body.jsx +17 -0
  80. package/dist/themes/default/components/docs-page-body.d.ts +21 -0
  81. package/dist/themes/default/components/docs-page-body.jsx +36 -0
  82. package/dist/themes/default/components/page-actions.d.ts +15 -0
  83. package/dist/themes/default/components/page-actions.jsx +60 -0
  84. package/dist/themes/default/components/page-header.d.ts +7 -0
  85. package/dist/themes/default/components/page-header.jsx +3 -0
  86. package/dist/themes/default/components/sidebar-footer.d.ts +6 -0
  87. package/dist/themes/default/components/sidebar-footer.jsx +12 -0
  88. package/dist/themes/default/components/sidebar-header.d.ts +8 -0
  89. package/dist/themes/default/components/sidebar-header.jsx +17 -0
  90. package/dist/themes/default/components/sidebar-mobile-nav.d.ts +7 -0
  91. package/dist/themes/default/components/sidebar-mobile-nav.jsx +17 -0
  92. package/dist/themes/default/components/sidebar-promo.d.ts +8 -0
  93. package/dist/themes/default/components/sidebar-promo.jsx +20 -0
  94. package/dist/themes/default/content/breadcrumbs.jsx +5 -2
  95. package/dist/themes/default/content/table-of-contents.jsx +3 -1
  96. package/dist/themes/default/hooks/use-page-copy.d.ts +6 -0
  97. package/dist/themes/default/hooks/use-page-copy.js +26 -0
  98. package/dist/themes/default/layout.jsx +30 -127
  99. package/dist/themes/default/lib/layout-visibility.d.ts +8 -0
  100. package/dist/themes/default/lib/layout-visibility.js +24 -0
  101. package/dist/themes/default/navbar.jsx +14 -7
  102. package/dist/themes/default/navigation/mobile-table-of-contents.jsx +5 -3
  103. package/dist/themes/default/navigation/sidebar-tree.d.ts +2 -0
  104. package/dist/themes/default/navigation/sidebar-tree.jsx +11 -2
  105. package/dist/themes/default/overlays/search-dialog.jsx +14 -3
  106. package/dist/themes/default/sidebar.jsx +21 -49
  107. package/dist/themes/types.d.ts +5 -0
  108. package/dist/types.d.ts +36 -0
  109. package/dist/utils/format-title.d.ts +1 -0
  110. package/dist/utils/format-title.js +11 -0
  111. package/dist/vendor/docs-src/client/page-actions.ts +69 -0
  112. package/dist/vendor/docs-src/components/ui/api-table.tsx +6 -4
  113. package/dist/vendor/docs-src/components/ui/code-block.tsx +6 -4
  114. package/dist/vendor/docs-src/components/ui/command.tsx +9 -5
  115. package/dist/vendor/docs-src/components/ui/list.tsx +4 -2
  116. package/dist/vendor/docs-src/components/ui/logo.tsx +19 -48
  117. package/dist/vendor/docs-src/components/ui/package-manager-tabs.tsx +4 -2
  118. package/dist/vendor/docs-src/components/ui/pager.tsx +4 -2
  119. package/dist/vendor/docs-src/components/ui/section-heading.tsx +5 -1
  120. package/dist/vendor/docs-src/components/ui/sidebar.tsx +7 -4
  121. package/dist/vendor/docs-src/components/ui/spinner.tsx +3 -1
  122. package/dist/vendor/docs-src/components/ui/theme-toggle.tsx +15 -13
  123. package/dist/vendor/docs-src/navigation/index.ts +2 -0
  124. package/dist/vendor/docs-src/navigation/repository-links.ts +43 -0
  125. package/dist/vendor/docs-src/navigation/sidebar-state.ts +22 -0
  126. package/dist/vendor/docs-src/navigation/sidebar-tree.ts +15 -0
  127. package/dist/vendor/docs-src/plugins/i18n/components/site-language-switcher.tsx +56 -0
  128. package/dist/vendor/docs-src/plugins/i18n/constants.ts +1 -0
  129. package/dist/vendor/docs-src/plugins/i18n/index.ts +110 -0
  130. package/dist/vendor/docs-src/plugins/i18n/navigation.ts +49 -0
  131. package/dist/vendor/docs-src/plugins/i18n/runtime.tsx +91 -0
  132. package/dist/vendor/docs-src/plugins/i18n/site-locale.ts +140 -0
  133. package/dist/vendor/docs-src/search/provider.ts +83 -0
  134. package/dist/vendor/docs-src/themes/default/components/docs-landing-body.tsx +30 -0
  135. package/dist/vendor/docs-src/themes/default/components/docs-page-body.tsx +53 -0
  136. package/dist/vendor/docs-src/themes/default/components/page-actions.tsx +105 -0
  137. package/dist/vendor/docs-src/themes/default/components/page-header.tsx +31 -0
  138. package/dist/vendor/docs-src/themes/default/components/sidebar-footer.tsx +21 -0
  139. package/dist/vendor/docs-src/themes/default/components/sidebar-header.tsx +30 -0
  140. package/dist/vendor/docs-src/themes/default/components/sidebar-mobile-nav.tsx +33 -0
  141. package/dist/vendor/docs-src/themes/default/components/sidebar-promo.tsx +37 -0
  142. package/dist/vendor/docs-src/themes/default/content/breadcrumbs.tsx +43 -0
  143. package/dist/vendor/docs-src/themes/default/content/pager.tsx +19 -0
  144. package/dist/vendor/docs-src/themes/default/content/table-of-contents.tsx +32 -0
  145. package/dist/vendor/docs-src/themes/default/hooks/use-page-copy.ts +29 -0
  146. package/dist/vendor/docs-src/themes/default/icons.ts +16 -0
  147. package/dist/vendor/docs-src/themes/default/index.ts +46 -0
  148. package/dist/vendor/docs-src/themes/default/layout.tsx +176 -0
  149. package/dist/vendor/docs-src/themes/default/lib/layout-visibility.ts +39 -0
  150. package/dist/vendor/docs-src/themes/default/navbar.tsx +130 -0
  151. package/dist/vendor/docs-src/themes/default/navigation/mobile-table-of-contents.tsx +61 -0
  152. package/dist/vendor/docs-src/themes/default/navigation/sidebar-tree.tsx +202 -0
  153. package/dist/vendor/docs-src/themes/default/overlays/search-dialog.tsx +106 -0
  154. package/dist/vendor/docs-src/themes/default/sidebar.tsx +86 -0
  155. package/dist/vendor/docs-src/themes/index.ts +4 -0
  156. package/dist/vendor/docs-src/themes/types.ts +87 -0
  157. package/dist/version.d.ts +1 -1
  158. package/dist/version.js +1 -1
  159. package/package.json +11 -4
  160. package/dist/server/plugin.js +0 -521
package/README.md CHANGED
@@ -22,6 +22,8 @@ and Tailwind CSS v4 design tokens.
22
22
  - Local search and configurable page metadata.
23
23
  - Shiki syntax highlighting with lazy language and theme loading.
24
24
  - Custom themes, layouts, components, CSS, logos, and site metadata.
25
+ - Typed plugin lifecycle for production builds and development reloads, with
26
+ immutable page/config snapshots and actionable hook errors.
25
27
  - CLI initialization for a complete documentation project.
26
28
 
27
29
  The default theme uses the Nikala UI design system. Additional Nikala UI
@@ -186,6 +188,20 @@ export default config;
186
188
 
187
189
  See the [Configuration](/configuration) guide for the supported options.
188
190
 
191
+ ## Plugin status
192
+
193
+ The plugin API is public and integrated with production builds, development
194
+ reloads, generated projects, and the browser/SSR validation suite. See the
195
+ [plugin authoring guide](docs/configuration/plugins.mdx) for lifecycle order,
196
+ hook contracts, immutable inputs, error handling, and compatibility policy.
197
+
198
+ The API is pre-1.0 and therefore follows a compatible-minor policy: plugin
199
+ packages should pin a compatible Folio minor range such as `~0.15.0`. The
200
+ current contract supports page metadata transformation while preserving route
201
+ identity; adding routes or replacing source MDX requires a separately defined
202
+ future API. This release adds no breaking plugin contract change and requires
203
+ no migration.
204
+
189
205
  ## Customize the theme
190
206
 
191
207
  The generated default theme is under `src/themes/default`. It can be
@@ -15,17 +15,8 @@ async function listSourceFiles(dir) {
15
15
  }
16
16
  return result;
17
17
  }
18
- async function stripSourceMapComments(dir) {
19
- if (!(await fs.pathExists(dir)))
20
- return;
21
- for (const sourceFile of await listSourceFiles(dir)) {
22
- if (!/\.(?:d\.ts|[cm]?[jt]sx?)$/.test(sourceFile))
23
- continue;
24
- const content = await fs.readFile(sourceFile, "utf-8");
25
- const cleaned = content.replace(/\s*\/\/[#@]\s*sourceMappingURL=.*$/gm, "");
26
- if (cleaned !== content)
27
- await fs.writeFile(sourceFile, cleaned, "utf-8");
28
- }
18
+ function isAuthoredSourceFile(file) {
19
+ return /\.(?:ts|tsx)$/.test(file) && !file.endsWith(".d.ts");
29
20
  }
30
21
  async function resolveRegistryDir() {
31
22
  const commandDir = path.dirname(fileURLToPath(import.meta.url));
@@ -79,7 +70,7 @@ async function copyRegistrySource(root) {
79
70
  ].filter((file) => fs.existsSync(file));
80
71
  const projectFiles = [
81
72
  ...(await listSourceFiles(path.join(root, "docs"))),
82
- ...(await listSourceFiles(path.join(root, "src/themes/default"))),
73
+ ...(await listSourceFiles(path.join(root, "src/themes/default"))).filter(isAuthoredSourceFile),
83
74
  ...docsComponentSources,
84
75
  ];
85
76
  const projectSource = (await Promise.all(projectFiles.map((file) => fs.readFile(file, "utf-8")))).join("\n");
@@ -152,7 +143,8 @@ async function copyRegistrySource(root) {
152
143
  : file.path.startsWith("ui/")
153
144
  ? path.join(componentsDir, relative)
154
145
  : path.join(hooksDir, relative);
155
- await fs.outputFile(destination, file.content, "utf-8");
146
+ if (!(await fs.pathExists(destination)))
147
+ await fs.outputFile(destination, file.content, "utf-8");
156
148
  if (file.path.startsWith("hooks/"))
157
149
  hookFiles.push(relative.replace(/\.(tsx?|jsx?)$/, ""));
158
150
  else if (file.path.startsWith("ui/"))
@@ -167,10 +159,12 @@ async function copyRegistrySource(root) {
167
159
  ];
168
160
  const internalComponentsSource = internalComponentCandidates.find((directory) => fs.existsSync(directory));
169
161
  if (internalComponentsSource) {
170
- for (const name of ["theme-toggle"]) {
162
+ for (const name of ["theme-toggle", "sidebar", "section-heading", "command"]) {
171
163
  const source = path.join(internalComponentsSource, `${name}.tsx`);
172
164
  if (await fs.pathExists(source)) {
173
- await fs.copy(source, path.join(componentsDir, `${name}.tsx`));
165
+ const destination = path.join(componentsDir, `${name}.tsx`);
166
+ if (!(await fs.pathExists(destination)))
167
+ await fs.copy(source, destination);
174
168
  componentFiles.push(name);
175
169
  }
176
170
  }
@@ -180,73 +174,105 @@ async function copyRegistrySource(root) {
180
174
  path.resolve(commandDir, "../../vendor/docs-src/lib/cn.ts"),
181
175
  ];
182
176
  const cnSource = cnCandidates.find((candidate) => fs.existsSync(candidate));
183
- if (cnSource)
184
- await fs.outputFile(path.join(root, "src/lib/cn.ts"), await fs.readFile(cnSource, "utf-8"), "utf-8");
177
+ const cnDestination = path.join(root, "src/lib/cn.ts");
178
+ if (cnSource && !(await fs.pathExists(cnDestination))) {
179
+ await fs.outputFile(cnDestination, await fs.readFile(cnSource, "utf-8"), "utf-8");
180
+ }
185
181
  return { componentFiles, hookFiles, dependencies: [...dependencies].sort() };
186
182
  }
183
+ async function copyPluginSources(root) {
184
+ const commandDir = path.dirname(fileURLToPath(import.meta.url));
185
+ const sourceCandidates = [
186
+ path.resolve(commandDir, "../../../src/plugins"),
187
+ path.resolve(commandDir, "../../vendor/docs-src/plugins"),
188
+ ];
189
+ const source = sourceCandidates.find((candidate) => fs.existsSync(candidate));
190
+ if (!source)
191
+ throw new Error("Folio plugin sources are missing from the package");
192
+ for (const sourceFile of (await listSourceFiles(source)).filter(isAuthoredSourceFile)) {
193
+ const relative = path.relative(source, sourceFile);
194
+ const destination = path.join(root, "src/plugins", relative);
195
+ const content = (await fs.readFile(sourceFile, "utf-8"))
196
+ .replace(/from "(?:\.\.\/)+plugin\.js"/g, 'from "@nikala-ui/folio"')
197
+ .replace(/from "(?:\.\.\/)+types\.js"/g, 'from "@nikala-ui/folio"')
198
+ .replace(/(from "(?:\.\/|\.\.\/)[^"]+)\.jsx"/g, "$1.tsx\"")
199
+ .replace(/(from "(?:\.\/|\.\.\/)[^"]+)\.js"/g, "$1.ts\"");
200
+ if (!(await fs.pathExists(destination)))
201
+ await fs.outputFile(destination, content, "utf-8");
202
+ }
203
+ }
187
204
  async function copyCustomTheme(root) {
188
205
  const commandDir = path.dirname(fileURLToPath(import.meta.url));
189
- const sourceCandidates = [path.resolve(commandDir, "../../../src/themes/default"), path.resolve(commandDir, "../../themes/default")];
206
+ const sourceCandidates = [
207
+ path.resolve(commandDir, "../../../src/themes/default"),
208
+ path.resolve(commandDir, "../../vendor/docs-src/themes/default"),
209
+ ];
190
210
  const source = sourceCandidates.find((candidate) => fs.existsSync(candidate));
191
211
  const target = path.join(root, "src/themes/default");
192
212
  if (!source) {
193
- await fs.outputFile(path.join(target, "index.ts"), `export { defaultTheme as default } from "@nikala-ui/folio";
213
+ const destination = path.join(target, "index.ts");
214
+ if (!(await fs.pathExists(destination)))
215
+ await fs.outputFile(destination, `export { defaultTheme as default } from "@nikala-ui/folio";
194
216
  `, "utf-8");
195
217
  return;
196
218
  }
197
219
  for (const sourceFile of await listSourceFiles(source)) {
198
220
  const basename = path.basename(sourceFile);
199
- const isSourceFile = /\.(ts|tsx)$/.test(sourceFile);
200
- const isPublishedThemeFile = /\.jsx?$/.test(sourceFile);
201
- if ((!isSourceFile && !isPublishedThemeFile) || basename !== basename.toLowerCase())
221
+ if (!isAuthoredSourceFile(sourceFile) || basename !== basename.toLowerCase())
202
222
  continue;
203
223
  const relative = path.relative(source, sourceFile)
204
224
  .replace(/\.jsx?$/, ".tsx")
205
225
  .replace(/index\.tsx$/, "index.ts");
206
226
  const destination = path.join(target, relative);
227
+ const runtimePrefix = relative.includes(path.sep) ? "../" : "./";
207
228
  let content = await fs.readFile(sourceFile, "utf-8");
208
229
  content = content
209
230
  .replace(/\s*\/\/[#@]\s*sourceMappingURL=.*$/gm, "")
210
231
  .replace(/from "@nikala-ui\/core\/ui\//g, 'from "@/components/ui/')
211
232
  .replace(/from "@nikala-ui\/core"/g, 'from "@/components/ui"')
212
233
  .replace(/from "@nikala-ui\/hooks"/g, 'from "@/hooks"')
213
- .replace(/from "\.\.\/\.\.\/client\/page-actions\.js"/g, 'from "./runtime/page-actions.js"')
214
- .replace(/from "\.\.\/\.\.\/navigation\/repository-links\.js"/g, 'from "./runtime/repository-links.js"')
215
- .replace(/from "\.\.\/\.\.\/search\/provider\.js"/g, 'from "./runtime/search-provider.js"')
216
- .replace(/from "\.\.\/\.\.\/\.\.\/search\/provider\.js"/g, 'from "../runtime/search-provider.js"')
234
+ .replace(/from "(?:\.\.\/)+client\/page-actions\.js"/g, `from "${runtimePrefix}runtime/page-actions.js"`)
235
+ .replace(/from "(?:\.\.\/)+navigation\/repository-links\.js"/g, `from "${runtimePrefix}runtime/repository-links.js"`)
236
+ .replace(/from "(?:\.\.\/)+search\/provider\.js"/g, `from "${runtimePrefix}runtime/search-provider.js"`)
217
237
  .replace(/from "\.\.\/\.\.\/\.\.\/navigation\/sidebar-state\.js"/g, 'from "./sidebar-state.js"')
218
238
  .replace(/from "(?:\.\.\/)+types\.js"/g, 'from "@nikala-ui/folio"')
239
+ .replace(/import\("(?:\.\.\/)+types\.js"\)/g, 'import("@nikala-ui/folio")')
219
240
  .replace(/from "(\.\.\/|\.\/)[^"]+\.(?:jsx|tsx|js)"/g, (match) => match.replace(/\.(?:jsx|tsx|js)"$/, '"'))
220
241
  .replace(/export \* from "(\.\.\/|\.\/)[^"]+\.(?:jsx|tsx|js)"/g, (match) => match.replace(/\.(?:jsx|tsx|js)"$/, '"'));
221
- await fs.outputFile(destination, content, "utf-8");
242
+ if (!(await fs.pathExists(destination)))
243
+ await fs.outputFile(destination, content, "utf-8");
222
244
  }
223
245
  const runtimeSources = [
224
- ["../../client/page-actions.js", "runtime/page-actions.js"],
225
- ["../../navigation/repository-links.js", "runtime/repository-links.js"],
226
- ["../../search/provider.js", "runtime/search-provider.js"],
246
+ [["../../../src/client/page-actions.ts", "../../vendor/docs-src/client/page-actions.ts"], "runtime/page-actions.ts"],
247
+ [["../../../src/navigation/repository-links.ts", "../../vendor/docs-src/navigation/repository-links.ts"], "runtime/repository-links.ts"],
248
+ [["../../../src/search/provider.ts", "../../vendor/docs-src/search/provider.ts"], "runtime/search-provider.ts"],
227
249
  ];
228
- for (const [relativeSource, relativeDestination] of runtimeSources) {
229
- const sourceFile = path.resolve(commandDir, relativeSource);
230
- if (!fs.existsSync(sourceFile))
250
+ for (const [relativeSources, relativeDestination] of runtimeSources) {
251
+ const sourceFile = relativeSources
252
+ .map((relativeSource) => path.resolve(commandDir, relativeSource))
253
+ .find((candidate) => fs.existsSync(candidate));
254
+ if (!sourceFile)
231
255
  continue;
232
256
  const destination = path.join(target, relativeDestination);
233
- const content = (await fs.readFile(sourceFile, "utf-8"))
234
- .replace(/from "\.\.\/types\.js"/g, 'from "@nikala-ui/folio"');
235
- await fs.outputFile(destination, content, "utf-8");
257
+ if (!(await fs.pathExists(destination))) {
258
+ const content = (await fs.readFile(sourceFile, "utf-8"))
259
+ .replace(/\s*\/\/[#@]\s*sourceMappingURL=.*$/gm, "")
260
+ .replace(/from "\.\.\/types\.js"/g, 'from "@nikala-ui/folio"');
261
+ await fs.outputFile(destination, content, "utf-8");
262
+ }
236
263
  }
237
264
  const navigationCandidates = [
238
265
  path.resolve(commandDir, "../../../src/navigation/sidebar-state.ts"),
239
- path.resolve(commandDir, "../../navigation/sidebar-state.js"),
266
+ path.resolve(commandDir, "../../vendor/docs-src/navigation/sidebar-state.ts"),
240
267
  ];
241
268
  const navigationSource = navigationCandidates.find((candidate) => fs.existsSync(candidate));
242
269
  if (navigationSource) {
243
270
  const navigationContent = (await fs.readFile(navigationSource, "utf-8"))
244
271
  .replace(/from "\.\.\/types\.js"/g, 'from "@nikala-ui/folio"');
245
- await fs.outputFile(path.join(target, "navigation/sidebar-state.ts"), navigationContent, "utf-8");
272
+ const navigationTarget = path.join(target, "navigation/sidebar-state.ts");
273
+ if (!(await fs.pathExists(navigationTarget)))
274
+ await fs.outputFile(navigationTarget, navigationContent, "utf-8");
246
275
  }
247
- // Remove stale references left by older generated themes so upgrading and
248
- // re-running init is enough to silence Vite's missing-map warnings.
249
- await stripSourceMapComments(target);
250
276
  }
251
277
  async function copyDefaultAssets(root) {
252
278
  const commandDir = path.dirname(fileURLToPath(import.meta.url));
@@ -262,11 +288,15 @@ async function copyDefaultAssets(root) {
262
288
  await fs.copy(source, destination);
263
289
  }
264
290
  async function writeProjectFiles(root, registryDependencies) {
291
+ const commandDir = path.dirname(fileURLToPath(import.meta.url));
265
292
  const docsConfigPath = path.join(root, "docs.config.ts");
266
293
  if (!(await fs.pathExists(docsConfigPath)))
267
- await fs.outputFile(docsConfigPath, `export default {
294
+ await fs.outputFile(docsConfigPath, `import { createI18nPlugin } from "./src/plugins/i18n/index.ts";
295
+
296
+ export default {
297
+ plugins: [createI18nPlugin({ defaultLocale: "en", locales: ["en"] })],
268
298
  title: "My Project Docs",
269
- description: "Documentation built with Folio and SolidJS",
299
+ description: "Documentation built with Folio",
270
300
  favicon: "/favicon.ico",
271
301
  contentDir: "docs",
272
302
  css: "src/index.css",
@@ -276,6 +306,17 @@ async function writeProjectFiles(root, registryDependencies) {
276
306
  search: { enabled: true },
277
307
  };
278
308
  `, "utf-8");
309
+ const localeTemplate = path.resolve(commandDir, "../../templates/locales/en.json");
310
+ const localePath = path.join(root, "locales/en.json");
311
+ if (!(await fs.pathExists(localePath)) && await fs.pathExists(localeTemplate)) {
312
+ await fs.ensureDir(path.dirname(localePath));
313
+ await fs.copyFile(localeTemplate, localePath);
314
+ }
315
+ const environmentTemplate = path.resolve(commandDir, "../../templates/env.d.ts");
316
+ const environmentPath = path.join(root, "src/env.d.ts");
317
+ if (!(await fs.pathExists(environmentPath)) && await fs.pathExists(environmentTemplate)) {
318
+ await fs.copyFile(environmentTemplate, environmentPath);
319
+ }
279
320
  const nikalaConfigPath = path.join(root, "nikala.config.json");
280
321
  if (!(await fs.pathExists(nikalaConfigPath))) {
281
322
  await fs.writeJson(nikalaConfigPath, {
@@ -291,7 +332,6 @@ async function writeProjectFiles(root, registryDependencies) {
291
332
  }, { spaces: 2 });
292
333
  }
293
334
  const packagePath = path.join(root, "package.json");
294
- const commandDir = path.dirname(fileURLToPath(import.meta.url));
295
335
  const docsPackageRoot = path.resolve(commandDir, "../../..");
296
336
  const workspaceRoot = path.resolve(docsPackageRoot, "../..");
297
337
  const workspaceManifestPath = path.join(workspaceRoot, "package.json");
@@ -304,7 +344,12 @@ async function writeProjectFiles(root, registryDependencies) {
304
344
  private: true,
305
345
  type: "module",
306
346
  scripts: { dev: "bunx @nikala-ui/folio dev", build: "bunx @nikala-ui/folio build", preview: "bunx @nikala-ui/folio preview" },
307
- dependencies: {},
347
+ dependencies: { "fs-extra": "^11.3.6" },
348
+ devDependencies: {
349
+ "@types/fs-extra": "latest",
350
+ "@types/node": "latest",
351
+ typescript: "latest",
352
+ },
308
353
  };
309
354
  const existingPackageJson = await fs.pathExists(packagePath) ? await fs.readJson(packagePath) : {};
310
355
  const packageJson = {
@@ -332,11 +377,18 @@ async function writeProjectFiles(root, registryDependencies) {
332
377
  .filter((dependency) => !packageJson.dependencies?.[dependency])
333
378
  .map((dependency) => [dependency, "latest"])),
334
379
  };
380
+ packageJson.devDependencies = {
381
+ ...defaultPackageJson.devDependencies,
382
+ ...existingPackageJson.devDependencies,
383
+ };
335
384
  await fs.writeJson(packagePath, packageJson, { spaces: 2 });
336
- await fs.outputFile(path.join(root, "tsconfig.json"), JSON.stringify({
337
- compilerOptions: { target: "ES2022", module: "ESNext", moduleResolution: "Bundler", jsx: "preserve", jsxImportSource: "solid-js", strict: true, skipLibCheck: true, paths: { "@/*": ["./src/*"], "@/components/ui/*": ["./src/components/ui/*"], "@/hooks/*": ["./src/hooks/*"] } },
338
- include: ["src/**/*", "docs.config.ts"],
339
- }, null, 2) + "\n", "utf-8");
385
+ const tsconfigPath = path.join(root, "tsconfig.json");
386
+ if (!(await fs.pathExists(tsconfigPath))) {
387
+ await fs.outputFile(tsconfigPath, JSON.stringify({
388
+ compilerOptions: { target: "ES2022", module: "ESNext", moduleResolution: "Bundler", jsx: "preserve", jsxImportSource: "solid-js", allowImportingTsExtensions: true, strict: true, skipLibCheck: true, paths: { "@/*": ["./src/*"], "@/components/*": ["./src/components/*"], "@/components/ui/*": ["./src/components/ui/*"], "@/hooks/*": ["./src/hooks/*"], "@/plugins/*": ["./src/plugins/*"] } },
389
+ include: ["src/**/*", "docs.config.ts"],
390
+ }, null, 2) + "\n", "utf-8");
391
+ }
340
392
  }
341
393
  export async function runInitCommand(targetDir = ".") {
342
394
  const root = path.resolve(process.cwd(), targetDir);
@@ -345,7 +397,8 @@ export async function runInitCommand(targetDir = ".") {
345
397
  console.log(pc.dim(` Initializing copy-paste documentation project in ${pc.bold(root)}...`));
346
398
  console.log();
347
399
  await fs.ensureDir(root);
348
- runNikalaInit(root);
400
+ if (!(await fs.pathExists(path.join(root, "src/lib/cn.ts"))))
401
+ runNikalaInit(root);
349
402
  await writeProjectFiles(root, []);
350
403
  const indexPath = path.join(root, "docs/index.mdx");
351
404
  if (!(await fs.pathExists(indexPath)))
@@ -364,13 +417,14 @@ Your Nikala UI components and reactive hooks are owned locally in **src/componen
364
417
  </Callout>
365
418
  `, "utf-8");
366
419
  await copyCustomTheme(root);
420
+ await copyPluginSources(root);
367
421
  await copyDefaultAssets(root);
368
422
  const copied = await copyRegistrySource(root);
369
423
  await writeProjectFiles(root, copied.dependencies);
370
424
  installProjectDependencies(root);
371
425
  console.log(` ${pc.green("✓")} Copied ${copied.componentFiles.length} UI sources and ${copied.hookFiles.length} hook sources`);
372
426
  console.log(` ${pc.green("✓")} Registered ${copied.dependencies.length} component dependencies`);
373
- console.log(` ${pc.green("✓")} Created ${pc.cyan("docs")}, ${pc.cyan("src/themes/default")}, and local Tailwind tokens`);
427
+ console.log(` ${pc.green("✓")} Created ${pc.cyan("docs")}, ${pc.cyan("src/plugins")}, ${pc.cyan("src/themes/default")}, and local Tailwind tokens`);
374
428
  console.log();
375
429
  console.log(` ${pc.bold(pc.green("Success!"))} Run ${pc.cyan("bunx @nikala-ui/folio dev")} to start your docs.`);
376
430
  console.log();
@@ -4,6 +4,7 @@ import { DocsLayoutShell } from "./components/docs-layout-shell.jsx";
4
4
  import { DocsPageContent } from "./components/docs-page-content.jsx";
5
5
  import { createPageNavigation } from "./navigation/page-navigation.js";
6
6
  import { createDocsRouter } from "./routing/use-docs-router.js";
7
+ import { SiteLocaleProvider } from "../plugins/i18n/runtime.jsx";
7
8
  // @ts-ignore
8
9
  import rawConfig from "virtual:folio-config";
9
10
  // @ts-ignore
@@ -44,7 +45,9 @@ export const App = (props) => {
44
45
  });
45
46
  }
46
47
  const navigation = createPageNavigation(router.currentPage, allPages, sidebarTree);
47
- return (<DocsLayoutShell config={config} tree={sidebarTree} pages={allPages} currentPage={router.currentPage()} breadcrumbs={navigation.breadcrumbs()} toc={router.activePageModule() ? navigation.toc() : []} prev={navigation.prevPage()} next={navigation.nextPage()} sourceContent={sourceContent()}>
48
- <DocsPageContent pageModule={router.activePageModule} mdxComponents={props.mdxComponents || defaultMdxComponents}/>
49
- </DocsLayoutShell>);
48
+ return (<SiteLocaleProvider config={config.uiLocale} pages={allPages} currentPage={router.currentPage()} currentPath={router.currentPage()?.url} onNavigate={router.navigate}>
49
+ <DocsLayoutShell config={config} tree={sidebarTree} pages={allPages} currentPage={router.currentPage()} onNavigate={router.navigate} breadcrumbs={navigation.breadcrumbs()} toc={router.activePageModule() ? navigation.toc() : []} prev={navigation.prevPage()} next={navigation.nextPage()} sourceContent={sourceContent()}>
50
+ <DocsPageContent pageModule={router.activePageModule} mdxComponents={props.mdxComponents || defaultMdxComponents}/>
51
+ </DocsLayoutShell>
52
+ </SiteLocaleProvider>);
50
53
  };
@@ -6,6 +6,7 @@ interface DocsLayoutShellProps {
6
6
  tree: SidebarItem[];
7
7
  pages: PageData[];
8
8
  currentPage: PageData | undefined;
9
+ onNavigate: (url: string) => void;
9
10
  breadcrumbs: BreadcrumbItemData[];
10
11
  toc: TocItem[];
11
12
  prev: {
@@ -7,7 +7,7 @@ export const DocsLayoutShell = (props) => {
7
7
  if (!ThemeProvider)
8
8
  throw new Error("Folio theme must provide a ThemeProvider");
9
9
  return (<ThemeProvider defaultTheme={resolveDefaultThemeMode(props.config)} storageKey="nikala-theme">
10
- <configuredTheme.Layout config={props.config} tree={props.tree} pages={props.pages} currentPage={props.currentPage} breadcrumbs={props.breadcrumbs} toc={props.toc} prev={props.prev} next={props.next} sourceContent={props.sourceContent}>
10
+ <configuredTheme.Layout config={props.config} tree={props.tree} pages={props.pages} currentPage={props.currentPage} onNavigate={props.onNavigate} breadcrumbs={props.breadcrumbs} toc={props.toc} prev={props.prev} next={props.next} sourceContent={props.sourceContent}>
11
11
  {props.children}
12
12
  </configuredTheme.Layout>
13
13
  </ThemeProvider>);
@@ -1,9 +1,13 @@
1
1
  import { Show } from "solid-js";
2
- export const DocsPageContent = (props) => (<Show when={props.pageModule() !== null} fallback={<div class="p-8 text-sm text-muted-foreground">Loading documentation...</div>}>
3
- <Show keyed when={props.pageModule()} fallback={<div class="space-y-4 py-8"><h1 class="text-2xl font-bold">Page Not Found</h1><p class="text-muted-foreground text-sm">The documentation article could not be found.</p></div>}>
2
+ import { useSiteLocale } from "../../plugins/i18n/runtime.jsx";
3
+ export const DocsPageContent = (props) => {
4
+ const siteLocale = useSiteLocale();
5
+ return (<Show when={props.pageModule() !== null} fallback={<div class="p-8 text-sm text-muted-foreground">{siteLocale.t("status.loading")}</div>}>
6
+ <Show keyed when={props.pageModule()} fallback={<div class="space-y-4 py-8"><h1 class="text-2xl font-bold">{siteLocale.t("errors.pageNotFound")}</h1><p class="text-muted-foreground text-sm">{siteLocale.t("errors.pageNotFoundDescription")}</p></div>}>
4
7
  {(module) => {
5
- const Page = module.default;
6
- return <Page components={props.mdxComponents}/>;
7
- }}
8
+ const Page = module.default;
9
+ return <Page components={props.mdxComponents}/>;
10
+ }}
8
11
  </Show>
9
12
  </Show>);
13
+ };
@@ -1,13 +1,16 @@
1
1
  import { createMemo } from "solid-js";
2
- import { flattenSidebarItems } from "../utils/sidebar.js";
2
+ import { buildPagination } from "../../core/route-tree.js";
3
3
  export function createPageNavigation(currentPage, pages, sidebarTree) {
4
4
  const breadcrumbs = createMemo(() => {
5
5
  const page = currentPage();
6
6
  if (!page)
7
7
  return [];
8
- const segments = page.url.split("/").filter(Boolean);
8
+ const allSegments = page.url.split("/").filter(Boolean);
9
+ const locale = typeof page.frontmatter.locale === "string" ? page.frontmatter.locale : undefined;
10
+ const hasLocalePrefix = Boolean(locale && allSegments[0] === locale);
11
+ const segments = hasLocalePrefix ? allSegments.slice(1) : allSegments;
9
12
  const items = [{ title: "Docs", href: "/" }];
10
- let accumulated = "";
13
+ let accumulated = hasLocalePrefix ? `/${locale}` : "";
11
14
  for (let index = 0; index < segments.length; index++) {
12
15
  accumulated += `/${segments[index]}`;
13
16
  const isLast = index === segments.length - 1;
@@ -20,31 +23,11 @@ export function createPageNavigation(currentPage, pages, sidebarTree) {
20
23
  return items;
21
24
  });
22
25
  const toc = createMemo(() => currentPage()?.toc || []);
23
- const flatPages = createMemo(() => {
24
- const visiblePages = new Map(pages.filter((page) => page.frontmatter?.hidden !== true).map((page) => [page.url, page]));
25
- return flattenSidebarItems(sidebarTree).map((item) => visiblePages.get(item.href)).filter((page) => Boolean(page));
26
- });
27
- const prevPage = createMemo(() => {
26
+ const pagination = createMemo(() => {
28
27
  const page = currentPage();
29
- if (!page)
30
- return undefined;
31
- const ordered = flatPages();
32
- const index = ordered.findIndex((item) => item.url === page.url);
33
- if (index <= 0)
34
- return undefined;
35
- const previous = ordered[index - 1];
36
- return { title: previous.title, href: previous.url };
37
- });
38
- const nextPage = createMemo(() => {
39
- const page = currentPage();
40
- if (!page)
41
- return undefined;
42
- const ordered = flatPages();
43
- const index = ordered.findIndex((item) => item.url === page.url);
44
- if (index < 0 || index >= ordered.length - 1)
45
- return undefined;
46
- const next = ordered[index + 1];
47
- return { title: next.title, href: next.url };
28
+ return page ? buildPagination(pages, page.url, sidebarTree) : {};
48
29
  });
30
+ const prevPage = createMemo(() => pagination().prev);
31
+ const nextPage = createMemo(() => pagination().next);
49
32
  return { breadcrumbs, toc, prevPage, nextPage };
50
33
  }
@@ -0,0 +1,15 @@
1
+ <svg width="77" height="19" aria-label="Algolia" role="img" id="Layer_1"
2
+ xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2196.2 500">
3
+ <defs>
4
+ <style>.cls-1,.cls-2{fill:#cacdd2;}.cls-2{fill-rule:evenodd;}</style>
5
+ </defs>
6
+ <path class="cls-2" d="M1070.38,275.3V5.91c0-3.63-3.24-6.39-6.82-5.83l-50.46,7.94c-2.87,.45-4.99,2.93-4.99,5.84l.17,273.22c0,12.92,0,92.7,95.97,95.49,3.33,.1,6.09-2.58,6.09-5.91v-40.78c0-2.96-2.19-5.51-5.12-5.84-34.85-4.01-34.85-47.57-34.85-54.72Z"></path>
7
+ <rect class="cls-1" x="1845.88" y="104.73" width="62.58" height="277.9" rx="5.9" ry="5.9"></rect>
8
+ <path class="cls-2" d="M1851.78,71.38h50.77c3.26,0,5.9-2.64,5.9-5.9V5.9c0-3.62-3.24-6.39-6.82-5.83l-50.77,7.95c-2.87,.45-4.99,2.92-4.99,5.83v51.62c0,3.26,2.64,5.9,5.9,5.9Z"></path>
9
+ <path class="cls-2" d="M1764.03,275.3V5.91c0-3.63-3.24-6.39-6.82-5.83l-50.46,7.94c-2.87,.45-4.99,2.93-4.99,5.84l.17,273.22c0,12.92,0,92.7,95.97,95.49,3.33,.1,6.09-2.58,6.09-5.91v-40.78c0-2.96-2.19-5.51-5.12-5.84-34.85-4.01-34.85-47.57-34.85-54.72Z"></path>
10
+ <path class="cls-2" d="M1631.95,142.72c-11.14-12.25-24.83-21.65-40.78-28.31-15.92-6.53-33.26-9.85-52.07-9.85-18.78,0-36.15,3.17-51.92,9.85-15.59,6.66-29.29,16.05-40.76,28.31-11.47,12.23-20.38,26.87-26.76,44.03-6.38,17.17-9.24,37.37-9.24,58.36,0,20.99,3.19,36.87,9.55,54.21,6.38,17.32,15.14,32.11,26.45,44.36,11.29,12.23,24.83,21.62,40.6,28.46,15.77,6.83,40.12,10.33,52.4,10.48,12.25,0,36.78-3.82,52.7-10.48,15.92-6.68,29.46-16.23,40.78-28.46,11.29-12.25,20.05-27.04,26.25-44.36,6.22-17.34,9.24-33.22,9.24-54.21,0-20.99-3.34-41.19-10.03-58.36-6.38-17.17-15.14-31.8-26.43-44.03Zm-44.43,163.75c-11.47,15.75-27.56,23.7-48.09,23.7-20.55,0-36.63-7.8-48.1-23.7-11.47-15.75-17.21-34.01-17.21-61.2,0-26.89,5.59-49.14,17.06-64.87,11.45-15.75,27.54-23.52,48.07-23.52,20.55,0,36.63,7.78,48.09,23.52,11.47,15.57,17.36,37.98,17.36,64.87,0,27.19-5.72,45.3-17.19,61.2Z"></path>
11
+ <path class="cls-2" d="M894.42,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-14.52,22.58-22.99,49.63-22.99,78.73,0,44.89,20.13,84.92,51.59,111.1,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47,1.23,0,2.46-.03,3.68-.09,.36-.02,.71-.05,1.07-.07,.87-.05,1.75-.11,2.62-.2,.34-.03,.68-.08,1.02-.12,.91-.1,1.82-.21,2.73-.34,.21-.03,.42-.07,.63-.1,32.89-5.07,61.56-30.82,70.9-62.81v57.83c0,3.26,2.64,5.9,5.9,5.9h50.42c3.26,0,5.9-2.64,5.9-5.9V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,206.92c-12.2,10.16-27.97,13.98-44.84,15.12-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-42.24,0-77.12-35.89-77.12-79.37,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33v142.83Z"></path>
12
+ <path class="cls-2" d="M2133.97,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-14.52,22.58-22.99,49.63-22.99,78.73,0,44.89,20.13,84.92,51.59,111.1,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47,1.23,0,2.46-.03,3.68-.09,.36-.02,.71-.05,1.07-.07,.87-.05,1.75-.11,2.62-.2,.34-.03,.68-.08,1.02-.12,.91-.1,1.82-.21,2.73-.34,.21-.03,.42-.07,.63-.1,32.89-5.07,61.56-30.82,70.9-62.81v57.83c0,3.26,2.64,5.9,5.9,5.9h50.42c3.26,0,5.9-2.64,5.9-5.9V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,206.92c-12.2,10.16-27.97,13.98-44.84,15.12-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-42.24,0-77.12-35.89-77.12-79.37,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33v142.83Z"></path>
13
+ <path class="cls-2" d="M1314.05,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-11.79,18.34-19.6,39.64-22.11,62.59-.58,5.3-.88,10.68-.88,16.14s.31,11.15,.93,16.59c4.28,38.09,23.14,71.61,50.66,94.52,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47h0c17.99,0,34.61-5.93,48.16-15.97,16.29-11.58,28.88-28.54,34.48-47.75v50.26h-.11v11.08c0,21.84-5.71,38.27-17.34,49.36-11.61,11.08-31.04,16.63-58.25,16.63-11.12,0-28.79-.59-46.6-2.41-2.83-.29-5.46,1.5-6.27,4.22l-12.78,43.11c-1.02,3.46,1.27,7.02,4.83,7.53,21.52,3.08,42.52,4.68,54.65,4.68,48.91,0,85.16-10.75,108.89-32.21,21.48-19.41,33.15-48.89,35.2-88.52V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,64.1s.65,139.13,0,143.36c-12.08,9.77-27.11,13.59-43.49,14.7-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-1.32,0-2.63-.03-3.94-.1-40.41-2.11-74.52-37.26-74.52-79.38,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33Z"></path>
14
+ <path class="cls-1" d="M249.83,0C113.3,0,2,110.09,.03,246.16c-2,138.19,110.12,252.7,248.33,253.5,42.68,.25,83.79-10.19,120.3-30.03,3.56-1.93,4.11-6.83,1.08-9.51l-23.38-20.72c-4.75-4.21-11.51-5.4-17.36-2.92-25.48,10.84-53.17,16.38-81.71,16.03-111.68-1.37-201.91-94.29-200.13-205.96,1.76-110.26,92-199.41,202.67-199.41h202.69V407.41l-115-102.18c-3.72-3.31-9.42-2.66-12.42,1.31-18.46,24.44-48.53,39.64-81.93,37.34-46.33-3.2-83.87-40.5-87.34-86.81-4.15-55.24,39.63-101.52,94-101.52,49.18,0,89.68,37.85,93.91,85.95,.38,4.28,2.31,8.27,5.52,11.12l29.95,26.55c3.4,3.01,8.79,1.17,9.63-3.3,2.16-11.55,2.92-23.58,2.07-35.92-4.82-70.34-61.8-126.93-132.17-131.26-80.68-4.97-148.13,58.14-150.27,137.25-2.09,77.1,61.08,143.56,138.19,145.26,32.19,.71,62.03-9.41,86.14-26.95l150.26,133.2c6.44,5.71,16.61,1.14,16.61-7.47V9.48C499.66,4.25,495.42,0,490.18,0H249.83Z"></path>
15
+ </svg>
Binary file
@@ -0,0 +1,11 @@
1
+ <svg width="111" height="134" viewBox="0 0 111 134" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path
3
+ d="M36.1777 0.00543119C36.9886 0.00499311 37.7994 0.00455503 38.6349 0.00410368C41.2808 0.00617229 43.9262 0.0294108 46.572 0.0530386C48.42 0.0586414 50.268 0.0629083 52.1161 0.0659018C56.9543 0.0772964 61.7923 0.106717 66.6305 0.140014C71.5778 0.170831 76.5251 0.184432 81.4724 0.199523C91.1607 0.231592 100.849 0.282723 110.537 0.346007C110.61 3.53599 110.654 6.72575 110.693 9.91632C110.725 11.2608 110.725 11.2608 110.757 12.6324C110.828 20.4476 109.466 26.0515 104.537 32.346C98.5344 38.2899 92.6817 40.5932 84.2432 40.6014C83.527 40.605 82.8108 40.6086 82.0729 40.6124C80.5233 40.6192 78.9737 40.6218 77.4242 40.6204C74.9635 40.6194 72.5033 40.6324 70.0426 40.6494C63.0485 40.6955 56.0544 40.7202 49.06 40.7269C44.7747 40.7319 40.4898 40.7563 36.2046 40.7922C34.5801 40.8019 32.9555 40.8044 31.331 40.799C19.2921 40.7614 9.61779 41.743 0.536854 50.346C0.448685 46.7003 0.396074 43.0549 0.349354 39.4085C0.324217 38.3869 0.29908 37.3653 0.273182 36.3128C0.173253 25.8869 2.62732 17.3394 9.53685 9.34601C17.2641 2.66649 26.0794 -0.141013 36.1777 0.00543119Z"
4
+ fill="#00ade4" />
5
+ <path
6
+ d="M22.0491 48.169C22.9608 48.1562 23.8725 48.1434 24.8118 48.1301C26.2884 48.119 26.2884 48.119 27.7947 48.1077C28.8123 48.0997 29.83 48.0916 30.8784 48.0833C33.0354 48.0694 35.1924 48.0587 37.3494 48.0509C40.6285 48.0337 43.9065 47.9898 47.1853 47.9456C49.2843 47.9355 51.3833 47.927 53.4822 47.9202C54.4544 47.9027 55.4266 47.8852 56.4283 47.8672C63.3556 47.889 69.7844 49.012 75.1263 53.7582C79.2822 58.4605 81.032 62.8674 80.8533 69.1585C80.0863 74.4616 77.9359 78.9471 74.1619 82.721C73.2957 83.2573 72.4294 83.7935 71.5369 84.346C70.7322 84.8676 69.9275 85.3892 69.0984 85.9266C64.0178 87.9514 59.3464 87.7288 53.9275 87.682C51.6228 87.6945 49.3182 87.7075 47.0135 87.721C43.4017 87.7249 39.7902 87.721 36.1785 87.7064C32.6778 87.6978 29.1782 87.7196 25.6775 87.7445C24.6105 87.7311 23.5435 87.7178 22.4442 87.704C13.6607 87.7897 7.75397 90.5347 0.536912 95.346C0.386963 91.1144 0.278963 86.8842 0.207322 82.6507C0.177416 81.2152 0.136674 79.7799 0.0842755 78.345C-0.242774 69.1492 0.0895104 61.5914 6.53691 54.346C11.3525 50.524 15.8248 48.2455 22.0491 48.169Z"
7
+ fill="#00ade4" />
8
+ <path
9
+ d="M20.8612 95.2484C21.8892 95.2516 22.9173 95.2548 23.9764 95.2581C25.5842 95.2707 25.5842 95.2707 27.2245 95.2835C28.3079 95.288 29.3914 95.2926 30.5077 95.2972C33.1842 95.309 35.8606 95.3255 38.537 95.346C38.6543 99.0124 38.7246 102.678 38.787 106.346C38.8205 107.376 38.854 108.406 38.8885 109.467C38.9806 116.694 38.1397 122.373 33.1595 127.865C28.2702 132.292 23.1029 133.85 16.5526 133.662C10.763 132.754 6.1827 128.721 2.53699 124.346C0.114874 119.156 -0.478718 113.766 1.15417 108.268C3.56015 102.689 7.36624 99.4145 12.537 96.346C15.5962 95.3263 17.6612 95.2307 20.8612 95.2484Z"
10
+ fill="#00ade4" />
11
+ </svg>
@@ -11,6 +11,7 @@ export interface DocsRouter {
11
11
  pathname: Accessor<string>;
12
12
  currentPage: Accessor<PageData | undefined>;
13
13
  activePageModule: Accessor<PageModule | null | undefined>;
14
+ navigate: (url: string) => void;
14
15
  }
15
16
  export declare function createDocsRouter(options: DocsRouterOptions): DocsRouter;
16
17
  export {};
@@ -2,6 +2,16 @@ import { createEffect, createMemo, createSignal, onCleanup, onMount } from "soli
2
2
  const normalizePath = (path) => path.replace(/\/$/, "") || "/";
3
3
  export function createDocsRouter(options) {
4
4
  const [pathname, setPathname] = createSignal(options.initialPath || (typeof window !== "undefined" ? window.location.pathname : "/"));
5
+ const navigate = (url) => {
6
+ if (typeof window === "undefined")
7
+ return;
8
+ const target = new URL(url, window.location.origin);
9
+ if (target.origin !== window.location.origin)
10
+ return;
11
+ window.history.pushState(null, "", `${target.pathname}${target.search}${target.hash}`);
12
+ setPathname(target.pathname);
13
+ window.scrollTo({ top: 0, behavior: "instant" });
14
+ };
5
15
  onMount(() => {
6
16
  const handlePopState = () => setPathname(window.location.pathname);
7
17
  const handleAnchorClick = (event) => {
@@ -24,8 +34,7 @@ export function createDocsRouter(options) {
24
34
  if (url.origin !== window.location.origin)
25
35
  return;
26
36
  event.preventDefault();
27
- setPathname(url.pathname);
28
- window.history.pushState(null, "", href);
37
+ navigate(href);
29
38
  if (url.hash) {
30
39
  const element = document.getElementById(url.hash.slice(1));
31
40
  if (element) {
@@ -82,5 +91,5 @@ export function createDocsRouter(options) {
82
91
  setLoadedPageModule(undefined);
83
92
  });
84
93
  });
85
- return { pathname, currentPage, activePageModule: loadedPageModule };
94
+ return { pathname, currentPage, activePageModule: loadedPageModule, navigate };
86
95
  }