@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.
- package/README.md +16 -0
- package/dist/cli/commands/init.js +105 -51
- 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/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 +4 -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 -4
- 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 +9 -0
- package/dist/search/provider.js +4 -2
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.js +69 -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 +121 -0
- package/dist/server/seo.d.ts +4 -0
- package/dist/server/seo.js +87 -0
- package/dist/templates/env.d.ts +26 -0
- package/dist/templates/locales/en.json +77 -0
- package/dist/themes/default/components/docs-landing-body.d.ts +17 -0
- package/dist/themes/default/components/docs-landing-body.jsx +17 -0
- package/dist/themes/default/components/docs-page-body.d.ts +21 -0
- package/dist/themes/default/components/docs-page-body.jsx +36 -0
- package/dist/themes/default/components/page-actions.d.ts +15 -0
- package/dist/themes/default/components/page-actions.jsx +60 -0
- package/dist/themes/default/components/page-header.d.ts +7 -0
- package/dist/themes/default/components/page-header.jsx +3 -0
- package/dist/themes/default/components/sidebar-footer.d.ts +6 -0
- package/dist/themes/default/components/sidebar-footer.jsx +12 -0
- package/dist/themes/default/components/sidebar-header.d.ts +8 -0
- package/dist/themes/default/components/sidebar-header.jsx +17 -0
- package/dist/themes/default/components/sidebar-mobile-nav.d.ts +7 -0
- package/dist/themes/default/components/sidebar-mobile-nav.jsx +17 -0
- package/dist/themes/default/components/sidebar-promo.d.ts +8 -0
- package/dist/themes/default/components/sidebar-promo.jsx +20 -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/hooks/use-page-copy.d.ts +6 -0
- package/dist/themes/default/hooks/use-page-copy.js +26 -0
- package/dist/themes/default/layout.jsx +30 -127
- package/dist/themes/default/lib/layout-visibility.d.ts +8 -0
- package/dist/themes/default/lib/layout-visibility.js +24 -0
- package/dist/themes/default/navbar.jsx +14 -7
- package/dist/themes/default/navigation/mobile-table-of-contents.jsx +5 -3
- 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 +14 -3
- package/dist/themes/default/sidebar.jsx +21 -49
- package/dist/themes/types.d.ts +5 -0
- package/dist/types.d.ts +36 -0
- package/dist/utils/format-title.d.ts +1 -0
- package/dist/utils/format-title.js +11 -0
- package/dist/vendor/docs-src/client/page-actions.ts +69 -0
- 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 +4 -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/navigation/index.ts +2 -0
- package/dist/vendor/docs-src/navigation/repository-links.ts +43 -0
- package/dist/vendor/docs-src/navigation/sidebar-state.ts +22 -0
- package/dist/vendor/docs-src/navigation/sidebar-tree.ts +15 -0
- 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/vendor/docs-src/search/provider.ts +83 -0
- package/dist/vendor/docs-src/themes/default/components/docs-landing-body.tsx +30 -0
- package/dist/vendor/docs-src/themes/default/components/docs-page-body.tsx +53 -0
- package/dist/vendor/docs-src/themes/default/components/page-actions.tsx +105 -0
- package/dist/vendor/docs-src/themes/default/components/page-header.tsx +31 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-footer.tsx +21 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-header.tsx +30 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-mobile-nav.tsx +33 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-promo.tsx +37 -0
- package/dist/vendor/docs-src/themes/default/content/breadcrumbs.tsx +43 -0
- package/dist/vendor/docs-src/themes/default/content/pager.tsx +19 -0
- package/dist/vendor/docs-src/themes/default/content/table-of-contents.tsx +32 -0
- package/dist/vendor/docs-src/themes/default/hooks/use-page-copy.ts +29 -0
- package/dist/vendor/docs-src/themes/default/icons.ts +16 -0
- package/dist/vendor/docs-src/themes/default/index.ts +46 -0
- package/dist/vendor/docs-src/themes/default/layout.tsx +176 -0
- package/dist/vendor/docs-src/themes/default/lib/layout-visibility.ts +39 -0
- package/dist/vendor/docs-src/themes/default/navbar.tsx +130 -0
- package/dist/vendor/docs-src/themes/default/navigation/mobile-table-of-contents.tsx +61 -0
- package/dist/vendor/docs-src/themes/default/navigation/sidebar-tree.tsx +202 -0
- package/dist/vendor/docs-src/themes/default/overlays/search-dialog.tsx +106 -0
- package/dist/vendor/docs-src/themes/default/sidebar.tsx +86 -0
- package/dist/vendor/docs-src/themes/index.ts +4 -0
- package/dist/vendor/docs-src/themes/types.ts +87 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +11 -4
- package/dist/server/plugin.js +0 -521
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { compileMdx } from "../../mdx/compiler.js";
|
|
4
|
+
import { loadConfig } from "../../config.js";
|
|
5
|
+
import { resolveDefaultThemeMode } from "../../theme-mode.js";
|
|
6
|
+
import { createFolioBuildSession } from "./lifecycle.js";
|
|
7
|
+
import { CONFIG_FILENAMES, RESOLVED_CONFIG_ID, RESOLVED_ICONS_ID, RESOLVED_ROUTES_ID, RESOLVED_SHIKI_ID, RESOLVED_SOURCES_ID, RESOLVED_THEME_ID, RESOLVED_TREE_ID, VIRTUAL_CONFIG_ID, VIRTUAL_COMPONENTS_ID, VIRTUAL_ICONS_ID, VIRTUAL_ROUTES_ID, VIRTUAL_SOURCES_ID, VIRTUAL_THEME_ID, VIRTUAL_TREE_ID, } from "./constants.js";
|
|
8
|
+
import { escapeHtmlAttribute, getServerModuleDir, getTailwindSourceDirectives } from "./styles.js";
|
|
9
|
+
import { createVirtualModuleLoader } from "./virtual-modules.js";
|
|
10
|
+
import { getComponentSourceDir } from "./components.js";
|
|
11
|
+
export function nikalaDocsPlugin(options = {}) {
|
|
12
|
+
let rootDir = path.resolve(options.configRoot || process.cwd());
|
|
13
|
+
let docsDir = options.docsDir ? path.resolve(rootDir, options.docsDir) : path.resolve(rootDir, "docs");
|
|
14
|
+
let resolvedConfig = options.config || { title: "Folio" };
|
|
15
|
+
let isSsrBuild = false;
|
|
16
|
+
let lifecycleSession = options.lifecycleSession;
|
|
17
|
+
let lifecycleMode = "production";
|
|
18
|
+
const moduleDir = getServerModuleDir();
|
|
19
|
+
const state = () => ({ rootDir, docsDir, resolvedConfig, optionsConfig: options.config, lifecycleSession, isSsrBuild });
|
|
20
|
+
const loadVirtualModule = createVirtualModuleLoader(state, moduleDir);
|
|
21
|
+
const createLifecycleSession = () => createFolioBuildSession({
|
|
22
|
+
plugins: resolvedConfig.plugins,
|
|
23
|
+
config: resolvedConfig,
|
|
24
|
+
rootDir,
|
|
25
|
+
contentDir: docsDir,
|
|
26
|
+
mode: lifecycleMode,
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
name: "vite-plugin-folio",
|
|
30
|
+
enforce: "pre",
|
|
31
|
+
async configResolved(viteConfig) {
|
|
32
|
+
isSsrBuild = Boolean(viteConfig.build.ssr);
|
|
33
|
+
lifecycleMode = viteConfig.command === "serve" ? "development" : "production";
|
|
34
|
+
rootDir = path.resolve(options.configRoot || process.cwd());
|
|
35
|
+
if (!options.config)
|
|
36
|
+
resolvedConfig = await loadConfig(options.configRoot || rootDir);
|
|
37
|
+
if (!options.docsDir) {
|
|
38
|
+
if (resolvedConfig.contentDir)
|
|
39
|
+
docsDir = path.resolve(rootDir, resolvedConfig.contentDir);
|
|
40
|
+
else if (await fs.pathExists(path.resolve(rootDir, "docs")))
|
|
41
|
+
docsDir = path.resolve(rootDir, "docs");
|
|
42
|
+
else if (await fs.pathExists(path.resolve(rootDir, "content")))
|
|
43
|
+
docsDir = path.resolve(rootDir, "content");
|
|
44
|
+
else
|
|
45
|
+
docsDir = rootDir;
|
|
46
|
+
}
|
|
47
|
+
else
|
|
48
|
+
docsDir = path.resolve(rootDir, options.docsDir);
|
|
49
|
+
lifecycleSession ||= createLifecycleSession();
|
|
50
|
+
await lifecycleSession.start();
|
|
51
|
+
},
|
|
52
|
+
transformIndexHtml(html) {
|
|
53
|
+
const favicon = resolvedConfig.favicon || "/favicon.ico";
|
|
54
|
+
return html.replace(/<link rel="icon" href="[^"]*"\s*\/>/i, `<link rel="icon" href="${escapeHtmlAttribute(favicon)}" />`).replaceAll("__NIKALA_DEFAULT_THEME__", resolveDefaultThemeMode(resolvedConfig));
|
|
55
|
+
},
|
|
56
|
+
resolveId(id, importer) {
|
|
57
|
+
if (id === "shiki" || id.startsWith("shiki/")) {
|
|
58
|
+
if (importer && (importer.includes("/mdx/") || importer.includes("\\mdx\\")))
|
|
59
|
+
return null;
|
|
60
|
+
return isSsrBuild ? RESOLVED_SHIKI_ID : null;
|
|
61
|
+
}
|
|
62
|
+
const virtualIds = {
|
|
63
|
+
[VIRTUAL_CONFIG_ID]: RESOLVED_CONFIG_ID, [VIRTUAL_TREE_ID]: RESOLVED_TREE_ID,
|
|
64
|
+
[VIRTUAL_ROUTES_ID]: RESOLVED_ROUTES_ID, [VIRTUAL_SOURCES_ID]: RESOLVED_SOURCES_ID,
|
|
65
|
+
[VIRTUAL_COMPONENTS_ID]: "\0" + VIRTUAL_COMPONENTS_ID, [VIRTUAL_ICONS_ID]: RESOLVED_ICONS_ID,
|
|
66
|
+
[RESOLVED_ICONS_ID]: RESOLVED_ICONS_ID, [VIRTUAL_THEME_ID]: RESOLVED_THEME_ID,
|
|
67
|
+
};
|
|
68
|
+
return virtualIds[id] || null;
|
|
69
|
+
},
|
|
70
|
+
load: loadVirtualModule,
|
|
71
|
+
async transform(code, id, transformOptions) {
|
|
72
|
+
const cssId = id.split("?", 1)[0];
|
|
73
|
+
const packagedCss = path.resolve(moduleDir, "../client/style.css");
|
|
74
|
+
const baseCss = path.resolve(moduleDir, "../client/base.css");
|
|
75
|
+
const configuredCss = resolvedConfig.css ? path.resolve(rootDir, resolvedConfig.css) : packagedCss;
|
|
76
|
+
if (cssId === packagedCss || cssId === configuredCss) {
|
|
77
|
+
const directives = getTailwindSourceDirectives(rootDir, docsDir, moduleDir);
|
|
78
|
+
if (cssId === packagedCss && configuredCss !== packagedCss)
|
|
79
|
+
return { code: `${directives}\n@import ${JSON.stringify(configuredCss.replace(/\\/g, "/"))};\n@import ${JSON.stringify(baseCss.replace(/\\/g, "/"))};`, map: null };
|
|
80
|
+
return { code: `@import "tailwindcss";\n${directives}\n${code.replace('@import "tailwindcss";', "")}`, map: null };
|
|
81
|
+
}
|
|
82
|
+
if (/\.(md|mdx)$/.test(id)) {
|
|
83
|
+
const result = await compileMdx(code, { filePath: id, development: !Boolean(transformOptions?.ssr) && process.env.NODE_ENV !== "production", shiki: resolvedConfig.shiki });
|
|
84
|
+
return { code: result.code, map: null };
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
},
|
|
88
|
+
configureServer(server) {
|
|
89
|
+
const configFiles = [...CONFIG_FILENAMES].map((filename) => path.join(rootDir, filename)).filter((file) => fs.existsSync(file));
|
|
90
|
+
if (configFiles.length)
|
|
91
|
+
server.watcher.add(configFiles);
|
|
92
|
+
if (docsDir && fs.existsSync(docsDir))
|
|
93
|
+
server.watcher.add(docsDir);
|
|
94
|
+
const componentsDir = getComponentSourceDir(rootDir, moduleDir);
|
|
95
|
+
if (componentsDir && fs.existsSync(componentsDir))
|
|
96
|
+
server.watcher.add(componentsDir);
|
|
97
|
+
const configuredCss = resolvedConfig.css ? path.resolve(rootDir, resolvedConfig.css) : undefined;
|
|
98
|
+
if (configuredCss && fs.existsSync(configuredCss))
|
|
99
|
+
server.watcher.add(configuredCss);
|
|
100
|
+
let reloadTimer;
|
|
101
|
+
const reportLifecycleError = (error) => {
|
|
102
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
103
|
+
server.config.logger.error(message);
|
|
104
|
+
server.ws.send({ type: "error", err: { message, stack: error instanceof Error ? error.stack || message : message } });
|
|
105
|
+
};
|
|
106
|
+
const invalidate = (includeConfig = false, includeComponents = false) => {
|
|
107
|
+
for (const id of [RESOLVED_TREE_ID, RESOLVED_ROUTES_ID, ...(includeComponents ? ["\0" + VIRTUAL_COMPONENTS_ID] : []), ...(includeConfig ? [RESOLVED_CONFIG_ID, RESOLVED_THEME_ID] : [])]) {
|
|
108
|
+
const module = server.moduleGraph.getModuleById(id);
|
|
109
|
+
if (module)
|
|
110
|
+
server.moduleGraph.invalidateModule(module);
|
|
111
|
+
}
|
|
112
|
+
if (reloadTimer)
|
|
113
|
+
clearTimeout(reloadTimer);
|
|
114
|
+
reloadTimer = setTimeout(() => { reloadTimer = undefined; server.ws.send({ type: "full-reload" }); }, 75);
|
|
115
|
+
};
|
|
116
|
+
const reloadContent = async () => {
|
|
117
|
+
try {
|
|
118
|
+
await lifecycleSession?.reload();
|
|
119
|
+
invalidate();
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
reportLifecycleError(error);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
server.watcher.on("add", (file) => /\.(md|mdx)$/.test(file) ? void reloadContent() : componentsDir && path.resolve(file).startsWith(`${path.resolve(componentsDir)}${path.sep}`) ? invalidate(false, true) : undefined);
|
|
126
|
+
server.watcher.on("unlink", (file) => /\.(md|mdx)$/.test(file) ? void reloadContent() : componentsDir && path.resolve(file).startsWith(`${path.resolve(componentsDir)}${path.sep}`) ? invalidate(false, true) : undefined);
|
|
127
|
+
server.watcher.on("change", async (file) => {
|
|
128
|
+
if (/\.(md|mdx)$/.test(file))
|
|
129
|
+
return reloadContent();
|
|
130
|
+
if (componentsDir && path.resolve(file).startsWith(`${path.resolve(componentsDir)}${path.sep}`))
|
|
131
|
+
return invalidate(false, true);
|
|
132
|
+
if (CONFIG_FILENAMES.has(path.basename(file))) {
|
|
133
|
+
try {
|
|
134
|
+
if (!options.config) {
|
|
135
|
+
resolvedConfig = await loadConfig(rootDir);
|
|
136
|
+
if (resolvedConfig.contentDir)
|
|
137
|
+
docsDir = path.resolve(rootDir, resolvedConfig.contentDir);
|
|
138
|
+
lifecycleSession = createLifecycleSession();
|
|
139
|
+
}
|
|
140
|
+
await lifecycleSession?.start();
|
|
141
|
+
return invalidate(true);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
return reportLifecycleError(error);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (configuredCss && path.resolve(file) === configuredCss) {
|
|
148
|
+
const cssModule = server.moduleGraph.getModuleById(configuredCss);
|
|
149
|
+
if (cssModule)
|
|
150
|
+
server.moduleGraph.invalidateModule(cssModule);
|
|
151
|
+
invalidate();
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
handleHotUpdate({ file, server }) {
|
|
156
|
+
const configuredCss = resolvedConfig.css ? path.resolve(rootDir, resolvedConfig.css) : undefined;
|
|
157
|
+
if (configuredCss && path.resolve(file) === configuredCss) {
|
|
158
|
+
for (const module of server.moduleGraph.getModulesByFile(configuredCss) || [])
|
|
159
|
+
server.moduleGraph.invalidateModule(module);
|
|
160
|
+
server.ws.send({ type: "full-reload" });
|
|
161
|
+
return [];
|
|
162
|
+
}
|
|
163
|
+
return undefined;
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FolioBuildResult, FolioPage, FolioPluginLogger } from "../../plugin.js";
|
|
2
|
+
import type { DocsConfig } from "../../types.js";
|
|
3
|
+
export interface FolioBuildSessionOptions {
|
|
4
|
+
plugins: DocsConfig["plugins"];
|
|
5
|
+
config: DocsConfig;
|
|
6
|
+
rootDir: string;
|
|
7
|
+
contentDir: string;
|
|
8
|
+
outputDir?: string;
|
|
9
|
+
mode: "development" | "production";
|
|
10
|
+
logger?: FolioPluginLogger;
|
|
11
|
+
}
|
|
12
|
+
/** Coordinates one Folio build's plugin lifecycle and page catalog. */
|
|
13
|
+
export declare class FolioBuildSession {
|
|
14
|
+
private lifecycle;
|
|
15
|
+
private readonly options;
|
|
16
|
+
private readonly contentDir;
|
|
17
|
+
private startPromise?;
|
|
18
|
+
private pagesPromise?;
|
|
19
|
+
private failure?;
|
|
20
|
+
private generation;
|
|
21
|
+
constructor(options: FolioBuildSessionOptions);
|
|
22
|
+
private createLifecycle;
|
|
23
|
+
start(): Promise<void>;
|
|
24
|
+
pages(): Promise<readonly FolioPage[]>;
|
|
25
|
+
/** Rebuilds the development catalog with a fresh lifecycle manager. */
|
|
26
|
+
reload(): Promise<readonly FolioPage[]>;
|
|
27
|
+
getPages(): readonly FolioPage[];
|
|
28
|
+
getFailure(): unknown;
|
|
29
|
+
generate(): Promise<void>;
|
|
30
|
+
buildEnd(result: FolioBuildResult): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare function createFolioBuildSession(options: FolioBuildSessionOptions): FolioBuildSession;
|
|
@@ -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,121 @@
|
|
|
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
|
+
function getSearchAdapterRuntime(provider) {
|
|
10
|
+
if (!provider || typeof provider !== "object" || !provider.runtime)
|
|
11
|
+
return undefined;
|
|
12
|
+
if (typeof provider.runtime !== "object" || Array.isArray(provider.runtime)) {
|
|
13
|
+
throw new Error("[folio] Search adapter runtime must be an object");
|
|
14
|
+
}
|
|
15
|
+
const runtime = provider.runtime;
|
|
16
|
+
if (typeof runtime.module !== "string" || typeof runtime.exportName !== "string") {
|
|
17
|
+
throw new Error("[folio] Search adapter runtime requires module and exportName");
|
|
18
|
+
}
|
|
19
|
+
if (!runtime.module.trim() || !runtime.exportName.trim()) {
|
|
20
|
+
throw new Error("[folio] Search adapter runtime requires module and exportName");
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
module: runtime.module,
|
|
24
|
+
exportName: runtime.exportName,
|
|
25
|
+
options: runtime.options,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function createVirtualModuleLoader(state, moduleDir) {
|
|
29
|
+
return async function load(id) {
|
|
30
|
+
const current = state();
|
|
31
|
+
const { rootDir, docsDir, resolvedConfig, lifecycleSession } = current;
|
|
32
|
+
if (id === RESOLVED_SHIKI_ID)
|
|
33
|
+
return `
|
|
34
|
+
export const createHighlighter = async () => null;
|
|
35
|
+
export const bundledLanguages = {};
|
|
36
|
+
export const bundledThemes = {};
|
|
37
|
+
export default { createHighlighter, bundledLanguages, bundledThemes };
|
|
38
|
+
`;
|
|
39
|
+
if (id === RESOLVED_CONFIG_ID) {
|
|
40
|
+
const serializedConfig = serializeModuleValue(resolvedConfig);
|
|
41
|
+
const runtime = getSearchAdapterRuntime(resolvedConfig.search?.provider);
|
|
42
|
+
if (!runtime)
|
|
43
|
+
return `export default ${serializedConfig};`;
|
|
44
|
+
return `import * as searchRuntime from ${serializeModuleValue(runtime.module)};
|
|
45
|
+
const config = ${serializedConfig};
|
|
46
|
+
const provider = config.search?.provider;
|
|
47
|
+
const createAdapter = searchRuntime[${serializeModuleValue(runtime.exportName)}];
|
|
48
|
+
if (provider?.runtime) {
|
|
49
|
+
if (typeof createAdapter !== "function") {
|
|
50
|
+
throw new Error(${serializeModuleValue(`[folio] Search adapter runtime export "${runtime.exportName}" was not found in "${runtime.module}"`)});
|
|
51
|
+
}
|
|
52
|
+
config.search = { ...config.search, provider: createAdapter(provider.runtime.options) };
|
|
53
|
+
}
|
|
54
|
+
export default config;`;
|
|
55
|
+
}
|
|
56
|
+
if (id === RESOLVED_TREE_ID) {
|
|
57
|
+
const pages = [...await lifecycleSession.pages()];
|
|
58
|
+
const directories = await scanContentDirectories(docsDir);
|
|
59
|
+
const configuredSidebar = resolvedConfig.navigation?.sidebar?.nav ?? resolvedConfig.sidebar ?? "auto";
|
|
60
|
+
const tree = configuredSidebar !== "auto" ? buildConfiguredSidebarTree(configuredSidebar, pages) : buildSidebarTree(pages, directories);
|
|
61
|
+
return `export const pages = ${serializeModuleValue(pages)}; export const tree = ${serializeModuleValue(tree)}; export default { pages, tree };`;
|
|
62
|
+
}
|
|
63
|
+
if (id === RESOLVED_ROUTES_ID || id === RESOLVED_SOURCES_ID) {
|
|
64
|
+
const pages = [...await lifecycleSession.pages()];
|
|
65
|
+
const key = id === RESOLVED_ROUTES_ID ? "routes" : "sources";
|
|
66
|
+
const entries = pages.map((page) => ` ${serializeModuleValue(page.url)}: () => import(${serializeModuleValue(id === RESOLVED_ROUTES_ID ? page.filePath : `${page.filePath}?raw`)})`);
|
|
67
|
+
return `export const ${key} = {\n${entries.join(",\n")}\n}; export default ${key};`;
|
|
68
|
+
}
|
|
69
|
+
if (id === RESOLVED_COMPONENTS_ID) {
|
|
70
|
+
const componentDir = getComponentSourceDir(rootDir, moduleDir);
|
|
71
|
+
const themeDirs = [path.resolve(moduleDir, "../themes/default"), path.resolve(rootDir, "src/themes/default")];
|
|
72
|
+
if (resolvedConfig.theme?.path) {
|
|
73
|
+
const configuredTheme = path.resolve(rootDir, resolvedConfig.theme.path);
|
|
74
|
+
themeDirs.push(fs.existsSync(configuredTheme) && fs.statSync(configuredTheme).isDirectory() ? configuredTheme : path.dirname(configuredTheme));
|
|
75
|
+
}
|
|
76
|
+
const staticFiles = collectStaticComponentFiles(componentDir, themeDirs);
|
|
77
|
+
const exports = collectComponentExports(componentDir);
|
|
78
|
+
const modules = new Map();
|
|
79
|
+
for (const { file } of exports)
|
|
80
|
+
if (!modules.has(file))
|
|
81
|
+
modules.set(file, { index: modules.size, isStatic: staticFiles.has(file) });
|
|
82
|
+
const imports = [...modules].map(([file, { index, isStatic }]) => isStatic ? `import * as componentModule${index} from ${serializeModuleValue(file)};` : `const componentModule${index} = () => import(${serializeModuleValue(file)});`);
|
|
83
|
+
const entries = exports.map(({ name, file }) => {
|
|
84
|
+
const module = modules.get(file);
|
|
85
|
+
return module.isStatic ? ` ${serializeModuleValue(name)}: componentModule${module.index}[${serializeModuleValue(name)}]` : ` ${serializeModuleValue(name)}: lazy(() => componentModule${module.index}().then((module) => ({ default: module[${serializeModuleValue(name)}] })))`;
|
|
86
|
+
});
|
|
87
|
+
return `import { lazy } from "solid-js";\n${imports.join("\n")}\nconst components = {\n${entries.join(",\n")}\n}; export default components;`;
|
|
88
|
+
}
|
|
89
|
+
if (id === RESOLVED_ICONS_ID) {
|
|
90
|
+
const pages = await lifecycleSession.pages();
|
|
91
|
+
const names = [...new Set(pages.map((page) => page.frontmatter.icon).filter((name) => typeof name === "string" && name.trim().length > 0))];
|
|
92
|
+
const require = createRequire(path.join(rootDir, "package.json"));
|
|
93
|
+
const entries = [];
|
|
94
|
+
for (const name of names) {
|
|
95
|
+
const kebabName = name.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
96
|
+
try {
|
|
97
|
+
require.resolve(`lucide-solid/icons/${kebabName}`);
|
|
98
|
+
entries.push({ name, specifier: `lucide-solid/icons/${kebabName}` });
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
console.warn(`[folio] Unknown Lucide icon "${name}"; skipping it.`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
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};`;
|
|
105
|
+
}
|
|
106
|
+
if (id === RESOLVED_THEME_ID) {
|
|
107
|
+
const configuredPath = resolvedConfig.theme?.path;
|
|
108
|
+
if (!configuredPath) {
|
|
109
|
+
const defaultEntry = path.resolve(moduleDir, "../themes/default/index.js");
|
|
110
|
+
return `import defaultTheme from ${serializeModuleValue(defaultEntry)}; export const theme = defaultTheme; export default theme;`;
|
|
111
|
+
}
|
|
112
|
+
const requestedPath = path.resolve(rootDir, configuredPath);
|
|
113
|
+
const candidates = [requestedPath, ...["index.ts", "index.tsx", "index.js", "index.jsx"].map((entry) => path.join(requestedPath, entry))];
|
|
114
|
+
const themeEntry = candidates.find((candidate) => fs.existsSync(candidate));
|
|
115
|
+
if (!themeEntry)
|
|
116
|
+
throw new Error(`[folio] Theme path does not exist: ${requestedPath}`);
|
|
117
|
+
return `import configuredTheme from ${serializeModuleValue(themeEntry)}; export const theme = configuredTheme.default || configuredTheme; export default theme;`;
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module "*.css";
|
|
4
|
+
|
|
5
|
+
declare module "virtual:folio-config" {
|
|
6
|
+
const config: any;
|
|
7
|
+
export default config;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module "virtual:folio-tree" {
|
|
11
|
+
export const pages: any[];
|
|
12
|
+
export const tree: any[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module "virtual:folio-routes" {
|
|
16
|
+
export const routes: Record<string, () => Promise<any>>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module "virtual:folio-components" {
|
|
20
|
+
const components: Record<string, any>;
|
|
21
|
+
export default components;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module "virtual:folio-icons" {
|
|
25
|
+
export const icons: Record<string, any>;
|
|
26
|
+
}
|