@clarify-labs/cli 0.6.5 → 0.6.6
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 +2 -2
- package/output/cli.cjs.map +1 -1
- package/output/cli.js +2 -2
- package/output/cli.js.map +1 -1
- package/output/index.cjs +1 -1
- package/output/index.js +1 -1
- package/output/parsers/mdx.d.ts +1 -1
- package/output/{plugin-BgE7WVoS.js → plugin-DC2f5YAH.js} +281 -276
- package/output/plugin-DC2f5YAH.js.map +1 -0
- package/output/{plugin-Dq1zHXan.cjs → plugin-GTN_SQ7d.cjs} +281 -276
- package/output/plugin-GTN_SQ7d.cjs.map +1 -0
- package/package.json +3 -3
- package/output/plugin-BgE7WVoS.js.map +0 -1
- package/output/plugin-Dq1zHXan.cjs.map +0 -1
|
@@ -8,11 +8,11 @@ import { toString } from "mdast-util-to-string";
|
|
|
8
8
|
import shiki from "shiki";
|
|
9
9
|
import { visit } from "unist-util-visit";
|
|
10
10
|
import { markdownRemarkPlugins } from "@clarify-labs/renderer";
|
|
11
|
-
import { z } from "zod";
|
|
12
11
|
import { remark } from "remark";
|
|
13
12
|
import matter from "gray-matter";
|
|
14
13
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
15
14
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
15
|
+
import { z } from "zod";
|
|
16
16
|
import { tmpdir } from "node:os";
|
|
17
17
|
import { pathToFileURL } from "node:url";
|
|
18
18
|
import { build, loadConfigFromFile } from "vite";
|
|
@@ -48,6 +48,11 @@ function rehypeParseCodeBlocks() {
|
|
|
48
48
|
const language = getLanguage(node.properties.className);
|
|
49
49
|
parentNode.properties.language = language;
|
|
50
50
|
node.properties.language = language;
|
|
51
|
+
for (const key of [
|
|
52
|
+
"title",
|
|
53
|
+
"tag",
|
|
54
|
+
"label"
|
|
55
|
+
]) if (node.properties[key] !== void 0) parentNode.properties[key] = node.properties[key];
|
|
51
56
|
});
|
|
52
57
|
};
|
|
53
58
|
}
|
|
@@ -101,284 +106,25 @@ var rehypePlugins = [
|
|
|
101
106
|
rehypeShiki
|
|
102
107
|
];
|
|
103
108
|
//#endregion
|
|
104
|
-
//#region source/
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
var clarifyFaviconConfigSchema = z.union([z.string(), z.object({
|
|
110
|
-
light: z.string().optional(),
|
|
111
|
-
dark: z.string().optional()
|
|
112
|
-
})]);
|
|
113
|
-
var clarifyLocalizedTextSchema = z.union([z.string(), z.record(z.string(), z.string())]);
|
|
114
|
-
var clarifyLocaleConfigSchema = z.object({
|
|
115
|
-
code: z.string(),
|
|
116
|
-
label: z.string(),
|
|
117
|
-
dir: z.union([z.literal("ltr"), z.literal("rtl")]).optional()
|
|
118
|
-
});
|
|
119
|
-
var clarifyI18nConfigSchema = z.object({
|
|
120
|
-
defaultLocale: z.string().optional(),
|
|
121
|
-
missing: z.union([
|
|
122
|
-
z.literal("fallback"),
|
|
123
|
-
z.literal("404"),
|
|
124
|
-
z.literal("hide")
|
|
125
|
-
]).optional(),
|
|
126
|
-
locales: z.array(clarifyLocaleConfigSchema).min(1)
|
|
127
|
-
}).superRefine((config, ctx) => {
|
|
128
|
-
const localeCodes = /* @__PURE__ */ new Set();
|
|
129
|
-
for (const [index, locale] of config.locales.entries()) {
|
|
130
|
-
if (localeCodes.has(locale.code)) ctx.addIssue({
|
|
131
|
-
code: z.ZodIssueCode.custom,
|
|
132
|
-
message: `Duplicate locale code "${locale.code}"`,
|
|
133
|
-
path: [
|
|
134
|
-
"locales",
|
|
135
|
-
index,
|
|
136
|
-
"code"
|
|
137
|
-
]
|
|
138
|
-
});
|
|
139
|
-
localeCodes.add(locale.code);
|
|
140
|
-
}
|
|
141
|
-
if (config.defaultLocale && !localeCodes.has(config.defaultLocale)) ctx.addIssue({
|
|
142
|
-
code: z.ZodIssueCode.custom,
|
|
143
|
-
message: "defaultLocale must be one of i18n.locales",
|
|
144
|
-
path: ["defaultLocale"]
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
var clarifyNavbarLinkSchema = z.object({
|
|
148
|
-
label: clarifyLocalizedTextSchema,
|
|
149
|
-
href: z.string(),
|
|
150
|
-
external: z.boolean().optional()
|
|
151
|
-
});
|
|
152
|
-
var clarifyBannerConfigSchema = z.object({
|
|
153
|
-
content: clarifyLocalizedTextSchema,
|
|
154
|
-
dismissible: z.boolean().optional()
|
|
155
|
-
});
|
|
156
|
-
var clarifyFooterConfigSchema = z.object({
|
|
157
|
-
links: z.array(clarifyNavbarLinkSchema).optional(),
|
|
158
|
-
socials: z.record(z.string(), z.string()).optional(),
|
|
159
|
-
copyright: clarifyLocalizedTextSchema.optional()
|
|
160
|
-
});
|
|
161
|
-
var clarifySourceConfigSchema = z.object({
|
|
162
|
-
repository: z.string(),
|
|
163
|
-
branch: z.string().optional(),
|
|
164
|
-
directory: z.string().optional()
|
|
165
|
-
});
|
|
166
|
-
var clarifyPagesItemSchema = z.union([
|
|
167
|
-
z.string(),
|
|
168
|
-
z.object({
|
|
169
|
-
page: z.string(),
|
|
170
|
-
title: clarifyLocalizedTextSchema.optional(),
|
|
171
|
-
icon: z.string().optional(),
|
|
172
|
-
redirect: z.string().optional()
|
|
173
|
-
}),
|
|
174
|
-
z.object({
|
|
175
|
-
openapi: z.string(),
|
|
176
|
-
icon: z.string().optional(),
|
|
177
|
-
title: clarifyLocalizedTextSchema.optional(),
|
|
178
|
-
filter: z.object({ tags: z.array(z.string()).optional() }).optional()
|
|
179
|
-
})
|
|
180
|
-
]);
|
|
181
|
-
var clarifyPagesGroupSchema = z.object({
|
|
182
|
-
group: clarifyLocalizedTextSchema,
|
|
183
|
-
icon: z.string().optional(),
|
|
184
|
-
pages: z.array(clarifyPagesItemSchema)
|
|
185
|
-
});
|
|
186
|
-
var clarifyPagesConfigSchema = z.union([z.array(clarifyPagesGroupSchema), z.literal("FileTree")]);
|
|
187
|
-
var clarifyTabItemSchema = z.object({
|
|
188
|
-
tab: clarifyLocalizedTextSchema,
|
|
189
|
-
icon: z.string().optional(),
|
|
190
|
-
pages: clarifyPagesConfigSchema.optional()
|
|
191
|
-
});
|
|
192
|
-
var clarifyTabsConfigSchema = z.array(clarifyTabItemSchema);
|
|
193
|
-
var clarifyThemePresetSchema = z.enum(["default", "base"]);
|
|
194
|
-
var clarifyThemeModeColorValueSchema = z.object({
|
|
195
|
-
light: z.string().optional(),
|
|
196
|
-
dark: z.string().optional()
|
|
197
|
-
});
|
|
198
|
-
var clarifyThemeColorValueSchema = z.union([z.string(), clarifyThemeModeColorValueSchema]);
|
|
199
|
-
var clarifyThemeColorTokensConfigSchema = z.object({
|
|
200
|
-
primary: clarifyThemeColorValueSchema.optional(),
|
|
201
|
-
accent: clarifyThemeColorValueSchema.optional(),
|
|
202
|
-
background: clarifyThemeColorValueSchema.optional(),
|
|
203
|
-
foreground: clarifyThemeColorValueSchema.optional(),
|
|
204
|
-
surface: clarifyThemeColorValueSchema.optional(),
|
|
205
|
-
muted: clarifyThemeColorValueSchema.optional(),
|
|
206
|
-
border: clarifyThemeColorValueSchema.optional(),
|
|
207
|
-
codeBackground: clarifyThemeColorValueSchema.optional()
|
|
208
|
-
});
|
|
209
|
-
var clarifyThemeRadiusTokensConfigSchema = z.object({
|
|
210
|
-
sm: z.string().optional(),
|
|
211
|
-
md: z.string().optional(),
|
|
212
|
-
lg: z.string().optional(),
|
|
213
|
-
xl: z.string().optional()
|
|
214
|
-
});
|
|
215
|
-
var clarifyThemeTokensConfigSchema = z.object({
|
|
216
|
-
colors: clarifyThemeColorTokensConfigSchema.optional(),
|
|
217
|
-
radius: clarifyThemeRadiusTokensConfigSchema.optional()
|
|
218
|
-
});
|
|
219
|
-
var clarifyThemeLayoutConfigSchema = z.object({ maxWidth: z.string().optional() });
|
|
220
|
-
var clarifyThemeConfigSchema = z.object({
|
|
221
|
-
preset: clarifyThemePresetSchema.optional(),
|
|
222
|
-
tokens: clarifyThemeTokensConfigSchema.optional(),
|
|
223
|
-
layout: clarifyThemeLayoutConfigSchema.optional(),
|
|
224
|
-
editor: z.boolean().optional()
|
|
225
|
-
});
|
|
226
|
-
var clarifyProjectConfigSchema = z.object({
|
|
227
|
-
title: z.string().optional(),
|
|
228
|
-
description: z.string().optional(),
|
|
229
|
-
siteUrl: z.string().optional(),
|
|
230
|
-
source: clarifySourceConfigSchema.optional(),
|
|
231
|
-
logo: clarifyLogoConfigSchema.optional(),
|
|
232
|
-
favicon: clarifyFaviconConfigSchema.optional(),
|
|
233
|
-
theme: clarifyThemeConfigSchema.optional(),
|
|
234
|
-
routePrefix: z.string().optional(),
|
|
235
|
-
navbar: z.object({ links: z.array(clarifyNavbarLinkSchema).optional() }).optional(),
|
|
236
|
-
banner: clarifyBannerConfigSchema.optional(),
|
|
237
|
-
footer: clarifyFooterConfigSchema.optional(),
|
|
238
|
-
i18n: clarifyI18nConfigSchema.optional(),
|
|
239
|
-
tabs: clarifyTabsConfigSchema.optional()
|
|
240
|
-
});
|
|
241
|
-
//#endregion
|
|
242
|
-
//#region source/core/theme.ts
|
|
243
|
-
var clarifyThemePresets = {
|
|
244
|
-
default: {
|
|
245
|
-
preset: "default",
|
|
246
|
-
tokens: {
|
|
247
|
-
colors: {
|
|
248
|
-
primary: "#047857",
|
|
249
|
-
accent: "#0D9488",
|
|
250
|
-
background: "#ffffff",
|
|
251
|
-
foreground: "#111827",
|
|
252
|
-
surface: "#ffffff",
|
|
253
|
-
muted: "#64748b",
|
|
254
|
-
border: "rgb(15 23 42 / 0.12)",
|
|
255
|
-
codeBackground: "#f6fbf8"
|
|
256
|
-
},
|
|
257
|
-
radius: {
|
|
258
|
-
sm: "6px",
|
|
259
|
-
md: "10px",
|
|
260
|
-
lg: "14px",
|
|
261
|
-
xl: "18px"
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
layout: { maxWidth: "82rem" },
|
|
265
|
-
editor: false
|
|
266
|
-
},
|
|
267
|
-
base: {
|
|
268
|
-
preset: "base",
|
|
269
|
-
tokens: {
|
|
270
|
-
colors: {
|
|
271
|
-
primary: "#18181b",
|
|
272
|
-
accent: "#52525b",
|
|
273
|
-
background: "#ffffff",
|
|
274
|
-
foreground: "#18181b",
|
|
275
|
-
surface: "#ffffff",
|
|
276
|
-
muted: "#71717a",
|
|
277
|
-
border: "rgb(24 24 27 / 0.12)",
|
|
278
|
-
codeBackground: "#f4f4f5"
|
|
279
|
-
},
|
|
280
|
-
radius: {
|
|
281
|
-
sm: "6px",
|
|
282
|
-
md: "8px",
|
|
283
|
-
lg: "12px",
|
|
284
|
-
xl: "16px"
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
layout: { maxWidth: "80rem" },
|
|
288
|
-
editor: false
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
function resolveThemeConfig(theme = {}) {
|
|
292
|
-
const preset = theme.preset ?? "default";
|
|
293
|
-
const presetTheme = clarifyThemePresets[preset];
|
|
294
|
-
return {
|
|
295
|
-
preset,
|
|
296
|
-
tokens: {
|
|
297
|
-
colors: {
|
|
298
|
-
...presetTheme.tokens.colors,
|
|
299
|
-
...theme.tokens?.colors
|
|
300
|
-
},
|
|
301
|
-
radius: {
|
|
302
|
-
...presetTheme.tokens.radius,
|
|
303
|
-
...theme.tokens?.radius
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
layout: {
|
|
307
|
-
...presetTheme.layout,
|
|
308
|
-
...theme.layout
|
|
309
|
-
},
|
|
310
|
-
editor: theme.editor ?? presetTheme.editor
|
|
311
|
-
};
|
|
109
|
+
//#region source/plugins/content-artifacts/artifacts.ts
|
|
110
|
+
var UTF8_SIGNATURE = "";
|
|
111
|
+
function normalizeBasePath(basePath) {
|
|
112
|
+
if (!basePath || basePath === "/") return "";
|
|
113
|
+
return "/" + basePath.replace(/^\/+|\/+$/g, "");
|
|
312
114
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
function formatIssuePath(path) {
|
|
316
|
-
return path.reduce((result, segment) => {
|
|
317
|
-
if (typeof segment === "number") return `${result}[${segment}]`;
|
|
318
|
-
const key = String(segment);
|
|
319
|
-
return result ? `${result}.${key}` : key;
|
|
320
|
-
}, "");
|
|
115
|
+
function containsNonAscii(content) {
|
|
116
|
+
return [...content].some((character) => character.codePointAt(0) > 127);
|
|
321
117
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const path = formatIssuePath(issue.path);
|
|
326
|
-
if (!path) return `[clarify] config must contain an object: ${issue.message}`;
|
|
327
|
-
return `[clarify] config field "${path}" is invalid: ${issue.message}`;
|
|
118
|
+
function withUtf8Signature(content) {
|
|
119
|
+
if (!containsNonAscii(content) || content.startsWith(UTF8_SIGNATURE)) return content;
|
|
120
|
+
return `${UTF8_SIGNATURE}${content}`;
|
|
328
121
|
}
|
|
329
|
-
function
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return result.data;
|
|
122
|
+
function shouldUseUtf8Signature(route) {
|
|
123
|
+
if (route.kind === "mdx") return true;
|
|
124
|
+
return /\.ya?ml$/i.test(route.contentArtifactUrl ?? "");
|
|
333
125
|
}
|
|
334
|
-
function
|
|
335
|
-
|
|
336
|
-
const firstLocale = i18n.locales[0]?.code;
|
|
337
|
-
const defaultLocale = i18n.defaultLocale ?? firstLocale;
|
|
338
|
-
if (!defaultLocale) return void 0;
|
|
339
|
-
return {
|
|
340
|
-
defaultLocale,
|
|
341
|
-
missing: i18n.missing ?? "fallback",
|
|
342
|
-
locales: i18n.locales
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
function resolveProjectConfig(config = {}) {
|
|
346
|
-
return {
|
|
347
|
-
title: config.title ?? "Clarify Docs",
|
|
348
|
-
description: config.description ?? "",
|
|
349
|
-
siteUrl: config.siteUrl,
|
|
350
|
-
source: config.source,
|
|
351
|
-
logo: config.logo,
|
|
352
|
-
favicon: config.favicon,
|
|
353
|
-
routePrefix: config.routePrefix ?? "/",
|
|
354
|
-
theme: resolveThemeConfig(config.theme),
|
|
355
|
-
navbar: config.navbar,
|
|
356
|
-
banner: config.banner,
|
|
357
|
-
footer: config.footer,
|
|
358
|
-
i18n: resolveI18nConfig(config.i18n),
|
|
359
|
-
tabs: config.tabs
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
//#endregion
|
|
363
|
-
//#region source/plugins/content-artifacts/artifacts.ts
|
|
364
|
-
var UTF8_SIGNATURE = "";
|
|
365
|
-
function normalizeBasePath(basePath) {
|
|
366
|
-
if (!basePath || basePath === "/") return "";
|
|
367
|
-
return "/" + basePath.replace(/^\/+|\/+$/g, "");
|
|
368
|
-
}
|
|
369
|
-
function containsNonAscii(content) {
|
|
370
|
-
return [...content].some((character) => character.codePointAt(0) > 127);
|
|
371
|
-
}
|
|
372
|
-
function withUtf8Signature(content) {
|
|
373
|
-
if (!containsNonAscii(content) || content.startsWith(UTF8_SIGNATURE)) return content;
|
|
374
|
-
return `${UTF8_SIGNATURE}${content}`;
|
|
375
|
-
}
|
|
376
|
-
function shouldUseUtf8Signature(route) {
|
|
377
|
-
if (route.kind === "mdx") return true;
|
|
378
|
-
return /\.ya?ml$/i.test(route.contentArtifactUrl ?? "");
|
|
379
|
-
}
|
|
380
|
-
function routeToMarkdownArtifactUrl(routePath) {
|
|
381
|
-
return `${routePath === "/" ? "/index" : routePath.replace(/\/$/, "")}.md`;
|
|
126
|
+
function routeToMarkdownArtifactUrl(routePath) {
|
|
127
|
+
return `${routePath === "/" ? "/index" : routePath.replace(/\/$/, "")}.md`;
|
|
382
128
|
}
|
|
383
129
|
function routeToOpenAPIArtifactUrl(routePath, filePath) {
|
|
384
130
|
const extension = extname(filePath).toLowerCase() || ".json";
|
|
@@ -1217,6 +963,265 @@ function createBuiltinPlugins(options = {}) {
|
|
|
1217
963
|
return plugins;
|
|
1218
964
|
}
|
|
1219
965
|
//#endregion
|
|
966
|
+
//#region source/core/config-schema.ts
|
|
967
|
+
var clarifyLogoConfigSchema = z.union([z.string(), z.object({
|
|
968
|
+
light: z.string().optional(),
|
|
969
|
+
dark: z.string().optional()
|
|
970
|
+
})]);
|
|
971
|
+
var clarifyFaviconConfigSchema = z.union([z.string(), z.object({
|
|
972
|
+
light: z.string().optional(),
|
|
973
|
+
dark: z.string().optional()
|
|
974
|
+
})]);
|
|
975
|
+
var clarifyLocalizedTextSchema = z.union([z.string(), z.record(z.string(), z.string())]);
|
|
976
|
+
var clarifyLocaleConfigSchema = z.object({
|
|
977
|
+
code: z.string(),
|
|
978
|
+
label: z.string(),
|
|
979
|
+
dir: z.union([z.literal("ltr"), z.literal("rtl")]).optional()
|
|
980
|
+
});
|
|
981
|
+
var clarifyI18nConfigSchema = z.object({
|
|
982
|
+
defaultLocale: z.string().optional(),
|
|
983
|
+
missing: z.union([
|
|
984
|
+
z.literal("fallback"),
|
|
985
|
+
z.literal("404"),
|
|
986
|
+
z.literal("hide")
|
|
987
|
+
]).optional(),
|
|
988
|
+
locales: z.array(clarifyLocaleConfigSchema).min(1)
|
|
989
|
+
}).superRefine((config, ctx) => {
|
|
990
|
+
const localeCodes = /* @__PURE__ */ new Set();
|
|
991
|
+
for (const [index, locale] of config.locales.entries()) {
|
|
992
|
+
if (localeCodes.has(locale.code)) ctx.addIssue({
|
|
993
|
+
code: z.ZodIssueCode.custom,
|
|
994
|
+
message: `Duplicate locale code "${locale.code}"`,
|
|
995
|
+
path: [
|
|
996
|
+
"locales",
|
|
997
|
+
index,
|
|
998
|
+
"code"
|
|
999
|
+
]
|
|
1000
|
+
});
|
|
1001
|
+
localeCodes.add(locale.code);
|
|
1002
|
+
}
|
|
1003
|
+
if (config.defaultLocale && !localeCodes.has(config.defaultLocale)) ctx.addIssue({
|
|
1004
|
+
code: z.ZodIssueCode.custom,
|
|
1005
|
+
message: "defaultLocale must be one of i18n.locales",
|
|
1006
|
+
path: ["defaultLocale"]
|
|
1007
|
+
});
|
|
1008
|
+
});
|
|
1009
|
+
var clarifyNavbarLinkSchema = z.object({
|
|
1010
|
+
label: clarifyLocalizedTextSchema,
|
|
1011
|
+
href: z.string(),
|
|
1012
|
+
external: z.boolean().optional()
|
|
1013
|
+
});
|
|
1014
|
+
var clarifyBannerConfigSchema = z.object({
|
|
1015
|
+
content: clarifyLocalizedTextSchema,
|
|
1016
|
+
dismissible: z.boolean().optional()
|
|
1017
|
+
});
|
|
1018
|
+
var clarifyFooterConfigSchema = z.object({
|
|
1019
|
+
links: z.array(clarifyNavbarLinkSchema).optional(),
|
|
1020
|
+
socials: z.record(z.string(), z.string()).optional(),
|
|
1021
|
+
copyright: clarifyLocalizedTextSchema.optional()
|
|
1022
|
+
});
|
|
1023
|
+
var clarifySourceConfigSchema = z.object({
|
|
1024
|
+
repository: z.string(),
|
|
1025
|
+
branch: z.string().optional(),
|
|
1026
|
+
directory: z.string().optional()
|
|
1027
|
+
});
|
|
1028
|
+
var clarifyPagesItemSchema = z.union([
|
|
1029
|
+
z.string(),
|
|
1030
|
+
z.object({
|
|
1031
|
+
page: z.string(),
|
|
1032
|
+
title: clarifyLocalizedTextSchema.optional(),
|
|
1033
|
+
icon: z.string().optional(),
|
|
1034
|
+
redirect: z.string().optional()
|
|
1035
|
+
}),
|
|
1036
|
+
z.object({
|
|
1037
|
+
openapi: z.string(),
|
|
1038
|
+
icon: z.string().optional(),
|
|
1039
|
+
title: clarifyLocalizedTextSchema.optional(),
|
|
1040
|
+
filter: z.object({ tags: z.array(z.string()).optional() }).optional()
|
|
1041
|
+
})
|
|
1042
|
+
]);
|
|
1043
|
+
var clarifyPagesGroupSchema = z.object({
|
|
1044
|
+
group: clarifyLocalizedTextSchema,
|
|
1045
|
+
icon: z.string().optional(),
|
|
1046
|
+
pages: z.array(clarifyPagesItemSchema)
|
|
1047
|
+
});
|
|
1048
|
+
var clarifyPagesConfigSchema = z.union([z.array(clarifyPagesGroupSchema), z.literal("FileTree")]);
|
|
1049
|
+
var clarifyTabItemSchema = z.object({
|
|
1050
|
+
tab: clarifyLocalizedTextSchema,
|
|
1051
|
+
icon: z.string().optional(),
|
|
1052
|
+
pages: clarifyPagesConfigSchema.optional()
|
|
1053
|
+
});
|
|
1054
|
+
var clarifyTabsConfigSchema = z.array(clarifyTabItemSchema);
|
|
1055
|
+
var clarifyThemePresetSchema = z.enum(["default", "base"]);
|
|
1056
|
+
var clarifyThemeModeColorValueSchema = z.object({
|
|
1057
|
+
light: z.string().optional(),
|
|
1058
|
+
dark: z.string().optional()
|
|
1059
|
+
});
|
|
1060
|
+
var clarifyThemeColorValueSchema = z.union([z.string(), clarifyThemeModeColorValueSchema]);
|
|
1061
|
+
var clarifyThemeColorTokensConfigSchema = z.object({
|
|
1062
|
+
primary: clarifyThemeColorValueSchema.optional(),
|
|
1063
|
+
accent: clarifyThemeColorValueSchema.optional(),
|
|
1064
|
+
background: clarifyThemeColorValueSchema.optional(),
|
|
1065
|
+
foreground: clarifyThemeColorValueSchema.optional(),
|
|
1066
|
+
surface: clarifyThemeColorValueSchema.optional(),
|
|
1067
|
+
muted: clarifyThemeColorValueSchema.optional(),
|
|
1068
|
+
border: clarifyThemeColorValueSchema.optional(),
|
|
1069
|
+
codeBackground: clarifyThemeColorValueSchema.optional()
|
|
1070
|
+
});
|
|
1071
|
+
var clarifyThemeRadiusTokensConfigSchema = z.object({
|
|
1072
|
+
sm: z.string().optional(),
|
|
1073
|
+
md: z.string().optional(),
|
|
1074
|
+
lg: z.string().optional(),
|
|
1075
|
+
xl: z.string().optional()
|
|
1076
|
+
});
|
|
1077
|
+
var clarifyThemeTokensConfigSchema = z.object({
|
|
1078
|
+
colors: clarifyThemeColorTokensConfigSchema.optional(),
|
|
1079
|
+
radius: clarifyThemeRadiusTokensConfigSchema.optional()
|
|
1080
|
+
});
|
|
1081
|
+
var clarifyThemeLayoutConfigSchema = z.object({ maxWidth: z.string().optional() });
|
|
1082
|
+
var clarifyThemeConfigSchema = z.object({
|
|
1083
|
+
preset: clarifyThemePresetSchema.optional(),
|
|
1084
|
+
tokens: clarifyThemeTokensConfigSchema.optional(),
|
|
1085
|
+
layout: clarifyThemeLayoutConfigSchema.optional(),
|
|
1086
|
+
editor: z.boolean().optional()
|
|
1087
|
+
});
|
|
1088
|
+
var clarifyProjectConfigSchema = z.object({
|
|
1089
|
+
title: z.string().optional(),
|
|
1090
|
+
description: z.string().optional(),
|
|
1091
|
+
siteUrl: z.string().optional(),
|
|
1092
|
+
source: clarifySourceConfigSchema.optional(),
|
|
1093
|
+
logo: clarifyLogoConfigSchema.optional(),
|
|
1094
|
+
favicon: clarifyFaviconConfigSchema.optional(),
|
|
1095
|
+
theme: clarifyThemeConfigSchema.optional(),
|
|
1096
|
+
routePrefix: z.string().optional(),
|
|
1097
|
+
navbar: z.object({ links: z.array(clarifyNavbarLinkSchema).optional() }).optional(),
|
|
1098
|
+
banner: clarifyBannerConfigSchema.optional(),
|
|
1099
|
+
footer: clarifyFooterConfigSchema.optional(),
|
|
1100
|
+
i18n: clarifyI18nConfigSchema.optional(),
|
|
1101
|
+
tabs: clarifyTabsConfigSchema.optional()
|
|
1102
|
+
});
|
|
1103
|
+
//#endregion
|
|
1104
|
+
//#region source/core/theme.ts
|
|
1105
|
+
var clarifyThemePresets = {
|
|
1106
|
+
default: {
|
|
1107
|
+
preset: "default",
|
|
1108
|
+
tokens: {
|
|
1109
|
+
colors: {
|
|
1110
|
+
primary: "#047857",
|
|
1111
|
+
accent: "#0D9488",
|
|
1112
|
+
background: "#ffffff",
|
|
1113
|
+
foreground: "#111827",
|
|
1114
|
+
surface: "#ffffff",
|
|
1115
|
+
muted: "#64748b",
|
|
1116
|
+
border: "rgb(15 23 42 / 0.12)",
|
|
1117
|
+
codeBackground: "#f6fbf8"
|
|
1118
|
+
},
|
|
1119
|
+
radius: {
|
|
1120
|
+
sm: "6px",
|
|
1121
|
+
md: "10px",
|
|
1122
|
+
lg: "14px",
|
|
1123
|
+
xl: "18px"
|
|
1124
|
+
}
|
|
1125
|
+
},
|
|
1126
|
+
layout: { maxWidth: "82rem" },
|
|
1127
|
+
editor: false
|
|
1128
|
+
},
|
|
1129
|
+
base: {
|
|
1130
|
+
preset: "base",
|
|
1131
|
+
tokens: {
|
|
1132
|
+
colors: {
|
|
1133
|
+
primary: "#18181b",
|
|
1134
|
+
accent: "#52525b",
|
|
1135
|
+
background: "#ffffff",
|
|
1136
|
+
foreground: "#18181b",
|
|
1137
|
+
surface: "#ffffff",
|
|
1138
|
+
muted: "#71717a",
|
|
1139
|
+
border: "rgb(24 24 27 / 0.12)",
|
|
1140
|
+
codeBackground: "#f4f4f5"
|
|
1141
|
+
},
|
|
1142
|
+
radius: {
|
|
1143
|
+
sm: "6px",
|
|
1144
|
+
md: "8px",
|
|
1145
|
+
lg: "12px",
|
|
1146
|
+
xl: "16px"
|
|
1147
|
+
}
|
|
1148
|
+
},
|
|
1149
|
+
layout: { maxWidth: "80rem" },
|
|
1150
|
+
editor: false
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
function resolveThemeConfig(theme = {}) {
|
|
1154
|
+
const preset = theme.preset ?? "default";
|
|
1155
|
+
const presetTheme = clarifyThemePresets[preset];
|
|
1156
|
+
return {
|
|
1157
|
+
preset,
|
|
1158
|
+
tokens: {
|
|
1159
|
+
colors: {
|
|
1160
|
+
...presetTheme.tokens.colors,
|
|
1161
|
+
...theme.tokens?.colors
|
|
1162
|
+
},
|
|
1163
|
+
radius: {
|
|
1164
|
+
...presetTheme.tokens.radius,
|
|
1165
|
+
...theme.tokens?.radius
|
|
1166
|
+
}
|
|
1167
|
+
},
|
|
1168
|
+
layout: {
|
|
1169
|
+
...presetTheme.layout,
|
|
1170
|
+
...theme.layout
|
|
1171
|
+
},
|
|
1172
|
+
editor: theme.editor ?? presetTheme.editor
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
//#endregion
|
|
1176
|
+
//#region source/core/config.ts
|
|
1177
|
+
function formatIssuePath(path) {
|
|
1178
|
+
return path.reduce((result, segment) => {
|
|
1179
|
+
if (typeof segment === "number") return `${result}[${segment}]`;
|
|
1180
|
+
const key = String(segment);
|
|
1181
|
+
return result ? `${result}.${key}` : key;
|
|
1182
|
+
}, "");
|
|
1183
|
+
}
|
|
1184
|
+
function formatProjectConfigError(error) {
|
|
1185
|
+
const issue = error.issues[0];
|
|
1186
|
+
if (!issue) return "[clarify] config is invalid";
|
|
1187
|
+
const path = formatIssuePath(issue.path);
|
|
1188
|
+
if (!path) return `[clarify] config must contain an object: ${issue.message}`;
|
|
1189
|
+
return `[clarify] config field "${path}" is invalid: ${issue.message}`;
|
|
1190
|
+
}
|
|
1191
|
+
function validateProjectConfig(value) {
|
|
1192
|
+
const result = clarifyProjectConfigSchema.safeParse(value);
|
|
1193
|
+
if (!result.success) throw new Error(formatProjectConfigError(result.error));
|
|
1194
|
+
return result.data;
|
|
1195
|
+
}
|
|
1196
|
+
function resolveI18nConfig(i18n) {
|
|
1197
|
+
if (!i18n) return void 0;
|
|
1198
|
+
const firstLocale = i18n.locales[0]?.code;
|
|
1199
|
+
const defaultLocale = i18n.defaultLocale ?? firstLocale;
|
|
1200
|
+
if (!defaultLocale) return void 0;
|
|
1201
|
+
return {
|
|
1202
|
+
defaultLocale,
|
|
1203
|
+
missing: i18n.missing ?? "fallback",
|
|
1204
|
+
locales: i18n.locales
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
function resolveProjectConfig(config = {}) {
|
|
1208
|
+
return {
|
|
1209
|
+
title: config.title ?? "Clarify Docs",
|
|
1210
|
+
description: config.description ?? "",
|
|
1211
|
+
siteUrl: config.siteUrl,
|
|
1212
|
+
source: config.source,
|
|
1213
|
+
logo: config.logo,
|
|
1214
|
+
favicon: config.favicon,
|
|
1215
|
+
routePrefix: config.routePrefix ?? "/",
|
|
1216
|
+
theme: resolveThemeConfig(config.theme),
|
|
1217
|
+
navbar: config.navbar,
|
|
1218
|
+
banner: config.banner,
|
|
1219
|
+
footer: config.footer,
|
|
1220
|
+
i18n: resolveI18nConfig(config.i18n),
|
|
1221
|
+
tabs: config.tabs
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
//#endregion
|
|
1220
1225
|
//#region source/core/hooks.ts
|
|
1221
1226
|
async function runHooks(plugins, hookName, input, ctx) {
|
|
1222
1227
|
let result = input;
|
|
@@ -1758,4 +1763,4 @@ function clarifyPlugin(options = {}) {
|
|
|
1758
1763
|
//#endregion
|
|
1759
1764
|
export { resolveClarifySite as a, createClarifyRuntimeAliases as i, defineConfig as n, loadClarifyConfig as r, clarifyPlugin as t };
|
|
1760
1765
|
|
|
1761
|
-
//# sourceMappingURL=plugin-
|
|
1766
|
+
//# sourceMappingURL=plugin-DC2f5YAH.js.map
|