@nikala-ui/folio 0.13.2 → 0.15.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/README.md +16 -0
- package/dist/cli/commands/init.js +37 -2
- package/dist/client/app.jsx +6 -3
- package/dist/client/components/docs-layout-shell.d.ts +1 -0
- package/dist/client/components/docs-layout-shell.jsx +1 -1
- package/dist/client/components/docs-page-content.jsx +9 -5
- package/dist/client/navigation/page-navigation.js +10 -27
- package/dist/client/public/algolia-logo.svg +15 -0
- package/dist/client/public/favicon.ico +0 -0
- package/dist/client/public/logo.svg +11 -0
- package/dist/client/routing/use-docs-router.d.ts +1 -0
- package/dist/client/routing/use-docs-router.js +12 -3
- package/dist/client/style.css +139 -55
- package/dist/components/mdx-components.jsx +4 -1
- package/dist/components/ui/api-table.jsx +6 -4
- package/dist/components/ui/code-block.jsx +6 -4
- package/dist/components/ui/command.jsx +9 -5
- package/dist/components/ui/list.jsx +3 -1
- package/dist/components/ui/logo.d.ts +4 -1
- package/dist/components/ui/logo.jsx +8 -22
- package/dist/components/ui/package-manager-tabs.jsx +12 -2
- package/dist/components/ui/pager.jsx +4 -2
- package/dist/components/ui/section-heading.jsx +1 -1
- package/dist/components/ui/sidebar.jsx +6 -3
- package/dist/components/ui/spinner.jsx +3 -1
- package/dist/components/ui/theme-toggle.jsx +14 -12
- package/dist/config.d.ts +1 -0
- package/dist/config.js +84 -29
- package/dist/core/content-scanner.d.ts +2 -1
- package/dist/core/content-scanner.js +2 -9
- package/dist/core/plugin/index.d.ts +2 -0
- package/dist/core/plugin/index.js +1 -0
- package/dist/core/plugin/lifecycle-error.d.ts +19 -0
- package/dist/core/plugin/lifecycle-error.js +28 -0
- package/dist/core/plugin/lifecycle-snapshot.d.ts +1 -0
- package/dist/core/plugin/lifecycle-snapshot.js +156 -0
- package/dist/core/plugin/lifecycle.d.ts +34 -0
- package/dist/core/plugin/lifecycle.js +170 -0
- package/dist/core/route-tree.d.ts +3 -2
- package/dist/core/route-tree.js +40 -10
- package/dist/index.d.ts +7 -3
- package/dist/index.js +4 -3
- package/dist/plugin.d.ts +60 -0
- package/dist/plugin.js +51 -0
- package/dist/plugins/i18n/components/site-language-switcher.d.ts +10 -0
- package/dist/plugins/i18n/components/site-language-switcher.jsx +39 -0
- package/dist/plugins/i18n/constants.d.ts +1 -0
- package/dist/plugins/i18n/constants.js +1 -0
- package/dist/plugins/i18n/index.d.ts +11 -0
- package/dist/plugins/i18n/index.js +89 -0
- package/dist/plugins/i18n/navigation.d.ts +5 -0
- package/dist/plugins/i18n/navigation.js +33 -0
- package/dist/plugins/i18n/runtime.d.ts +19 -0
- package/dist/plugins/i18n/runtime.jsx +65 -0
- package/dist/plugins/i18n/site-locale.d.ts +12 -0
- package/dist/plugins/i18n/site-locale.js +119 -0
- package/dist/search/provider.d.ts +16 -4
- package/dist/search/provider.js +28 -3
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.js +73 -33
- package/dist/server/module-serialization.d.ts +6 -0
- package/dist/server/module-serialization.js +26 -0
- package/dist/server/plugin/components.d.ts +7 -0
- package/dist/server/plugin/components.js +82 -0
- package/dist/server/plugin/constants.d.ts +17 -0
- package/dist/server/plugin/constants.js +21 -0
- package/dist/server/{plugin.d.ts → plugin/index.d.ts} +3 -1
- package/dist/server/plugin/index.js +166 -0
- package/dist/server/plugin/lifecycle.d.ts +32 -0
- package/dist/server/plugin/lifecycle.js +110 -0
- package/dist/server/plugin/styles.d.ts +3 -0
- package/dist/server/plugin/styles.js +22 -0
- package/dist/server/plugin/virtual-modules.d.ts +11 -0
- package/dist/server/plugin/virtual-modules.js +88 -0
- package/dist/server/seo.d.ts +4 -0
- package/dist/server/seo.js +87 -0
- package/dist/themes/default/content/breadcrumbs.jsx +5 -2
- package/dist/themes/default/content/table-of-contents.jsx +3 -1
- package/dist/themes/default/layout.jsx +42 -14
- package/dist/themes/default/navbar.jsx +14 -7
- package/dist/themes/default/navigation/mobile-table-of-contents.jsx +3 -1
- package/dist/themes/default/navigation/sidebar-tree.d.ts +2 -0
- package/dist/themes/default/navigation/sidebar-tree.jsx +11 -2
- package/dist/themes/default/overlays/search-dialog.jsx +37 -11
- package/dist/themes/default/sidebar.jsx +7 -5
- package/dist/themes/types.d.ts +7 -2
- package/dist/types.d.ts +38 -1
- package/dist/utils/format-title.d.ts +1 -0
- package/dist/utils/format-title.js +11 -0
- package/dist/vendor/docs-src/components/mdx-components.tsx +4 -1
- package/dist/vendor/docs-src/components/ui/api-table.tsx +6 -4
- package/dist/vendor/docs-src/components/ui/code-block.tsx +6 -4
- package/dist/vendor/docs-src/components/ui/command.tsx +9 -5
- package/dist/vendor/docs-src/components/ui/list.tsx +4 -2
- package/dist/vendor/docs-src/components/ui/logo.tsx +19 -48
- package/dist/vendor/docs-src/components/ui/package-manager-tabs.tsx +12 -2
- package/dist/vendor/docs-src/components/ui/pager.tsx +4 -2
- package/dist/vendor/docs-src/components/ui/section-heading.tsx +5 -1
- package/dist/vendor/docs-src/components/ui/sidebar.tsx +7 -4
- package/dist/vendor/docs-src/components/ui/spinner.tsx +3 -1
- package/dist/vendor/docs-src/components/ui/theme-toggle.tsx +15 -13
- package/dist/vendor/docs-src/plugins/i18n/components/site-language-switcher.tsx +56 -0
- package/dist/vendor/docs-src/plugins/i18n/constants.ts +1 -0
- package/dist/vendor/docs-src/plugins/i18n/index.ts +110 -0
- package/dist/vendor/docs-src/plugins/i18n/navigation.ts +49 -0
- package/dist/vendor/docs-src/plugins/i18n/runtime.tsx +91 -0
- package/dist/vendor/docs-src/plugins/i18n/site-locale.ts +140 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +19 -4
- package/dist/server/plugin.js +0 -521
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
|
|
4
|
+
export { SITE_LOCALE_STORAGE_KEY } from "./constants.js";
|
|
5
|
+
|
|
6
|
+
export const SITE_TRANSLATION_KEYS = [
|
|
7
|
+
"navigation.search",
|
|
8
|
+
"navigation.searchLabel",
|
|
9
|
+
"navigation.toggleSidebar",
|
|
10
|
+
"navigation.closeSidebar",
|
|
11
|
+
"navigation.documentation",
|
|
12
|
+
"navigation.primary",
|
|
13
|
+
"navigation.github",
|
|
14
|
+
"navigation.chooseLanguage",
|
|
15
|
+
"navigation.toggleNavigation",
|
|
16
|
+
"navigation.toggleSidebarRail",
|
|
17
|
+
"navigation.sidebar",
|
|
18
|
+
"navigation.collapse",
|
|
19
|
+
"navigation.expand",
|
|
20
|
+
"navigation.breadcrumb",
|
|
21
|
+
"actions.viewSource",
|
|
22
|
+
"actions.copyPage",
|
|
23
|
+
"actions.copyAsMarkdown",
|
|
24
|
+
"actions.learnMore",
|
|
25
|
+
"actions.copyDocumentationPage",
|
|
26
|
+
"actions.openInProvider",
|
|
27
|
+
"actions.copied",
|
|
28
|
+
"actions.prompt",
|
|
29
|
+
"actions.copyContext",
|
|
30
|
+
"actions.copyCliCommand",
|
|
31
|
+
"actions.copyCode",
|
|
32
|
+
"actions.exitFullscreen",
|
|
33
|
+
"actions.expandFullscreen",
|
|
34
|
+
"tableOfContents.title",
|
|
35
|
+
"search.placeholder",
|
|
36
|
+
"search.empty",
|
|
37
|
+
"search.pages",
|
|
38
|
+
"search.by",
|
|
39
|
+
"search.commandPlaceholder",
|
|
40
|
+
"search.noResults",
|
|
41
|
+
"pagination.previous",
|
|
42
|
+
"pagination.next",
|
|
43
|
+
"theme.toggle",
|
|
44
|
+
"theme.light",
|
|
45
|
+
"theme.dark",
|
|
46
|
+
"theme.system",
|
|
47
|
+
"theme.mode",
|
|
48
|
+
"theme.brandAccentColor",
|
|
49
|
+
"theme.borderRadius",
|
|
50
|
+
"viewer.preview",
|
|
51
|
+
"viewer.code",
|
|
52
|
+
"viewer.desktopViewport",
|
|
53
|
+
"viewer.tabletViewport",
|
|
54
|
+
"viewer.mobileViewport",
|
|
55
|
+
"viewer.desktopSize",
|
|
56
|
+
"viewer.tabletSize",
|
|
57
|
+
"viewer.mobileSize",
|
|
58
|
+
"viewer.toggleBackgroundGrid",
|
|
59
|
+
"viewer.canvasGrid",
|
|
60
|
+
"viewer.resetPreviewCanvas",
|
|
61
|
+
"viewer.resetCanvas",
|
|
62
|
+
"viewer.copyAiContext",
|
|
63
|
+
"viewer.copyCodeForAi",
|
|
64
|
+
"viewer.copyCliInstallation",
|
|
65
|
+
"viewer.fullscreenPreview",
|
|
66
|
+
"viewer.exitFullscreen",
|
|
67
|
+
"code.copied",
|
|
68
|
+
"code.copy",
|
|
69
|
+
"command.navigate",
|
|
70
|
+
"command.select",
|
|
71
|
+
"command.close",
|
|
72
|
+
"image.avatar",
|
|
73
|
+
"status.loading",
|
|
74
|
+
"status.loadingLabel",
|
|
75
|
+
"accessibility.callout",
|
|
76
|
+
"errors.pageNotFound",
|
|
77
|
+
"errors.pageNotFoundDescription",
|
|
78
|
+
"apiTable.property",
|
|
79
|
+
"apiTable.type",
|
|
80
|
+
"apiTable.default",
|
|
81
|
+
"apiTable.description",
|
|
82
|
+
] as const;
|
|
83
|
+
|
|
84
|
+
export type SiteTranslationKey = (typeof SITE_TRANSLATION_KEYS)[number];
|
|
85
|
+
export type SiteTranslations = Record<SiteTranslationKey, string>;
|
|
86
|
+
|
|
87
|
+
export interface DocsUiLocaleConfig {
|
|
88
|
+
defaultLocale?: string;
|
|
89
|
+
directory?: string;
|
|
90
|
+
locale?: string;
|
|
91
|
+
translations?: Record<string, Partial<SiteTranslations>>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const KEY_SET = new Set<string>(SITE_TRANSLATION_KEYS);
|
|
95
|
+
|
|
96
|
+
function validateLocale(locale: string, value: unknown): Partial<SiteTranslations> {
|
|
97
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
98
|
+
throw new Error(`[folio] Translation file for locale "${locale}" must contain a JSON object`);
|
|
99
|
+
}
|
|
100
|
+
const entries = Object.entries(value);
|
|
101
|
+
for (const [key, translation] of entries) {
|
|
102
|
+
if (!KEY_SET.has(key)) throw new Error(`[folio] Unknown site translation key "${key}" in locale "${locale}"`);
|
|
103
|
+
if (typeof translation !== "string") throw new Error(`[folio] Translation "${locale}.${key}" must be a string`);
|
|
104
|
+
}
|
|
105
|
+
return value as Partial<SiteTranslations>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export async function loadSiteTranslations(
|
|
109
|
+
rootDir: string,
|
|
110
|
+
config: DocsUiLocaleConfig = {},
|
|
111
|
+
): Promise<DocsUiLocaleConfig> {
|
|
112
|
+
const defaultLocale = config.defaultLocale || "en";
|
|
113
|
+
const directory = config.directory || "locales";
|
|
114
|
+
const localeDir = path.resolve(rootDir, directory);
|
|
115
|
+
const translations: Record<string, Partial<SiteTranslations>> = {};
|
|
116
|
+
|
|
117
|
+
if (await fs.pathExists(localeDir)) {
|
|
118
|
+
const files = (await fs.readdir(localeDir))
|
|
119
|
+
.filter((file) => file.endsWith(".json"))
|
|
120
|
+
.sort();
|
|
121
|
+
for (const file of files) {
|
|
122
|
+
const locale = path.basename(file, ".json");
|
|
123
|
+
translations[locale] = validateLocale(locale, await fs.readJson(path.join(localeDir, file)));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!translations[defaultLocale]) translations[defaultLocale] = {};
|
|
128
|
+
return { ...config, defaultLocale, directory, locale: config.locale || defaultLocale, translations };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function getSiteTranslation(
|
|
132
|
+
config: DocsUiLocaleConfig | undefined,
|
|
133
|
+
key: SiteTranslationKey,
|
|
134
|
+
): string {
|
|
135
|
+
const locale = config?.locale || config?.defaultLocale || "en";
|
|
136
|
+
const defaultLocale = config?.defaultLocale || "en";
|
|
137
|
+
return config?.translations?.[locale]?.[key]
|
|
138
|
+
|| config?.translations?.[defaultLocale]?.[key]
|
|
139
|
+
|| key;
|
|
140
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const FOLIO_VERSION = "0.
|
|
1
|
+
export declare const FOLIO_VERSION = "0.15.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const FOLIO_VERSION = "0.
|
|
1
|
+
export const FOLIO_VERSION = "0.15.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nikala-ui/folio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Zero-config, fast, and elegant documentation engine for SolidJS, built on Nikala UI and Tailwind CSS v4",
|
|
6
6
|
"type": "module",
|
|
@@ -15,8 +15,16 @@
|
|
|
15
15
|
"import": "./dist/index.js"
|
|
16
16
|
},
|
|
17
17
|
"./plugin": {
|
|
18
|
-
"types": "./dist/server/plugin.d.ts",
|
|
19
|
-
"import": "./dist/server/plugin.js"
|
|
18
|
+
"types": "./dist/server/plugin/index.d.ts",
|
|
19
|
+
"import": "./dist/server/plugin/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./config": {
|
|
22
|
+
"types": "./dist/config.d.ts",
|
|
23
|
+
"import": "./dist/config.js"
|
|
24
|
+
},
|
|
25
|
+
"./content": {
|
|
26
|
+
"types": "./dist/core/content-scanner.d.ts",
|
|
27
|
+
"import": "./dist/core/content-scanner.js"
|
|
20
28
|
},
|
|
21
29
|
"./theme": {
|
|
22
30
|
"types": "./dist/themes/default/index.d.ts",
|
|
@@ -45,7 +53,11 @@
|
|
|
45
53
|
"typecheck": "bunx tsc --noEmit -p tsconfig.json",
|
|
46
54
|
"test": "bun test tests",
|
|
47
55
|
"test:browser": "bun tests/ssr-preview.playwright.ts",
|
|
56
|
+
"test:browser-i18n": "bun tests/i18n-browser.playwright.ts",
|
|
57
|
+
"test:browser-hmr": "bun tests/dev-hmr.playwright.ts",
|
|
48
58
|
"test:generated": "bun tests/generated-project.smoke.ts",
|
|
59
|
+
"plugin:perf": "bun scripts/plugin-performance.ts",
|
|
60
|
+
"plugin:memory": "bun scripts/plugin-memory-evidence.ts",
|
|
49
61
|
"package:check": "bun run build && bun scripts/check-package.ts",
|
|
50
62
|
"bundle:check": "bun run docs:build && bun scripts/check-bundle.ts",
|
|
51
63
|
"bump": "bun scripts/bump.ts",
|
|
@@ -53,7 +65,8 @@
|
|
|
53
65
|
"docs:dev": "bun run build && bun dist/cli/index.js dev",
|
|
54
66
|
"docs:build": "bun run build && bun dist/cli/index.js build -o .docs-dist",
|
|
55
67
|
"docs:preview": "bun run build && bun dist/cli/index.js build -o .docs-dist && bun dist/cli/index.js preview -o .docs-dist",
|
|
56
|
-
"
|
|
68
|
+
"index:search": "bun scripts/index-search.ts",
|
|
69
|
+
"check": "bun run typecheck && bun run build && bun run test && bun run docs:build",
|
|
57
70
|
"dev": "tsc -p tsconfig.build.json --watch"
|
|
58
71
|
},
|
|
59
72
|
"dependencies": {
|
|
@@ -86,8 +99,10 @@
|
|
|
86
99
|
"tailwindcss": ">=4.0.0"
|
|
87
100
|
},
|
|
88
101
|
"devDependencies": {
|
|
102
|
+
"@nikala-ui/folio-algolia": "0.2.0",
|
|
89
103
|
"@types/fs-extra": "^11.0.4",
|
|
90
104
|
"@types/node": "^26.1.1",
|
|
105
|
+
"bun-types": "1.3.14",
|
|
91
106
|
"playwright": "1.63.0",
|
|
92
107
|
"solid-js": "^1.9.14",
|
|
93
108
|
"tailwindcss": "^4.0.7",
|