@clarify-labs/cli 0.6.7 → 0.7.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/output/cli.cjs +5 -4
- package/output/cli.cjs.map +1 -1
- package/output/cli.js +5 -4
- package/output/cli.js.map +1 -1
- package/output/core/config-schema.d.ts +37 -8
- package/output/core/search-language.d.ts +1 -0
- package/output/core/ssg.d.ts +1 -1
- package/output/core/temp-dir.d.ts +2 -0
- package/output/core/theme.d.ts +2 -52
- package/output/core/virtual-modules.d.ts +10 -1
- package/output/index.cjs +1 -1
- package/output/index.js +1 -1
- package/output/{plugin-hJcy-YdO.cjs → plugin-DFpkIm9j.cjs} +231 -70
- package/output/plugin-DFpkIm9j.cjs.map +1 -0
- package/output/{plugin-Cx9lFenc.js → plugin-o1rP_gts.js} +228 -73
- package/output/plugin-o1rP_gts.js.map +1 -0
- package/output/plugins/openapi/virtual-modules.d.ts +1 -1
- package/output/plugins/search-index/index.d.ts +2 -0
- package/output/types.d.ts +10 -2
- package/package.json +5 -3
- package/output/plugin-Cx9lFenc.js.map +0 -1
- package/output/plugin-hJcy-YdO.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { createReadStream, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
3
|
import mdxPlugin from "@mdx-js/rollup";
|
|
4
4
|
import tailwindcss from "@tailwindcss/vite";
|
|
@@ -7,13 +7,13 @@ import GithubSlugger, { slug } from "github-slugger";
|
|
|
7
7
|
import { toString } from "mdast-util-to-string";
|
|
8
8
|
import shiki from "shiki";
|
|
9
9
|
import { visit } from "unist-util-visit";
|
|
10
|
-
import { markdownRemarkPlugins } from "@clarify-labs/renderer";
|
|
10
|
+
import { markdownRemarkPlugins, themeBootstrapScript, themePresets } from "@clarify-labs/renderer";
|
|
11
11
|
import { remark } from "remark";
|
|
12
12
|
import matter from "gray-matter";
|
|
13
13
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
14
|
+
import { tmpdir } from "node:os";
|
|
14
15
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
15
16
|
import { z } from "zod";
|
|
16
|
-
import { tmpdir } from "node:os";
|
|
17
17
|
import { pathToFileURL } from "node:url";
|
|
18
18
|
import { build, loadConfigFromFile } from "vite";
|
|
19
19
|
import { createRequire } from "node:module";
|
|
@@ -233,7 +233,6 @@ function createContentArtifactsPlugin() {
|
|
|
233
233
|
}
|
|
234
234
|
//#endregion
|
|
235
235
|
//#region source/plugins/html-shell/index.ts
|
|
236
|
-
var THEME_BOOTSTRAP_SCRIPT = `(function(){try{var e=localStorage.getItem('clarify:theme');var t=e==='dark'||e==='light'||e==='system'?e:'system';var r=t==='system'?window.matchMedia('(prefers-color-scheme: dark)').matches:t==='dark';document.documentElement.classList.toggle('dark',r);document.documentElement.style.colorScheme=r?'dark':'light'}catch(e){}})();`;
|
|
237
236
|
var REL_ICON_RE = /<link\s+[^>]*rel=["'][^"']*\bicon\b[^"']*["'][^>]*>/i;
|
|
238
237
|
function inferIconType(href) {
|
|
239
238
|
const path = href.split(/[?#]/, 1)[0]?.toLowerCase() ?? href.toLowerCase();
|
|
@@ -273,7 +272,7 @@ function createHtmlShellPlugin() {
|
|
|
273
272
|
...REL_ICON_RE.test(input.html) ? [] : createIconTags(ctx.projectConfig.favicon ?? ctx.projectConfig.logo),
|
|
274
273
|
{
|
|
275
274
|
tag: "script",
|
|
276
|
-
children:
|
|
275
|
+
children: themeBootstrapScript(ctx.projectConfig.theme),
|
|
277
276
|
injectTo: "head-prepend"
|
|
278
277
|
},
|
|
279
278
|
{
|
|
@@ -338,6 +337,7 @@ function navigationSections(sections) {
|
|
|
338
337
|
return sections.map((s) => ({
|
|
339
338
|
id: s.id,
|
|
340
339
|
title: s.title,
|
|
340
|
+
level: s.level,
|
|
341
341
|
badge: s.badge,
|
|
342
342
|
tags: s.tags
|
|
343
343
|
}));
|
|
@@ -732,6 +732,7 @@ function generateRoutesModule(routes, resolvedNavigation, projectConfig, mode =
|
|
|
732
732
|
const sections = r.sections && r.sections.length > 0 ? `, sections: ${JSON.stringify(r.sections.map((s) => ({
|
|
733
733
|
id: s.id,
|
|
734
734
|
title: s.title,
|
|
735
|
+
level: s.level,
|
|
735
736
|
badge: s.badge,
|
|
736
737
|
tags: s.tags
|
|
737
738
|
})))}` : "";
|
|
@@ -750,8 +751,12 @@ function generateRoutesModule(routes, resolvedNavigation, projectConfig, mode =
|
|
|
750
751
|
const navigation = resolvedNavigation ?? (projectConfig?.tabs ? projectConfig.i18n ? buildLocalizedNavigationFromTabsConfig(routes, projectConfig.tabs, projectConfig.i18n) ?? {} : buildNavigationFromTabsConfig(routes, projectConfig.tabs) : buildNavigation(routes));
|
|
751
752
|
return `${imports}\n\nexport const routes = [\n${routesArray}\n];\n\nexport const navigation = ${JSON.stringify(navigation, null, 2)};\n`;
|
|
752
753
|
}
|
|
753
|
-
function createRuntimeModule() {
|
|
754
|
-
|
|
754
|
+
function createRuntimeModule(options = {}) {
|
|
755
|
+
const imports = [options.bannerComponentSource === "path" && options.imports?.bannerComponent ? `import BannerComponent from ${moduleSpecifier(options.imports.bannerComponent)};` : void 0, options.footerComponentSource === "path" && options.imports?.footerComponent ? `import FooterComponent from ${moduleSpecifier(options.imports.footerComponent)};` : void 0].filter(Boolean).join("\n");
|
|
756
|
+
const exports = `export const openApis = {};
|
|
757
|
+
export const bannerComponent = ${options.bannerComponentSource === "path" ? "BannerComponent" : "undefined"};
|
|
758
|
+
export const footerComponent = ${options.footerComponentSource === "path" ? "FooterComponent" : "undefined"};`;
|
|
759
|
+
return imports ? `${imports}\n${exports}` : exports;
|
|
755
760
|
}
|
|
756
761
|
function createClientEntryModule(options = {}) {
|
|
757
762
|
return `
|
|
@@ -759,16 +764,29 @@ import '@clarify-labs/renderer/style.css';
|
|
|
759
764
|
import { render } from '@clarify-labs/renderer/client';
|
|
760
765
|
import { routes, navigation } from '${VIRTUAL_ROUTES}';
|
|
761
766
|
import { config } from '${VIRTUAL_CONFIG}';
|
|
762
|
-
import { openApis } from '${VIRTUAL_RUNTIME}';
|
|
763
|
-
render({ config, routes, navigation, openApis, themeEditor: ${JSON.stringify(options.themeEditor ?? false)} });`;
|
|
767
|
+
import { openApis, bannerComponent, footerComponent } from '${VIRTUAL_RUNTIME}';
|
|
768
|
+
render({ config, routes, navigation, openApis, bannerComponent, footerComponent, themeEditor: ${JSON.stringify(options.themeEditor ?? false)} });`;
|
|
764
769
|
}
|
|
765
770
|
function buildVirtualModules(args) {
|
|
766
771
|
const modules = /* @__PURE__ */ new Map();
|
|
767
772
|
const clientEntryModule = createClientEntryModule({ themeEditor: args.themeEditor });
|
|
773
|
+
const bannerComponent = args.projectConfig.banner;
|
|
774
|
+
const bannerComponentSource = typeof bannerComponent === "string" ? "path" : void 0;
|
|
775
|
+
const bannerComponentImport = typeof bannerComponent === "string" ? bannerComponent : void 0;
|
|
776
|
+
const footerComponent = args.projectConfig.footer;
|
|
777
|
+
const footerComponentSource = typeof footerComponent === "string" ? "path" : void 0;
|
|
778
|
+
const footerComponentImport = typeof footerComponent === "string" ? footerComponent : void 0;
|
|
768
779
|
modules.set(VIRTUAL_CONFIG, generateConfigModule(args.projectConfig, args.generateOptions));
|
|
769
780
|
modules.set(VIRTUAL_ROUTES, generateRoutesModule(args.routes, args.navigation, args.projectConfig, "client"));
|
|
770
781
|
modules.set(VIRTUAL_SERVER_ROUTES, generateRoutesModule(args.routes, args.navigation, args.projectConfig, "server"));
|
|
771
|
-
modules.set(VIRTUAL_RUNTIME, createRuntimeModule(
|
|
782
|
+
modules.set(VIRTUAL_RUNTIME, createRuntimeModule({
|
|
783
|
+
bannerComponentSource,
|
|
784
|
+
footerComponentSource,
|
|
785
|
+
imports: {
|
|
786
|
+
bannerComponent: bannerComponentImport,
|
|
787
|
+
footerComponent: footerComponentImport
|
|
788
|
+
}
|
|
789
|
+
}));
|
|
772
790
|
modules.set(VIRTUAL_CLIENT_ENTRY, clientEntryModule);
|
|
773
791
|
modules.set(RESOLVED_CLIENT_ENTRY, clientEntryModule);
|
|
774
792
|
for (const route of args.routes) modules.set(route.virtualModuleId, `export { default } from ${moduleSpecifier(route.filePath)};`);
|
|
@@ -777,8 +795,12 @@ function buildVirtualModules(args) {
|
|
|
777
795
|
//#endregion
|
|
778
796
|
//#region source/plugins/openapi/virtual-modules.ts
|
|
779
797
|
var openApiRegistryModuleId = VIRTUAL_RUNTIME;
|
|
780
|
-
function generateOpenAPIRegistryModule(openApis) {
|
|
781
|
-
|
|
798
|
+
function generateOpenAPIRegistryModule(openApis, runtimeModule = "") {
|
|
799
|
+
const openApisExport = `export const openApis = ${JSON.stringify(openApis)};`;
|
|
800
|
+
const openApisPlaceholder = /export const openApis = \{\};?/;
|
|
801
|
+
if (!runtimeModule) return openApisExport;
|
|
802
|
+
if (openApisPlaceholder.test(runtimeModule)) return runtimeModule.replace(openApisPlaceholder, openApisExport);
|
|
803
|
+
return runtimeModule;
|
|
782
804
|
}
|
|
783
805
|
function generateOpenAPIModule(spec, tagFilter) {
|
|
784
806
|
return `import { createElement } from 'react';
|
|
@@ -906,7 +928,7 @@ function createOpenAPIPlugin() {
|
|
|
906
928
|
return nextRoutes;
|
|
907
929
|
},
|
|
908
930
|
"modules:before": (modules, ctx) => {
|
|
909
|
-
modules.set(openApiRegistryModuleId, generateOpenAPIRegistryModule(Object.fromEntries(Object.entries(specs).map(([moduleId, entry]) => [moduleId, entry.spec]))));
|
|
931
|
+
modules.set(openApiRegistryModuleId, generateOpenAPIRegistryModule(Object.fromEntries(Object.entries(specs).map(([moduleId, entry]) => [moduleId, entry.spec])), modules.get(openApiRegistryModuleId)));
|
|
910
932
|
for (const [moduleId, entry] of Object.entries(specs)) modules.set(moduleId, generateOpenAPIModule(entry.spec, entry.tagFilter));
|
|
911
933
|
for (const route of ctx.routes.filter((route) => route.kind === "openapi" && route.diagnostic)) if (route.diagnostic) modules.set(route.virtualModuleId, generateOpenAPIErrorModule(route.diagnostic));
|
|
912
934
|
return modules;
|
|
@@ -915,6 +937,180 @@ function createOpenAPIPlugin() {
|
|
|
915
937
|
};
|
|
916
938
|
}
|
|
917
939
|
//#endregion
|
|
940
|
+
//#region source/core/search-language.ts
|
|
941
|
+
function toPagefindLanguage(locale) {
|
|
942
|
+
return locale?.trim().replace(/_/g, "-").split("-").filter(Boolean).join("-").toLowerCase() || "en";
|
|
943
|
+
}
|
|
944
|
+
//#endregion
|
|
945
|
+
//#region source/core/temp-dir.ts
|
|
946
|
+
function createClarifyTempDir(name) {
|
|
947
|
+
return mkdtempSync(join(tmpdir(), `clarify-${name}-`));
|
|
948
|
+
}
|
|
949
|
+
function removeClarifyTempDir(path) {
|
|
950
|
+
if (!path) return;
|
|
951
|
+
rmSync(path, {
|
|
952
|
+
recursive: true,
|
|
953
|
+
force: true
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
//#endregion
|
|
957
|
+
//#region source/plugins/search-index/index.ts
|
|
958
|
+
var pagefindContentTypes = {
|
|
959
|
+
".css": "text/css; charset=utf-8",
|
|
960
|
+
".js": "text/javascript; charset=utf-8",
|
|
961
|
+
".json": "application/json; charset=utf-8",
|
|
962
|
+
".wasm": "application/wasm"
|
|
963
|
+
};
|
|
964
|
+
function assertNoPagefindErrors(action, errors) {
|
|
965
|
+
if (!errors?.length) return;
|
|
966
|
+
throw new Error(`[clarify] Pagefind ${action} failed:\n${errors.join("\n")}`);
|
|
967
|
+
}
|
|
968
|
+
async function generatePagefindIndex(options) {
|
|
969
|
+
const pagefind = await import("pagefind");
|
|
970
|
+
const { errors, index } = await pagefind.createIndex({
|
|
971
|
+
excludeSelectors: [
|
|
972
|
+
"[data-pagefind-ignore]",
|
|
973
|
+
"script",
|
|
974
|
+
"style",
|
|
975
|
+
"svg"
|
|
976
|
+
],
|
|
977
|
+
includeCharacters: "._-/#:@",
|
|
978
|
+
keepIndexUrl: false,
|
|
979
|
+
verbose: false,
|
|
980
|
+
writePlayground: false
|
|
981
|
+
});
|
|
982
|
+
assertNoPagefindErrors("createIndex", errors);
|
|
983
|
+
if (!index) throw new Error("[clarify] Pagefind did not create an index.");
|
|
984
|
+
try {
|
|
985
|
+
const addResult = await index.addDirectory({
|
|
986
|
+
path: options.sourceRoot ?? options.outputRoot,
|
|
987
|
+
glob: "**/*.html"
|
|
988
|
+
});
|
|
989
|
+
assertNoPagefindErrors("addDirectory", addResult.errors);
|
|
990
|
+
assertNoPagefindErrors("writeFiles", (await index.writeFiles({ outputPath: join(options.outputRoot, "pagefind") })).errors);
|
|
991
|
+
return addResult.page_count;
|
|
992
|
+
} finally {
|
|
993
|
+
await index.deleteIndex();
|
|
994
|
+
await pagefind.close();
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
function routeSearchContent(route) {
|
|
998
|
+
return [
|
|
999
|
+
route.title,
|
|
1000
|
+
route.description,
|
|
1001
|
+
route.keywords?.join(" "),
|
|
1002
|
+
route.sections?.map((section) => section.title).join(" "),
|
|
1003
|
+
route.content
|
|
1004
|
+
].filter(Boolean).join("\n\n");
|
|
1005
|
+
}
|
|
1006
|
+
async function generateDevSearchIndex(ctx, root) {
|
|
1007
|
+
const pagefind = await import("pagefind");
|
|
1008
|
+
const { errors, index } = await pagefind.createIndex({
|
|
1009
|
+
includeCharacters: "._-/#:@",
|
|
1010
|
+
keepIndexUrl: false,
|
|
1011
|
+
verbose: false,
|
|
1012
|
+
writePlayground: false
|
|
1013
|
+
});
|
|
1014
|
+
assertNoPagefindErrors("createIndex", errors);
|
|
1015
|
+
if (!index) throw new Error("[clarify] Pagefind did not create an index.");
|
|
1016
|
+
try {
|
|
1017
|
+
let pageCount = 0;
|
|
1018
|
+
for (const route of ctx.routes) {
|
|
1019
|
+
const content = routeSearchContent(route);
|
|
1020
|
+
if (!content.trim()) continue;
|
|
1021
|
+
const result = await index.addCustomRecord({
|
|
1022
|
+
url: route.path,
|
|
1023
|
+
content,
|
|
1024
|
+
language: toPagefindLanguage(route.locale ?? ctx.projectConfig.i18n?.defaultLocale),
|
|
1025
|
+
meta: { title: route.title }
|
|
1026
|
+
});
|
|
1027
|
+
assertNoPagefindErrors(`addCustomRecord ${route.path}`, result.errors);
|
|
1028
|
+
pageCount += 1;
|
|
1029
|
+
}
|
|
1030
|
+
assertNoPagefindErrors("writeFiles", (await index.writeFiles({ outputPath: join(root, "pagefind") })).errors);
|
|
1031
|
+
console.log(`[clarify] Dev search index generated for ${pageCount} pages.`);
|
|
1032
|
+
} finally {
|
|
1033
|
+
await index.deleteIndex();
|
|
1034
|
+
await pagefind.close();
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
function normalizeDevPagefindPath(rawUrl, routePrefix) {
|
|
1038
|
+
const pathname = rawUrl?.split("?")[0];
|
|
1039
|
+
if (!pathname) return void 0;
|
|
1040
|
+
const normalizedPrefix = routePrefix && routePrefix !== "/" ? `/${routePrefix.replace(/^\/+|\/+$/g, "")}` : "";
|
|
1041
|
+
const pagefindPath = normalizedPrefix && pathname.startsWith(`${normalizedPrefix}/pagefind/`) ? pathname.slice(normalizedPrefix.length) : pathname;
|
|
1042
|
+
return pagefindPath.startsWith("/pagefind/") ? pagefindPath : void 0;
|
|
1043
|
+
}
|
|
1044
|
+
function serveDevPagefind(server, getRoot, ctx) {
|
|
1045
|
+
server.middlewares.use((req, res, next) => {
|
|
1046
|
+
const root = getRoot();
|
|
1047
|
+
const pagefindPath = normalizeDevPagefindPath(req.url, ctx.projectConfig.routePrefix);
|
|
1048
|
+
if (!root || !pagefindPath) {
|
|
1049
|
+
next();
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
const filePath = join(root, pagefindPath);
|
|
1053
|
+
const relativePath = relative(root, filePath);
|
|
1054
|
+
if (relativePath.startsWith("..") || relativePath === "" || !existsSync(filePath)) {
|
|
1055
|
+
next();
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
const contentType = pagefindContentTypes[extname(filePath)] ?? "application/octet-stream";
|
|
1059
|
+
res.setHeader("Content-Type", contentType);
|
|
1060
|
+
createReadStream(filePath).pipe(res);
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
function createSearchIndexPlugin() {
|
|
1064
|
+
return {
|
|
1065
|
+
name: "clarify:search-index",
|
|
1066
|
+
hooks: {
|
|
1067
|
+
async "dev:configureServer"(server, ctx) {
|
|
1068
|
+
let currentRoot;
|
|
1069
|
+
const staleRoots = /* @__PURE__ */ new Set();
|
|
1070
|
+
const replaceDevIndex = async () => {
|
|
1071
|
+
const nextRoot = createClarifyTempDir("pagefind");
|
|
1072
|
+
await generateDevSearchIndex(ctx, nextRoot);
|
|
1073
|
+
const previousRoot = currentRoot;
|
|
1074
|
+
currentRoot = nextRoot;
|
|
1075
|
+
if (previousRoot) {
|
|
1076
|
+
staleRoots.add(previousRoot);
|
|
1077
|
+
setTimeout(() => {
|
|
1078
|
+
staleRoots.delete(previousRoot);
|
|
1079
|
+
removeClarifyTempDir(previousRoot);
|
|
1080
|
+
}, 3e4).unref?.();
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
serveDevPagefind(server, () => currentRoot, ctx);
|
|
1084
|
+
await replaceDevIndex();
|
|
1085
|
+
let regenerateTimer;
|
|
1086
|
+
const regenerate = (filePath) => {
|
|
1087
|
+
if (!/\.(md|mdx|json|ya?ml)$/i.test(filePath)) return;
|
|
1088
|
+
if (regenerateTimer) clearTimeout(regenerateTimer);
|
|
1089
|
+
regenerateTimer = setTimeout(() => {
|
|
1090
|
+
replaceDevIndex().catch((err) => {
|
|
1091
|
+
console.error("[clarify] Failed to regenerate dev search index:", err);
|
|
1092
|
+
});
|
|
1093
|
+
}, 100);
|
|
1094
|
+
};
|
|
1095
|
+
server.watcher.on("add", regenerate);
|
|
1096
|
+
server.watcher.on("change", regenerate);
|
|
1097
|
+
server.watcher.on("unlink", regenerate);
|
|
1098
|
+
server.httpServer?.once("close", () => {
|
|
1099
|
+
if (regenerateTimer) clearTimeout(regenerateTimer);
|
|
1100
|
+
removeClarifyTempDir(currentRoot);
|
|
1101
|
+
for (const staleRoot of staleRoots) removeClarifyTempDir(staleRoot);
|
|
1102
|
+
});
|
|
1103
|
+
},
|
|
1104
|
+
async "build:done"(ctx) {
|
|
1105
|
+
const outputDirectory = ctx.generateOptions.outputDirectory;
|
|
1106
|
+
if (!outputDirectory) return;
|
|
1107
|
+
const pageCount = await generatePagefindIndex({ outputRoot: resolve(ctx.generateOptions.projectRoot, outputDirectory) });
|
|
1108
|
+
console.log(`[clarify] Search index generated for ${pageCount} pages.`);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
//#endregion
|
|
918
1114
|
//#region source/plugins/seo/artifacts.ts
|
|
919
1115
|
function trimTrailingSlash(value) {
|
|
920
1116
|
return value.replace(/\/+$/, "");
|
|
@@ -1010,7 +1206,8 @@ function createBuiltinPlugins(options = {}) {
|
|
|
1010
1206
|
createOpenAPIPlugin(),
|
|
1011
1207
|
createSourceLinksPlugin(),
|
|
1012
1208
|
createContentArtifactsPlugin(),
|
|
1013
|
-
createSeoPlugin()
|
|
1209
|
+
createSeoPlugin(),
|
|
1210
|
+
createSearchIndexPlugin()
|
|
1014
1211
|
];
|
|
1015
1212
|
if (options.htmlShell ?? true) plugins.push(createHtmlShellPlugin());
|
|
1016
1213
|
return plugins;
|
|
@@ -1064,15 +1261,18 @@ var clarifyNavbarLinkSchema = z.object({
|
|
|
1064
1261
|
href: z.string(),
|
|
1065
1262
|
external: z.boolean().optional()
|
|
1066
1263
|
});
|
|
1067
|
-
var
|
|
1264
|
+
var clarifyBannerConfigOptionsSchema = z.object({
|
|
1068
1265
|
content: clarifyLocalizedTextSchema,
|
|
1069
|
-
dismissible: z.boolean().optional()
|
|
1070
|
-
|
|
1071
|
-
|
|
1266
|
+
dismissible: z.boolean().optional(),
|
|
1267
|
+
link: clarifyNavbarLinkSchema.optional()
|
|
1268
|
+
}).strict();
|
|
1269
|
+
var clarifyBannerConfigSchema = z.union([clarifyBannerConfigOptionsSchema, z.string()]);
|
|
1270
|
+
var clarifyFooterLinksConfigSchema = z.object({
|
|
1072
1271
|
links: z.array(clarifyNavbarLinkSchema).optional(),
|
|
1073
1272
|
socials: z.record(z.string(), z.string()).optional(),
|
|
1074
1273
|
copyright: clarifyLocalizedTextSchema.optional()
|
|
1075
|
-
});
|
|
1274
|
+
}).strict();
|
|
1275
|
+
var clarifyFooterConfigSchema = z.union([clarifyFooterLinksConfigSchema, z.string()]);
|
|
1076
1276
|
var clarifySourceConfigSchema = z.object({
|
|
1077
1277
|
repository: z.string(),
|
|
1078
1278
|
branch: z.string().optional(),
|
|
@@ -1146,6 +1346,7 @@ var clarifyProjectConfigSchema = z.object({
|
|
|
1146
1346
|
siteUrl: z.string().optional(),
|
|
1147
1347
|
source: clarifySourceConfigSchema.optional(),
|
|
1148
1348
|
logo: clarifyLogoConfigSchema.optional(),
|
|
1349
|
+
homeUrl: z.string().optional(),
|
|
1149
1350
|
favicon: clarifyFaviconConfigSchema.optional(),
|
|
1150
1351
|
theme: clarifyThemeConfigSchema.optional(),
|
|
1151
1352
|
routePrefix: z.string().optional(),
|
|
@@ -1157,57 +1358,9 @@ var clarifyProjectConfigSchema = z.object({
|
|
|
1157
1358
|
});
|
|
1158
1359
|
//#endregion
|
|
1159
1360
|
//#region source/core/theme.ts
|
|
1160
|
-
var clarifyThemePresets = {
|
|
1161
|
-
default: {
|
|
1162
|
-
preset: "default",
|
|
1163
|
-
tokens: {
|
|
1164
|
-
colors: {
|
|
1165
|
-
primary: "#047857",
|
|
1166
|
-
accent: "#0D9488",
|
|
1167
|
-
background: "#ffffff",
|
|
1168
|
-
foreground: "#111827",
|
|
1169
|
-
surface: "#ffffff",
|
|
1170
|
-
muted: "#64748b",
|
|
1171
|
-
border: "rgb(15 23 42 / 0.12)",
|
|
1172
|
-
codeBackground: "#f6fbf8"
|
|
1173
|
-
},
|
|
1174
|
-
radius: {
|
|
1175
|
-
sm: "6px",
|
|
1176
|
-
md: "10px",
|
|
1177
|
-
lg: "14px",
|
|
1178
|
-
xl: "18px"
|
|
1179
|
-
}
|
|
1180
|
-
},
|
|
1181
|
-
layout: { maxWidth: "82rem" },
|
|
1182
|
-
editor: false
|
|
1183
|
-
},
|
|
1184
|
-
base: {
|
|
1185
|
-
preset: "base",
|
|
1186
|
-
tokens: {
|
|
1187
|
-
colors: {
|
|
1188
|
-
primary: "#18181b",
|
|
1189
|
-
accent: "#52525b",
|
|
1190
|
-
background: "#ffffff",
|
|
1191
|
-
foreground: "#18181b",
|
|
1192
|
-
surface: "#ffffff",
|
|
1193
|
-
muted: "#71717a",
|
|
1194
|
-
border: "rgb(24 24 27 / 0.12)",
|
|
1195
|
-
codeBackground: "#f4f4f5"
|
|
1196
|
-
},
|
|
1197
|
-
radius: {
|
|
1198
|
-
sm: "6px",
|
|
1199
|
-
md: "8px",
|
|
1200
|
-
lg: "12px",
|
|
1201
|
-
xl: "16px"
|
|
1202
|
-
}
|
|
1203
|
-
},
|
|
1204
|
-
layout: { maxWidth: "80rem" },
|
|
1205
|
-
editor: false
|
|
1206
|
-
}
|
|
1207
|
-
};
|
|
1208
1361
|
function resolveThemeConfig(theme = {}) {
|
|
1209
1362
|
const preset = theme.preset ?? "default";
|
|
1210
|
-
const presetTheme =
|
|
1363
|
+
const presetTheme = themePresets[preset];
|
|
1211
1364
|
return {
|
|
1212
1365
|
preset,
|
|
1213
1366
|
tokens: {
|
|
@@ -1266,6 +1419,7 @@ function resolveProjectConfig(config = {}) {
|
|
|
1266
1419
|
siteUrl: config.siteUrl,
|
|
1267
1420
|
source: config.source,
|
|
1268
1421
|
logo: config.logo,
|
|
1422
|
+
homeUrl: config.homeUrl,
|
|
1269
1423
|
favicon: config.favicon,
|
|
1270
1424
|
routePrefix: config.routePrefix ?? "/",
|
|
1271
1425
|
theme: resolveThemeConfig(config.theme),
|
|
@@ -1521,13 +1675,13 @@ function routeOutputFiles(outputDirectory, route) {
|
|
|
1521
1675
|
var SSR_ENTRY_CODE = `import { renderToHTML } from '@clarify-labs/renderer/server';
|
|
1522
1676
|
import { routes, navigation } from 'virtual:clarify-routes/server';
|
|
1523
1677
|
import { config } from 'virtual:clarify-config';
|
|
1524
|
-
import { openApis } from 'virtual:clarify-runtime';
|
|
1678
|
+
import { openApis, bannerComponent, footerComponent } from 'virtual:clarify-runtime';
|
|
1525
1679
|
|
|
1526
1680
|
export function render(url) {
|
|
1527
|
-
return renderToHTML({ config, routes, navigation, openApis, url, themeEditor: config.theme.editor });
|
|
1681
|
+
return renderToHTML({ config, routes, navigation, openApis, bannerComponent, footerComponent, url, themeEditor: config.theme.editor });
|
|
1528
1682
|
}`;
|
|
1529
1683
|
function createTempEntryFile(content) {
|
|
1530
|
-
const entryPath = join(
|
|
1684
|
+
const entryPath = join(createClarifyTempDir("ssr"), "entry-server.ts");
|
|
1531
1685
|
writeFileSync(entryPath, content, "utf-8");
|
|
1532
1686
|
return entryPath;
|
|
1533
1687
|
}
|
|
@@ -1567,6 +1721,7 @@ async function renderSSGRoutes(routes, projectConfig, outputDirectory, ssrBundle
|
|
|
1567
1721
|
//#endregion
|
|
1568
1722
|
//#region source/core/user-config.ts
|
|
1569
1723
|
function defineConfig(config) {
|
|
1724
|
+
validateProjectConfig(config);
|
|
1570
1725
|
return config;
|
|
1571
1726
|
}
|
|
1572
1727
|
var CONFIG_FILENAMES = [
|
|
@@ -1817,6 +1972,6 @@ function clarifyPlugin(options = {}) {
|
|
|
1817
1972
|
].flat().filter(Boolean);
|
|
1818
1973
|
}
|
|
1819
1974
|
//#endregion
|
|
1820
|
-
export { resolveClarifySite as a, createClarifyRuntimeAliases as i, defineConfig as n, loadClarifyConfig as r, clarifyPlugin as t };
|
|
1975
|
+
export { resolveClarifySite as a, createClarifyRuntimeAliases as i, defineConfig as n, createClarifyTempDir as o, loadClarifyConfig as r, clarifyPlugin as t };
|
|
1821
1976
|
|
|
1822
|
-
//# sourceMappingURL=plugin-
|
|
1977
|
+
//# sourceMappingURL=plugin-o1rP_gts.js.map
|