@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,110 @@
|
|
|
1
|
+
import { scanContent } from "../../core/content-scanner.js";
|
|
2
|
+
import { createFolioPluginLifecycleManager, } from "../../core/plugin/index.js";
|
|
3
|
+
const consoleLogger = {
|
|
4
|
+
debug: (message, ...args) => console.debug(message, ...args),
|
|
5
|
+
info: (message, ...args) => console.info(message, ...args),
|
|
6
|
+
warn: (message, ...args) => console.warn(message, ...args),
|
|
7
|
+
error: (message, ...args) => console.error(message, ...args),
|
|
8
|
+
};
|
|
9
|
+
/** Coordinates one Folio build's plugin lifecycle and page catalog. */
|
|
10
|
+
export class FolioBuildSession {
|
|
11
|
+
lifecycle;
|
|
12
|
+
options;
|
|
13
|
+
contentDir;
|
|
14
|
+
startPromise;
|
|
15
|
+
pagesPromise;
|
|
16
|
+
failure;
|
|
17
|
+
generation = 0;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.options = options;
|
|
20
|
+
this.contentDir = options.contentDir;
|
|
21
|
+
this.lifecycle = this.createLifecycle();
|
|
22
|
+
}
|
|
23
|
+
createLifecycle() {
|
|
24
|
+
return createFolioPluginLifecycleManager({
|
|
25
|
+
plugins: this.options.plugins,
|
|
26
|
+
config: this.options.config,
|
|
27
|
+
rootDir: this.options.rootDir,
|
|
28
|
+
contentDir: this.options.contentDir,
|
|
29
|
+
outputDir: this.options.outputDir,
|
|
30
|
+
mode: this.options.mode,
|
|
31
|
+
logger: this.options.logger || consoleLogger,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async start() {
|
|
35
|
+
if (!this.startPromise) {
|
|
36
|
+
const generation = this.generation;
|
|
37
|
+
const lifecycle = this.lifecycle;
|
|
38
|
+
this.startPromise = (async () => {
|
|
39
|
+
await lifecycle.configResolved();
|
|
40
|
+
await lifecycle.buildStart();
|
|
41
|
+
if (generation !== this.generation)
|
|
42
|
+
return;
|
|
43
|
+
})();
|
|
44
|
+
}
|
|
45
|
+
await this.startPromise;
|
|
46
|
+
}
|
|
47
|
+
async pages() {
|
|
48
|
+
if (!this.pagesPromise) {
|
|
49
|
+
const generation = this.generation;
|
|
50
|
+
const lifecycle = this.lifecycle;
|
|
51
|
+
this.pagesPromise = (async () => {
|
|
52
|
+
await this.start();
|
|
53
|
+
const scanned = await scanContent(this.contentDir);
|
|
54
|
+
const generated = await lifecycle.pagesGenerated(scanned);
|
|
55
|
+
for (const page of generated) {
|
|
56
|
+
if (generation !== this.generation)
|
|
57
|
+
return this.pages();
|
|
58
|
+
await lifecycle.pageCollected(page);
|
|
59
|
+
const transformed = await lifecycle.pageTransformed(page);
|
|
60
|
+
await lifecycle.pageActions(transformed);
|
|
61
|
+
}
|
|
62
|
+
if (generation !== this.generation)
|
|
63
|
+
return this.pages();
|
|
64
|
+
return lifecycle.getPages();
|
|
65
|
+
})().catch((error) => {
|
|
66
|
+
this.failure = error;
|
|
67
|
+
throw error;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return this.pagesPromise;
|
|
71
|
+
}
|
|
72
|
+
/** Rebuilds the development catalog with a fresh lifecycle manager. */
|
|
73
|
+
async reload() {
|
|
74
|
+
const previousLifecycle = this.lifecycle;
|
|
75
|
+
const previousStart = this.startPromise;
|
|
76
|
+
const previousPages = this.pagesPromise;
|
|
77
|
+
const previousFailure = this.failure;
|
|
78
|
+
this.generation += 1;
|
|
79
|
+
this.lifecycle = this.createLifecycle();
|
|
80
|
+
this.startPromise = undefined;
|
|
81
|
+
this.pagesPromise = undefined;
|
|
82
|
+
this.failure = undefined;
|
|
83
|
+
try {
|
|
84
|
+
return await this.pages();
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
this.lifecycle = previousLifecycle;
|
|
88
|
+
this.startPromise = previousStart;
|
|
89
|
+
this.pagesPromise = previousPages;
|
|
90
|
+
this.failure = previousFailure;
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
getPages() {
|
|
95
|
+
return this.lifecycle.getPages();
|
|
96
|
+
}
|
|
97
|
+
getFailure() {
|
|
98
|
+
return this.failure;
|
|
99
|
+
}
|
|
100
|
+
async generate() {
|
|
101
|
+
await this.pages();
|
|
102
|
+
await this.lifecycle.generate();
|
|
103
|
+
}
|
|
104
|
+
async buildEnd(result) {
|
|
105
|
+
await this.lifecycle.buildEnd(result);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export function createFolioBuildSession(options) {
|
|
109
|
+
return new FolioBuildSession(options);
|
|
110
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
export function escapeHtmlAttribute(value) {
|
|
5
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
6
|
+
}
|
|
7
|
+
export function getTailwindSourceDirectives(rootDir, docsDir, moduleDir) {
|
|
8
|
+
const sources = [];
|
|
9
|
+
const bundledDocsSource = path.resolve(moduleDir, "../vendor/docs-src");
|
|
10
|
+
if (fs.existsSync(bundledDocsSource))
|
|
11
|
+
sources.push(bundledDocsSource);
|
|
12
|
+
sources.push(path.resolve(rootDir, "src"));
|
|
13
|
+
const themesDir = path.resolve(moduleDir, "../themes");
|
|
14
|
+
if (fs.existsSync(themesDir))
|
|
15
|
+
sources.push(themesDir);
|
|
16
|
+
if (docsDir && fs.existsSync(docsDir))
|
|
17
|
+
sources.push(docsDir);
|
|
18
|
+
return sources.map((src) => `@source "${src}";`).join("\n");
|
|
19
|
+
}
|
|
20
|
+
export function getServerModuleDir() {
|
|
21
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DocsConfig } from "../../types.js";
|
|
2
|
+
import type { FolioBuildSession } from "./lifecycle.js";
|
|
3
|
+
export interface VirtualModuleState {
|
|
4
|
+
rootDir: string;
|
|
5
|
+
docsDir: string;
|
|
6
|
+
resolvedConfig: DocsConfig;
|
|
7
|
+
optionsConfig?: DocsConfig;
|
|
8
|
+
lifecycleSession?: FolioBuildSession;
|
|
9
|
+
isSsrBuild: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function createVirtualModuleLoader(state: () => VirtualModuleState, moduleDir: string): (id: string) => Promise<string | null>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { scanContentDirectories } from "../../core/content-scanner.js";
|
|
5
|
+
import { buildConfiguredSidebarTree, buildSidebarTree } from "../../core/route-tree.js";
|
|
6
|
+
import { serializeModuleValue } from "../module-serialization.js";
|
|
7
|
+
import { collectComponentExports, collectStaticComponentFiles, getComponentSourceDir, toLucideComponentName } from "./components.js";
|
|
8
|
+
import { RESOLVED_COMPONENTS_ID, RESOLVED_CONFIG_ID, RESOLVED_ICONS_ID, RESOLVED_ROUTES_ID, RESOLVED_SHIKI_ID, RESOLVED_SOURCES_ID, RESOLVED_THEME_ID, RESOLVED_TREE_ID, } from "./constants.js";
|
|
9
|
+
export function createVirtualModuleLoader(state, moduleDir) {
|
|
10
|
+
return async function load(id) {
|
|
11
|
+
const current = state();
|
|
12
|
+
const { rootDir, docsDir, resolvedConfig, lifecycleSession } = current;
|
|
13
|
+
if (id === RESOLVED_SHIKI_ID)
|
|
14
|
+
return `
|
|
15
|
+
export const createHighlighter = async () => null;
|
|
16
|
+
export const bundledLanguages = {};
|
|
17
|
+
export const bundledThemes = {};
|
|
18
|
+
export default { createHighlighter, bundledLanguages, bundledThemes };
|
|
19
|
+
`;
|
|
20
|
+
if (id === RESOLVED_CONFIG_ID) {
|
|
21
|
+
return `export default ${serializeModuleValue(resolvedConfig)};`;
|
|
22
|
+
}
|
|
23
|
+
if (id === RESOLVED_TREE_ID) {
|
|
24
|
+
const pages = [...await lifecycleSession.pages()];
|
|
25
|
+
const directories = await scanContentDirectories(docsDir);
|
|
26
|
+
const configuredSidebar = resolvedConfig.navigation?.sidebar?.nav ?? resolvedConfig.sidebar ?? "auto";
|
|
27
|
+
const tree = configuredSidebar !== "auto" ? buildConfiguredSidebarTree(configuredSidebar, pages) : buildSidebarTree(pages, directories);
|
|
28
|
+
return `export const pages = ${serializeModuleValue(pages)}; export const tree = ${serializeModuleValue(tree)}; export default { pages, tree };`;
|
|
29
|
+
}
|
|
30
|
+
if (id === RESOLVED_ROUTES_ID || id === RESOLVED_SOURCES_ID) {
|
|
31
|
+
const pages = [...await lifecycleSession.pages()];
|
|
32
|
+
const key = id === RESOLVED_ROUTES_ID ? "routes" : "sources";
|
|
33
|
+
const entries = pages.map((page) => ` ${serializeModuleValue(page.url)}: () => import(${serializeModuleValue(id === RESOLVED_ROUTES_ID ? page.filePath : `${page.filePath}?raw`)})`);
|
|
34
|
+
return `export const ${key} = {\n${entries.join(",\n")}\n}; export default ${key};`;
|
|
35
|
+
}
|
|
36
|
+
if (id === RESOLVED_COMPONENTS_ID) {
|
|
37
|
+
const componentDir = getComponentSourceDir(rootDir, moduleDir);
|
|
38
|
+
const themeDirs = [path.resolve(moduleDir, "../themes/default"), path.resolve(rootDir, "src/themes/default")];
|
|
39
|
+
if (resolvedConfig.theme?.path) {
|
|
40
|
+
const configuredTheme = path.resolve(rootDir, resolvedConfig.theme.path);
|
|
41
|
+
themeDirs.push(fs.existsSync(configuredTheme) && fs.statSync(configuredTheme).isDirectory() ? configuredTheme : path.dirname(configuredTheme));
|
|
42
|
+
}
|
|
43
|
+
const staticFiles = collectStaticComponentFiles(componentDir, themeDirs);
|
|
44
|
+
const exports = collectComponentExports(componentDir);
|
|
45
|
+
const modules = new Map();
|
|
46
|
+
for (const { file } of exports)
|
|
47
|
+
if (!modules.has(file))
|
|
48
|
+
modules.set(file, { index: modules.size, isStatic: staticFiles.has(file) });
|
|
49
|
+
const imports = [...modules].map(([file, { index, isStatic }]) => isStatic ? `import * as componentModule${index} from ${serializeModuleValue(file)};` : `const componentModule${index} = () => import(${serializeModuleValue(file)});`);
|
|
50
|
+
const entries = exports.map(({ name, file }) => {
|
|
51
|
+
const module = modules.get(file);
|
|
52
|
+
return module.isStatic ? ` ${serializeModuleValue(name)}: componentModule${module.index}[${serializeModuleValue(name)}]` : ` ${serializeModuleValue(name)}: lazy(() => componentModule${module.index}().then((module) => ({ default: module[${serializeModuleValue(name)}] })))`;
|
|
53
|
+
});
|
|
54
|
+
return `import { lazy } from "solid-js";\n${imports.join("\n")}\nconst components = {\n${entries.join(",\n")}\n}; export default components;`;
|
|
55
|
+
}
|
|
56
|
+
if (id === RESOLVED_ICONS_ID) {
|
|
57
|
+
const pages = await lifecycleSession.pages();
|
|
58
|
+
const names = [...new Set(pages.map((page) => page.frontmatter.icon).filter((name) => typeof name === "string" && name.trim().length > 0))];
|
|
59
|
+
const require = createRequire(path.join(rootDir, "package.json"));
|
|
60
|
+
const entries = [];
|
|
61
|
+
for (const name of names) {
|
|
62
|
+
const kebabName = name.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
63
|
+
try {
|
|
64
|
+
require.resolve(`lucide-solid/icons/${kebabName}`);
|
|
65
|
+
entries.push({ name, specifier: `lucide-solid/icons/${kebabName}` });
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
console.warn(`[folio] Unknown Lucide icon "${name}"; skipping it.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return `${entries.map(({ specifier }, index) => `import icon${index} from ${serializeModuleValue(specifier)};`).join("\n")}\nexport const icons = {\n${entries.map(({ name }, index) => ` ${serializeModuleValue(toLucideComponentName(name))}: icon${index}`).join(",\n")}\n};`;
|
|
72
|
+
}
|
|
73
|
+
if (id === RESOLVED_THEME_ID) {
|
|
74
|
+
const configuredPath = resolvedConfig.theme?.path;
|
|
75
|
+
if (!configuredPath) {
|
|
76
|
+
const defaultEntry = path.resolve(moduleDir, "../themes/default/index.js");
|
|
77
|
+
return `import defaultTheme from ${serializeModuleValue(defaultEntry)}; export const theme = defaultTheme; export default theme;`;
|
|
78
|
+
}
|
|
79
|
+
const requestedPath = path.resolve(rootDir, configuredPath);
|
|
80
|
+
const candidates = [requestedPath, ...["index.ts", "index.tsx", "index.js", "index.jsx"].map((entry) => path.join(requestedPath, entry))];
|
|
81
|
+
const themeEntry = candidates.find((candidate) => fs.existsSync(candidate));
|
|
82
|
+
if (!themeEntry)
|
|
83
|
+
throw new Error(`[folio] Theme path does not exist: ${requestedPath}`);
|
|
84
|
+
return `import configuredTheme from ${serializeModuleValue(themeEntry)}; export const theme = configuredTheme.default || configuredTheme; export default theme;`;
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DocsConfig, PageData } from "../types.js";
|
|
2
|
+
export declare function renderSeoMetadata(config: DocsConfig, page: PageData): string;
|
|
3
|
+
export declare function isPageIndexable(page: PageData): boolean;
|
|
4
|
+
export declare function getPageLastModified(page: PageData): string | undefined;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
function escapeHtml(value) {
|
|
2
|
+
return value
|
|
3
|
+
.replace(/&/g, "&")
|
|
4
|
+
.replace(/</g, "<")
|
|
5
|
+
.replace(/>/g, ">")
|
|
6
|
+
.replace(/"/g, """)
|
|
7
|
+
.replace(/'/g, "'");
|
|
8
|
+
}
|
|
9
|
+
function absoluteUrl(siteUrl, value) {
|
|
10
|
+
try {
|
|
11
|
+
const url = new URL(value, siteUrl || "https://folio.invalid");
|
|
12
|
+
if (!siteUrl && url.origin === "https://folio.invalid")
|
|
13
|
+
return undefined;
|
|
14
|
+
return url.toString();
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function jsonLd(value) {
|
|
21
|
+
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
22
|
+
}
|
|
23
|
+
export function renderSeoMetadata(config, page) {
|
|
24
|
+
const siteName = config.seo?.siteName || config.title || "Documentation";
|
|
25
|
+
const title = `${page.title} - ${config.title || "Documentation"}`;
|
|
26
|
+
const description = page.description || config.description || "";
|
|
27
|
+
const pageUrl = absoluteUrl(config.siteUrl, page.url);
|
|
28
|
+
const imageUrl = config.seo?.image
|
|
29
|
+
? absoluteUrl(config.siteUrl, config.seo.image)
|
|
30
|
+
: undefined;
|
|
31
|
+
const tags = [
|
|
32
|
+
`<title>${escapeHtml(title)}</title>`,
|
|
33
|
+
];
|
|
34
|
+
if (description) {
|
|
35
|
+
tags.push(`<meta name="description" content="${escapeHtml(description)}">`);
|
|
36
|
+
}
|
|
37
|
+
if (page.frontmatter.noindex === true) {
|
|
38
|
+
tags.push(`<meta name="robots" content="noindex, follow">`);
|
|
39
|
+
}
|
|
40
|
+
if (pageUrl) {
|
|
41
|
+
tags.push(`<link rel="canonical" href="${escapeHtml(pageUrl)}">`);
|
|
42
|
+
tags.push(`<meta property="og:url" content="${escapeHtml(pageUrl)}">`);
|
|
43
|
+
}
|
|
44
|
+
tags.push(`<meta property="og:type" content="article">`, `<meta property="og:title" content="${escapeHtml(title)}">`, `<meta property="og:site_name" content="${escapeHtml(siteName)}">`, `<meta property="og:locale" content="${escapeHtml(config.seo?.locale || "en_US")}">`, `<meta name="twitter:card" content="${config.seo?.twitterCard || "summary_large_image"}">`, `<meta name="twitter:title" content="${escapeHtml(title)}">`);
|
|
45
|
+
if (description) {
|
|
46
|
+
tags.push(`<meta property="og:description" content="${escapeHtml(description)}">`, `<meta name="twitter:description" content="${escapeHtml(description)}">`);
|
|
47
|
+
}
|
|
48
|
+
if (imageUrl) {
|
|
49
|
+
tags.push(`<meta property="og:image" content="${escapeHtml(imageUrl)}">`, `<meta name="twitter:image" content="${escapeHtml(imageUrl)}">`);
|
|
50
|
+
if (config.seo?.imageAlt) {
|
|
51
|
+
tags.push(`<meta property="og:image:alt" content="${escapeHtml(config.seo.imageAlt)}">`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (pageUrl) {
|
|
55
|
+
const structuredData = {
|
|
56
|
+
"@context": "https://schema.org",
|
|
57
|
+
"@graph": [
|
|
58
|
+
{
|
|
59
|
+
"@type": "TechArticle",
|
|
60
|
+
headline: page.title,
|
|
61
|
+
description: description || undefined,
|
|
62
|
+
url: pageUrl,
|
|
63
|
+
image: imageUrl,
|
|
64
|
+
isPartOf: { "@type": "WebSite", name: siteName, url: absoluteUrl(config.siteUrl, "/") },
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"@type": "BreadcrumbList",
|
|
68
|
+
itemListElement: [
|
|
69
|
+
{ "@type": "ListItem", position: 1, name: siteName, item: absoluteUrl(config.siteUrl, "/") },
|
|
70
|
+
{ "@type": "ListItem", position: 2, name: page.title, item: pageUrl },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
tags.push(`<script type="application/ld+json">${jsonLd(structuredData)}</script>`);
|
|
76
|
+
}
|
|
77
|
+
return tags.join("");
|
|
78
|
+
}
|
|
79
|
+
export function isPageIndexable(page) {
|
|
80
|
+
return page.frontmatter.noindex !== true;
|
|
81
|
+
}
|
|
82
|
+
export function getPageLastModified(page) {
|
|
83
|
+
const value = page.frontmatter.updatedAt;
|
|
84
|
+
if (!value || Number.isNaN(Date.parse(value)))
|
|
85
|
+
return undefined;
|
|
86
|
+
return new Date(value).toISOString().slice(0, 10);
|
|
87
|
+
}
|
|
@@ -6,17 +6,20 @@ import { BreadcrumbItem } from "@/components/ui/breadcrumb";
|
|
|
6
6
|
import { BreadcrumbLink } from "@/components/ui/breadcrumb";
|
|
7
7
|
import { BreadcrumbSeparator } from "@/components/ui/breadcrumb";
|
|
8
8
|
import { BreadcrumbPage } from "@/components/ui/breadcrumb";
|
|
9
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
9
10
|
export const DocsBreadcrumbs = (props) => {
|
|
10
11
|
const [local, rest] = splitProps(props, ["items", "class"]);
|
|
12
|
+
const siteLocale = useSiteLocale();
|
|
11
13
|
return (<Breadcrumb class={local.class} {...rest}>
|
|
12
14
|
<BreadcrumbList>
|
|
13
15
|
<For each={local.items}>
|
|
14
16
|
{(item, index) => {
|
|
15
17
|
const isLast = () => index() === local.items.length - 1;
|
|
18
|
+
const title = () => item.href === "/" ? siteLocale.t("navigation.documentation") : item.title;
|
|
16
19
|
return (<>
|
|
17
20
|
<BreadcrumbItem>
|
|
18
|
-
<Show when={!isLast() && item.href} fallback={<BreadcrumbPage>{
|
|
19
|
-
<BreadcrumbLink href={item.href}>{
|
|
21
|
+
<Show when={!isLast() && item.href} fallback={<BreadcrumbPage>{title()}</BreadcrumbPage>}>
|
|
22
|
+
<BreadcrumbLink href={item.href}>{title()}</BreadcrumbLink>
|
|
20
23
|
</Show>
|
|
21
24
|
</BreadcrumbItem>
|
|
22
25
|
<Show when={!isLast()}>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// packages/docs/src/themes/default/content/table-of-contents.tsx
|
|
2
2
|
import { createSignal, onMount, Show, splitProps } from "solid-js";
|
|
3
3
|
import { TableOfContents as CoreTableOfContents } from "@/components/ui/table-of-contents";
|
|
4
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
4
5
|
export const DocsTableOfContents = (props) => {
|
|
5
6
|
const [local, rest] = splitProps(props, ["items", "title", "class"]);
|
|
6
7
|
const [ready, setReady] = createSignal(false);
|
|
8
|
+
const siteLocale = useSiteLocale();
|
|
7
9
|
onMount(() => {
|
|
8
10
|
if (typeof window === "undefined") {
|
|
9
11
|
setReady(true);
|
|
@@ -13,6 +15,6 @@ export const DocsTableOfContents = (props) => {
|
|
|
13
15
|
return () => window.cancelAnimationFrame(frame);
|
|
14
16
|
});
|
|
15
17
|
return (<Show when={ready()}>
|
|
16
|
-
<CoreTableOfContents items={local.items} title={local.title ?? "
|
|
18
|
+
<CoreTableOfContents items={local.items} title={local.title ?? siteLocale.t("tableOfContents.title")} class={local.class} {...rest}/>
|
|
17
19
|
</Show>);
|
|
18
20
|
};
|
|
@@ -14,18 +14,21 @@ import { DocsSearchDialog } from "./overlays/search-dialog.jsx";
|
|
|
14
14
|
import { cn } from "@/lib/cn";
|
|
15
15
|
import { buttonVariants } from "@/components/ui/button";
|
|
16
16
|
import { Button } from "@/components/ui/button";
|
|
17
|
+
import { Card, CardContent, CardDescription, CardTitle } from "@/components/ui/card";
|
|
17
18
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
18
19
|
import { createClipboard } from "@/hooks/create-clipboard";
|
|
19
20
|
import { Copy, FileText, ChevronDown, ExternalLink } from "lucide-solid";
|
|
20
21
|
import { pageToMarkdown, pageToText, resolvePageActionUrl, sourceToMarkdown } from "../../client/page-actions.js";
|
|
21
22
|
import { getRepositorySourceUrl } from "../../navigation/repository-links.js";
|
|
22
23
|
import { resolveSearchProvider } from "../../search/provider.js";
|
|
24
|
+
import { useSiteLocale } from "../../plugins/i18n/runtime.jsx";
|
|
23
25
|
export const DocsLayout = (props) => {
|
|
24
26
|
const [local, rest] = splitProps(props, [
|
|
25
27
|
"config",
|
|
26
28
|
"tree",
|
|
27
29
|
"pages",
|
|
28
30
|
"currentPage",
|
|
31
|
+
"onNavigate",
|
|
29
32
|
"breadcrumbs",
|
|
30
33
|
"toc",
|
|
31
34
|
"prev",
|
|
@@ -35,7 +38,9 @@ export const DocsLayout = (props) => {
|
|
|
35
38
|
"class",
|
|
36
39
|
]);
|
|
37
40
|
const [searchOpen, setSearchOpen] = createSignal(false);
|
|
41
|
+
const siteLocale = useSiteLocale();
|
|
38
42
|
const pageClipboard = createClipboard();
|
|
43
|
+
const searchEnabled = () => local.config.search?.enabled !== false;
|
|
39
44
|
const searchProvider = () => resolveSearchProvider(local.config.search);
|
|
40
45
|
const currentUrl = () => local.currentPage?.url;
|
|
41
46
|
const landingPage = () => local.currentPage?.url === "/" && local.config.home?.layout === "landing";
|
|
@@ -48,6 +53,7 @@ export const DocsLayout = (props) => {
|
|
|
48
53
|
const sidebarLayout = () => local.config.navigation?.layout !== "top";
|
|
49
54
|
const sidebarHeader = () => local.config.navigation?.sidebar?.header !== false;
|
|
50
55
|
const sidebarFooter = () => local.config.navigation?.sidebar?.footer !== false;
|
|
56
|
+
const sidebarPromo = () => local.config.navigation?.sidebar?.promo;
|
|
51
57
|
const sourceUrl = () => {
|
|
52
58
|
const page = local.currentPage;
|
|
53
59
|
const repository = local.config.repository;
|
|
@@ -81,7 +87,8 @@ export const DocsLayout = (props) => {
|
|
|
81
87
|
title: local.currentPage?.title,
|
|
82
88
|
prompt: provider.prompt,
|
|
83
89
|
});
|
|
84
|
-
const
|
|
90
|
+
const pageActions = () => local.currentPage?.pageActions || [];
|
|
91
|
+
const sidebar = (className) => (<DocsSidebar tree={local.tree} pages={local.pages} nav={local.config.navigation?.navbar || local.config.nav} currentUrl={currentUrl()} title={local.config.title} logo={local.config.logo} headerSubtitle={local.config.navigation?.sidebar?.headerSubtitle} footerText={local.config.navigation?.sidebar?.footerText} showHeader={sidebarHeader()} showFooter={sidebarFooter()} class={className}/>);
|
|
85
92
|
const content = () => (<SidebarInset class={cn("min-w-0", local.class)} {...rest}>
|
|
86
93
|
<Container as="main" size="2xl" class="min-w-0 w-full max-w-[96rem] flex-1 grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_16rem] items-start gap-4 sm:gap-8 py-6 sm:py-8">
|
|
87
94
|
<Container as="article" size="full" class="min-w-0 max-w-none mx-0 px-0 sm:px-4 w-full">
|
|
@@ -92,34 +99,39 @@ export const DocsLayout = (props) => {
|
|
|
92
99
|
<SectionHeading variant="page" title={local.currentPage.title} description={local.currentPage?.description} class="mb-8" actions={<div class="flex items-center gap-2">
|
|
93
100
|
<Show when={sourceUrl()}>
|
|
94
101
|
{(url) => (<a href={url()} target="_blank" rel="noreferrer" class={cn(buttonVariants({ variant: "secondary", size: "sm" }), "shrink-0")}>
|
|
95
|
-
|
|
102
|
+
{siteLocale.t("actions.viewSource")}
|
|
96
103
|
</a>)}
|
|
97
104
|
</Show>
|
|
105
|
+
<For each={pageActions()}>
|
|
106
|
+
{(action) => (<a href={action.href} target={action.external ? "_blank" : undefined} rel={action.external ? "noreferrer" : undefined} class={cn(buttonVariants({ variant: "secondary", size: "sm" }), "shrink-0")}>
|
|
107
|
+
{action.label}
|
|
108
|
+
</a>)}
|
|
109
|
+
</For>
|
|
98
110
|
<Show when={hasPageActions()}>
|
|
99
111
|
<DropdownMenu placement="bottom-end">
|
|
100
|
-
<DropdownMenuTrigger as={Button} variant="secondary" size="sm" class="shrink-0 gap-1" aria-label="
|
|
112
|
+
<DropdownMenuTrigger as={Button} variant="secondary" size="sm" class="shrink-0 gap-1" aria-label={siteLocale.t("actions.copyDocumentationPage")}>
|
|
101
113
|
<Copy class="size-3.5"/>
|
|
102
|
-
<span class="hidden sm:inline">
|
|
114
|
+
<span class="hidden sm:inline">{siteLocale.t("actions.copyPage")}</span>
|
|
103
115
|
<ChevronDown class="size-3.5"/>
|
|
104
116
|
</DropdownMenuTrigger>
|
|
105
117
|
<DropdownMenuContent>
|
|
106
118
|
<Show when={copyPageEnabled()}>
|
|
107
119
|
<DropdownMenuItem onClick={copyPage}>
|
|
108
120
|
<FileText class="mr-2 size-4"/>
|
|
109
|
-
|
|
121
|
+
{siteLocale.t("actions.copyPage")}
|
|
110
122
|
</DropdownMenuItem>
|
|
111
123
|
</Show>
|
|
112
124
|
<Show when={copyMarkdownEnabled()}>
|
|
113
125
|
<DropdownMenuItem onClick={copyMarkdown}>
|
|
114
126
|
<Copy class="mr-2 size-4"/>
|
|
115
|
-
|
|
127
|
+
{siteLocale.t("actions.copyAsMarkdown")}
|
|
116
128
|
</DropdownMenuItem>
|
|
117
129
|
</Show>
|
|
118
130
|
<Show when={aiProviders().length > 0}>
|
|
119
131
|
<For each={aiProviders()}>
|
|
120
132
|
{(provider) => (<DropdownMenuItem as="a" href={pageActionUrl(provider)} target="_blank" rel="noreferrer">
|
|
121
133
|
<ExternalLink class="mr-2 size-4"/>
|
|
122
|
-
|
|
134
|
+
{siteLocale.t("actions.openInProvider", { provider: provider.name })}
|
|
123
135
|
</DropdownMenuItem>)}
|
|
124
136
|
</For>
|
|
125
137
|
</Show>
|
|
@@ -139,12 +151,28 @@ export const DocsLayout = (props) => {
|
|
|
139
151
|
</Show>
|
|
140
152
|
</Container>
|
|
141
153
|
<Show when={showToc() && local.currentPage?.url} keyed>
|
|
142
|
-
<Container as="aside" size="sm" class="hidden xl:block w-64 shrink-0 self-start px-0 sticky top-14 z-10 h-fit max-h-[calc(100vh-3.5rem)] overflow-
|
|
143
|
-
<
|
|
154
|
+
<Container as="aside" size="sm" class="hidden xl:block w-64 shrink-0 self-start px-0 sticky top-14 z-10 h-fit max-h-[calc(100vh-3.5rem)] overflow-y-auto bg-background">
|
|
155
|
+
<div class="flex flex-col gap-5">
|
|
156
|
+
<DocsTableOfContents items={local.toc} class="max-h-none"/>
|
|
157
|
+
<Show when={sidebarPromo()}>
|
|
158
|
+
{(promo) => (<Card class="border-primary/30 bg-primary/5 shadow-none">
|
|
159
|
+
<CardContent class="p-4">
|
|
160
|
+
<CardTitle class="text-sm">{promo().title}</CardTitle>
|
|
161
|
+
<CardDescription class="mt-2 text-xs leading-relaxed">
|
|
162
|
+
{promo().description}
|
|
163
|
+
</CardDescription>
|
|
164
|
+
<a href={promo().href} target="_blank" rel="noreferrer" class={cn(buttonVariants({ variant: "outline", size: "sm" }), "mt-4 h-8 w-full gap-1.5 text-xs")}>
|
|
165
|
+
{promo().cta || siteLocale.t("actions.learnMore")}
|
|
166
|
+
<ExternalLink class="size-3" aria-hidden="true"/>
|
|
167
|
+
</a>
|
|
168
|
+
</CardContent>
|
|
169
|
+
</Card>)}
|
|
170
|
+
</Show>
|
|
171
|
+
</div>
|
|
144
172
|
</Container>
|
|
145
173
|
</Show>
|
|
146
174
|
</Container>
|
|
147
|
-
<DocsSearchDialog open={searchOpen()} onOpenChange={setSearchOpen} pages={local.pages} provider={searchProvider().
|
|
175
|
+
<DocsSearchDialog open={searchOpen()} onOpenChange={setSearchOpen} pages={local.pages} provider={searchEnabled() ? searchProvider().implementation : undefined}/>
|
|
148
176
|
</SidebarInset>);
|
|
149
177
|
const landingContent = () => (<SidebarInset class={cn("min-w-0", local.class)} {...rest}>
|
|
150
178
|
<Container as="main" size="2xl" class="min-w-0 max-w-full flex-1 py-8 sm:py-12 lg:py-16">
|
|
@@ -162,22 +190,22 @@ export const DocsLayout = (props) => {
|
|
|
162
190
|
</Show>
|
|
163
191
|
</Container>
|
|
164
192
|
</Container>
|
|
165
|
-
<DocsSearchDialog open={searchOpen()} onOpenChange={setSearchOpen} pages={local.pages} provider={searchProvider().
|
|
193
|
+
<DocsSearchDialog open={searchOpen()} onOpenChange={setSearchOpen} pages={local.pages} provider={searchEnabled() ? searchProvider().implementation : undefined}/>
|
|
166
194
|
</SidebarInset>);
|
|
167
195
|
return (<SidebarProvider defaultOpen={true} class="min-h-screen w-full items-stretch">
|
|
168
196
|
<Show when={landingPage()} fallback={<Show when={sidebarLayout()} fallback={<div class="flex min-h-screen min-w-0 flex-1 flex-col">
|
|
169
|
-
<DocsNavbar config={local.config} showBrand={true} showSidebarTrigger={false} onOpenSearch={() => setSearchOpen(true)}/>
|
|
197
|
+
<DocsNavbar config={local.config} currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} showBrand={true} showSidebarTrigger={false} onOpenSearch={() => setSearchOpen(true)}/>
|
|
170
198
|
<div class="flex min-h-0 min-w-0 max-w-full flex-1 items-start">{content()}</div>
|
|
171
199
|
</div>}>
|
|
172
200
|
{sidebar()}
|
|
173
201
|
<div class="flex min-h-screen min-w-0 flex-1 flex-col">
|
|
174
|
-
<DocsNavbar config={local.config} showBrand={false} onOpenSearch={() => setSearchOpen(true)}/>
|
|
202
|
+
<DocsNavbar config={local.config} currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} showBrand={false} onOpenSearch={() => setSearchOpen(true)}/>
|
|
175
203
|
{content()}
|
|
176
204
|
</div>
|
|
177
205
|
</Show>}>
|
|
178
206
|
<div class="flex min-h-screen min-w-0 flex-1 flex-col">
|
|
179
207
|
<Show when={showNavbar()}>
|
|
180
|
-
<DocsNavbar config={local.config} showBrand={true} showSidebarTrigger={showLandingSidebar()} mobileSidebarTrigger={landingPage()} onOpenSearch={() => setSearchOpen(true)}/>
|
|
208
|
+
<DocsNavbar config={local.config} currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} showBrand={true} showSidebarTrigger={showLandingSidebar()} mobileSidebarTrigger={landingPage()} onOpenSearch={() => setSearchOpen(true)}/>
|
|
181
209
|
</Show>
|
|
182
210
|
<Show when={showLandingSidebar()} fallback={<>
|
|
183
211
|
<Show when={landingPage()}>
|
|
@@ -10,14 +10,17 @@ import { buttonVariants } from "@/components/ui/button";
|
|
|
10
10
|
import { Kbd } from "@/components/ui/kbd";
|
|
11
11
|
import { SidebarTrigger } from "@/components/ui/sidebar";
|
|
12
12
|
import { ThemeToggle } from "@/components/ui/theme-toggle";
|
|
13
|
+
import { DocsSiteLanguageSwitcher } from "../../plugins/i18n/components/site-language-switcher.jsx";
|
|
14
|
+
import { useSiteLocale } from "../../plugins/i18n/runtime.jsx";
|
|
13
15
|
import { Logo } from "@/components/ui/logo";
|
|
14
16
|
import { Search } from "lucide-solid";
|
|
15
17
|
export const DocsNavbar = (props) => {
|
|
16
|
-
const [local, rest] = splitProps(props, ["config", "onOpenSearch", "showBrand", "showSidebarTrigger", "mobileSidebarTrigger", "class"]);
|
|
18
|
+
const [local, rest] = splitProps(props, ["config", "currentPage", "pages", "onNavigate", "onOpenSearch", "showBrand", "showSidebarTrigger", "mobileSidebarTrigger", "class"]);
|
|
17
19
|
const title = () => local.config.title || "Folio";
|
|
18
20
|
const logoText = () => local.config.logo?.text || title();
|
|
19
21
|
const logoHref = () => local.config.logo?.href || "/";
|
|
20
22
|
const repoUrl = () => local.config.repository?.url;
|
|
23
|
+
const siteLocale = useSiteLocale();
|
|
21
24
|
return (<Navbar variant="default" maxWidth="full" isSticky={true} class={local.class} {...rest}>
|
|
22
25
|
<NavbarContainer class="h-14 md:h-14 px-4 sm:px-6">
|
|
23
26
|
<NavbarContent justify="start" class="gap-3">
|
|
@@ -26,7 +29,7 @@ export const DocsNavbar = (props) => {
|
|
|
26
29
|
</Show>
|
|
27
30
|
<Show when={local.showBrand !== false}>
|
|
28
31
|
<NavbarBrand href={logoHref()} class="text-base font-bold tracking-tight">
|
|
29
|
-
<Show when={local.config.logo?.image} fallback={<Logo class="
|
|
32
|
+
<Show when={local.config.logo?.image} fallback={<Logo class="h-6 w-auto"/>}>
|
|
30
33
|
{(img) => <img src={img()} alt={logoText()} class="size-6 object-contain"/>}
|
|
31
34
|
</Show>
|
|
32
35
|
<span>{logoText()}</span>
|
|
@@ -50,13 +53,13 @@ export const DocsNavbar = (props) => {
|
|
|
50
53
|
<Show when={local.config.search?.enabled !== false && local.onOpenSearch}>
|
|
51
54
|
<NavbarItem>
|
|
52
55
|
<Button variant="outline" size="sm" onClick={() => local.onOpenSearch?.()} class="hidden sm:inline-flex text-muted-foreground w-48 sm:w-64 justify-between h-8 text-xs font-normal">
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
<span class="inline-flex items-center gap-2">
|
|
57
|
+
<Search class="size-3.5"/>
|
|
58
|
+
<span>{siteLocale.t("navigation.search")}</span>
|
|
56
59
|
</span>
|
|
57
60
|
<Kbd size="sm">⌘K</Kbd>
|
|
58
61
|
</Button>
|
|
59
|
-
<Button variant="ghost" size="sm" onClick={() => local.onOpenSearch?.()} class="sm:hidden p-2" aria-label="
|
|
62
|
+
<Button variant="ghost" size="sm" onClick={() => local.onOpenSearch?.()} class="sm:hidden p-2" aria-label={siteLocale.t("navigation.searchLabel")}>
|
|
60
63
|
<Search class="size-4"/>
|
|
61
64
|
</Button>
|
|
62
65
|
</NavbarItem>
|
|
@@ -66,11 +69,15 @@ export const DocsNavbar = (props) => {
|
|
|
66
69
|
<Show when={repoUrl()}>
|
|
67
70
|
{(url) => (<NavbarItem>
|
|
68
71
|
<a href={url()} target="_blank" rel="noreferrer" class={buttonVariants({ variant: "ghost", size: "sm" }) + " hidden sm:inline-flex h-8 px-2 text-xs"}>
|
|
69
|
-
|
|
72
|
+
{siteLocale.t("navigation.github")}
|
|
70
73
|
</a>
|
|
71
74
|
</NavbarItem>)}
|
|
72
75
|
</Show>
|
|
73
76
|
|
|
77
|
+
<NavbarItem>
|
|
78
|
+
<DocsSiteLanguageSwitcher currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate}/>
|
|
79
|
+
</NavbarItem>
|
|
80
|
+
|
|
74
81
|
{/* Theme Toggle */}
|
|
75
82
|
<NavbarItem>
|
|
76
83
|
<ThemeToggle />
|
|
@@ -5,12 +5,14 @@ import { CollapsibleTrigger } from "@/components/ui/collapsible";
|
|
|
5
5
|
import { cn } from "@/lib/cn";
|
|
6
6
|
import { ChevronDown } from "lucide-solid";
|
|
7
7
|
import { DocsTableOfContents } from "../content/table-of-contents.jsx";
|
|
8
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
8
9
|
export const DocsMobileTableOfContents = (props) => {
|
|
9
10
|
const [local, rest] = splitProps(props, ["items", "title", "class", "onActiveChange"]);
|
|
10
11
|
const [open, setOpen] = createSignal(false);
|
|
11
12
|
const [activeId, setActiveId] = createSignal(local.items[0]?.id || "");
|
|
12
13
|
const [rootElement, setRootElement] = createSignal();
|
|
13
|
-
const
|
|
14
|
+
const siteLocale = useSiteLocale();
|
|
15
|
+
const title = () => local.title ?? siteLocale.t("tableOfContents.title");
|
|
14
16
|
const activeTitle = () => local.items.find((item) => item.id === activeId())?.text || title();
|
|
15
17
|
const handleActiveChange = (id) => {
|
|
16
18
|
setActiveId(id);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type Component } from "solid-js";
|
|
2
2
|
import type { SidebarItem } from "../../../types.js";
|
|
3
|
+
import type { PageData } from "../../../types.js";
|
|
3
4
|
export interface SidebarTreeProps {
|
|
4
5
|
tree: SidebarItem[];
|
|
6
|
+
pages?: readonly PageData[];
|
|
5
7
|
currentUrl?: string;
|
|
6
8
|
}
|
|
7
9
|
export declare const SidebarTree: Component<SidebarTreeProps>;
|