@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
|
@@ -35,13 +35,13 @@ let shiki = require("shiki");
|
|
|
35
35
|
shiki = __toESM(shiki, 1);
|
|
36
36
|
let unist_util_visit = require("unist-util-visit");
|
|
37
37
|
let _clarify_labs_renderer = require("@clarify-labs/renderer");
|
|
38
|
-
let zod = require("zod");
|
|
39
38
|
let remark = require("remark");
|
|
40
39
|
let gray_matter = require("gray-matter");
|
|
41
40
|
gray_matter = __toESM(gray_matter, 1);
|
|
42
41
|
let _apidevtools_swagger_parser = require("@apidevtools/swagger-parser");
|
|
43
42
|
_apidevtools_swagger_parser = __toESM(_apidevtools_swagger_parser, 1);
|
|
44
43
|
let node_fs_promises = require("node:fs/promises");
|
|
44
|
+
let zod = require("zod");
|
|
45
45
|
let node_os = require("node:os");
|
|
46
46
|
let node_url = require("node:url");
|
|
47
47
|
let vite = require("vite");
|
|
@@ -77,6 +77,11 @@ function rehypeParseCodeBlocks() {
|
|
|
77
77
|
const language = getLanguage(node.properties.className);
|
|
78
78
|
parentNode.properties.language = language;
|
|
79
79
|
node.properties.language = language;
|
|
80
|
+
for (const key of [
|
|
81
|
+
"title",
|
|
82
|
+
"tag",
|
|
83
|
+
"label"
|
|
84
|
+
]) if (node.properties[key] !== void 0) parentNode.properties[key] = node.properties[key];
|
|
80
85
|
});
|
|
81
86
|
};
|
|
82
87
|
}
|
|
@@ -130,284 +135,25 @@ var rehypePlugins = [
|
|
|
130
135
|
rehypeShiki
|
|
131
136
|
];
|
|
132
137
|
//#endregion
|
|
133
|
-
//#region source/
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
var clarifyFaviconConfigSchema = zod.z.union([zod.z.string(), zod.z.object({
|
|
139
|
-
light: zod.z.string().optional(),
|
|
140
|
-
dark: zod.z.string().optional()
|
|
141
|
-
})]);
|
|
142
|
-
var clarifyLocalizedTextSchema = zod.z.union([zod.z.string(), zod.z.record(zod.z.string(), zod.z.string())]);
|
|
143
|
-
var clarifyLocaleConfigSchema = zod.z.object({
|
|
144
|
-
code: zod.z.string(),
|
|
145
|
-
label: zod.z.string(),
|
|
146
|
-
dir: zod.z.union([zod.z.literal("ltr"), zod.z.literal("rtl")]).optional()
|
|
147
|
-
});
|
|
148
|
-
var clarifyI18nConfigSchema = zod.z.object({
|
|
149
|
-
defaultLocale: zod.z.string().optional(),
|
|
150
|
-
missing: zod.z.union([
|
|
151
|
-
zod.z.literal("fallback"),
|
|
152
|
-
zod.z.literal("404"),
|
|
153
|
-
zod.z.literal("hide")
|
|
154
|
-
]).optional(),
|
|
155
|
-
locales: zod.z.array(clarifyLocaleConfigSchema).min(1)
|
|
156
|
-
}).superRefine((config, ctx) => {
|
|
157
|
-
const localeCodes = /* @__PURE__ */ new Set();
|
|
158
|
-
for (const [index, locale] of config.locales.entries()) {
|
|
159
|
-
if (localeCodes.has(locale.code)) ctx.addIssue({
|
|
160
|
-
code: zod.z.ZodIssueCode.custom,
|
|
161
|
-
message: `Duplicate locale code "${locale.code}"`,
|
|
162
|
-
path: [
|
|
163
|
-
"locales",
|
|
164
|
-
index,
|
|
165
|
-
"code"
|
|
166
|
-
]
|
|
167
|
-
});
|
|
168
|
-
localeCodes.add(locale.code);
|
|
169
|
-
}
|
|
170
|
-
if (config.defaultLocale && !localeCodes.has(config.defaultLocale)) ctx.addIssue({
|
|
171
|
-
code: zod.z.ZodIssueCode.custom,
|
|
172
|
-
message: "defaultLocale must be one of i18n.locales",
|
|
173
|
-
path: ["defaultLocale"]
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
var clarifyNavbarLinkSchema = zod.z.object({
|
|
177
|
-
label: clarifyLocalizedTextSchema,
|
|
178
|
-
href: zod.z.string(),
|
|
179
|
-
external: zod.z.boolean().optional()
|
|
180
|
-
});
|
|
181
|
-
var clarifyBannerConfigSchema = zod.z.object({
|
|
182
|
-
content: clarifyLocalizedTextSchema,
|
|
183
|
-
dismissible: zod.z.boolean().optional()
|
|
184
|
-
});
|
|
185
|
-
var clarifyFooterConfigSchema = zod.z.object({
|
|
186
|
-
links: zod.z.array(clarifyNavbarLinkSchema).optional(),
|
|
187
|
-
socials: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
188
|
-
copyright: clarifyLocalizedTextSchema.optional()
|
|
189
|
-
});
|
|
190
|
-
var clarifySourceConfigSchema = zod.z.object({
|
|
191
|
-
repository: zod.z.string(),
|
|
192
|
-
branch: zod.z.string().optional(),
|
|
193
|
-
directory: zod.z.string().optional()
|
|
194
|
-
});
|
|
195
|
-
var clarifyPagesItemSchema = zod.z.union([
|
|
196
|
-
zod.z.string(),
|
|
197
|
-
zod.z.object({
|
|
198
|
-
page: zod.z.string(),
|
|
199
|
-
title: clarifyLocalizedTextSchema.optional(),
|
|
200
|
-
icon: zod.z.string().optional(),
|
|
201
|
-
redirect: zod.z.string().optional()
|
|
202
|
-
}),
|
|
203
|
-
zod.z.object({
|
|
204
|
-
openapi: zod.z.string(),
|
|
205
|
-
icon: zod.z.string().optional(),
|
|
206
|
-
title: clarifyLocalizedTextSchema.optional(),
|
|
207
|
-
filter: zod.z.object({ tags: zod.z.array(zod.z.string()).optional() }).optional()
|
|
208
|
-
})
|
|
209
|
-
]);
|
|
210
|
-
var clarifyPagesGroupSchema = zod.z.object({
|
|
211
|
-
group: clarifyLocalizedTextSchema,
|
|
212
|
-
icon: zod.z.string().optional(),
|
|
213
|
-
pages: zod.z.array(clarifyPagesItemSchema)
|
|
214
|
-
});
|
|
215
|
-
var clarifyPagesConfigSchema = zod.z.union([zod.z.array(clarifyPagesGroupSchema), zod.z.literal("FileTree")]);
|
|
216
|
-
var clarifyTabItemSchema = zod.z.object({
|
|
217
|
-
tab: clarifyLocalizedTextSchema,
|
|
218
|
-
icon: zod.z.string().optional(),
|
|
219
|
-
pages: clarifyPagesConfigSchema.optional()
|
|
220
|
-
});
|
|
221
|
-
var clarifyTabsConfigSchema = zod.z.array(clarifyTabItemSchema);
|
|
222
|
-
var clarifyThemePresetSchema = zod.z.enum(["default", "base"]);
|
|
223
|
-
var clarifyThemeModeColorValueSchema = zod.z.object({
|
|
224
|
-
light: zod.z.string().optional(),
|
|
225
|
-
dark: zod.z.string().optional()
|
|
226
|
-
});
|
|
227
|
-
var clarifyThemeColorValueSchema = zod.z.union([zod.z.string(), clarifyThemeModeColorValueSchema]);
|
|
228
|
-
var clarifyThemeColorTokensConfigSchema = zod.z.object({
|
|
229
|
-
primary: clarifyThemeColorValueSchema.optional(),
|
|
230
|
-
accent: clarifyThemeColorValueSchema.optional(),
|
|
231
|
-
background: clarifyThemeColorValueSchema.optional(),
|
|
232
|
-
foreground: clarifyThemeColorValueSchema.optional(),
|
|
233
|
-
surface: clarifyThemeColorValueSchema.optional(),
|
|
234
|
-
muted: clarifyThemeColorValueSchema.optional(),
|
|
235
|
-
border: clarifyThemeColorValueSchema.optional(),
|
|
236
|
-
codeBackground: clarifyThemeColorValueSchema.optional()
|
|
237
|
-
});
|
|
238
|
-
var clarifyThemeRadiusTokensConfigSchema = zod.z.object({
|
|
239
|
-
sm: zod.z.string().optional(),
|
|
240
|
-
md: zod.z.string().optional(),
|
|
241
|
-
lg: zod.z.string().optional(),
|
|
242
|
-
xl: zod.z.string().optional()
|
|
243
|
-
});
|
|
244
|
-
var clarifyThemeTokensConfigSchema = zod.z.object({
|
|
245
|
-
colors: clarifyThemeColorTokensConfigSchema.optional(),
|
|
246
|
-
radius: clarifyThemeRadiusTokensConfigSchema.optional()
|
|
247
|
-
});
|
|
248
|
-
var clarifyThemeLayoutConfigSchema = zod.z.object({ maxWidth: zod.z.string().optional() });
|
|
249
|
-
var clarifyThemeConfigSchema = zod.z.object({
|
|
250
|
-
preset: clarifyThemePresetSchema.optional(),
|
|
251
|
-
tokens: clarifyThemeTokensConfigSchema.optional(),
|
|
252
|
-
layout: clarifyThemeLayoutConfigSchema.optional(),
|
|
253
|
-
editor: zod.z.boolean().optional()
|
|
254
|
-
});
|
|
255
|
-
var clarifyProjectConfigSchema = zod.z.object({
|
|
256
|
-
title: zod.z.string().optional(),
|
|
257
|
-
description: zod.z.string().optional(),
|
|
258
|
-
siteUrl: zod.z.string().optional(),
|
|
259
|
-
source: clarifySourceConfigSchema.optional(),
|
|
260
|
-
logo: clarifyLogoConfigSchema.optional(),
|
|
261
|
-
favicon: clarifyFaviconConfigSchema.optional(),
|
|
262
|
-
theme: clarifyThemeConfigSchema.optional(),
|
|
263
|
-
routePrefix: zod.z.string().optional(),
|
|
264
|
-
navbar: zod.z.object({ links: zod.z.array(clarifyNavbarLinkSchema).optional() }).optional(),
|
|
265
|
-
banner: clarifyBannerConfigSchema.optional(),
|
|
266
|
-
footer: clarifyFooterConfigSchema.optional(),
|
|
267
|
-
i18n: clarifyI18nConfigSchema.optional(),
|
|
268
|
-
tabs: clarifyTabsConfigSchema.optional()
|
|
269
|
-
});
|
|
270
|
-
//#endregion
|
|
271
|
-
//#region source/core/theme.ts
|
|
272
|
-
var clarifyThemePresets = {
|
|
273
|
-
default: {
|
|
274
|
-
preset: "default",
|
|
275
|
-
tokens: {
|
|
276
|
-
colors: {
|
|
277
|
-
primary: "#047857",
|
|
278
|
-
accent: "#0D9488",
|
|
279
|
-
background: "#ffffff",
|
|
280
|
-
foreground: "#111827",
|
|
281
|
-
surface: "#ffffff",
|
|
282
|
-
muted: "#64748b",
|
|
283
|
-
border: "rgb(15 23 42 / 0.12)",
|
|
284
|
-
codeBackground: "#f6fbf8"
|
|
285
|
-
},
|
|
286
|
-
radius: {
|
|
287
|
-
sm: "6px",
|
|
288
|
-
md: "10px",
|
|
289
|
-
lg: "14px",
|
|
290
|
-
xl: "18px"
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
layout: { maxWidth: "82rem" },
|
|
294
|
-
editor: false
|
|
295
|
-
},
|
|
296
|
-
base: {
|
|
297
|
-
preset: "base",
|
|
298
|
-
tokens: {
|
|
299
|
-
colors: {
|
|
300
|
-
primary: "#18181b",
|
|
301
|
-
accent: "#52525b",
|
|
302
|
-
background: "#ffffff",
|
|
303
|
-
foreground: "#18181b",
|
|
304
|
-
surface: "#ffffff",
|
|
305
|
-
muted: "#71717a",
|
|
306
|
-
border: "rgb(24 24 27 / 0.12)",
|
|
307
|
-
codeBackground: "#f4f4f5"
|
|
308
|
-
},
|
|
309
|
-
radius: {
|
|
310
|
-
sm: "6px",
|
|
311
|
-
md: "8px",
|
|
312
|
-
lg: "12px",
|
|
313
|
-
xl: "16px"
|
|
314
|
-
}
|
|
315
|
-
},
|
|
316
|
-
layout: { maxWidth: "80rem" },
|
|
317
|
-
editor: false
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
function resolveThemeConfig(theme = {}) {
|
|
321
|
-
const preset = theme.preset ?? "default";
|
|
322
|
-
const presetTheme = clarifyThemePresets[preset];
|
|
323
|
-
return {
|
|
324
|
-
preset,
|
|
325
|
-
tokens: {
|
|
326
|
-
colors: {
|
|
327
|
-
...presetTheme.tokens.colors,
|
|
328
|
-
...theme.tokens?.colors
|
|
329
|
-
},
|
|
330
|
-
radius: {
|
|
331
|
-
...presetTheme.tokens.radius,
|
|
332
|
-
...theme.tokens?.radius
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
-
layout: {
|
|
336
|
-
...presetTheme.layout,
|
|
337
|
-
...theme.layout
|
|
338
|
-
},
|
|
339
|
-
editor: theme.editor ?? presetTheme.editor
|
|
340
|
-
};
|
|
138
|
+
//#region source/plugins/content-artifacts/artifacts.ts
|
|
139
|
+
var UTF8_SIGNATURE = "";
|
|
140
|
+
function normalizeBasePath(basePath) {
|
|
141
|
+
if (!basePath || basePath === "/") return "";
|
|
142
|
+
return "/" + basePath.replace(/^\/+|\/+$/g, "");
|
|
341
143
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
function formatIssuePath(path) {
|
|
345
|
-
return path.reduce((result, segment) => {
|
|
346
|
-
if (typeof segment === "number") return `${result}[${segment}]`;
|
|
347
|
-
const key = String(segment);
|
|
348
|
-
return result ? `${result}.${key}` : key;
|
|
349
|
-
}, "");
|
|
144
|
+
function containsNonAscii(content) {
|
|
145
|
+
return [...content].some((character) => character.codePointAt(0) > 127);
|
|
350
146
|
}
|
|
351
|
-
function
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const path = formatIssuePath(issue.path);
|
|
355
|
-
if (!path) return `[clarify] config must contain an object: ${issue.message}`;
|
|
356
|
-
return `[clarify] config field "${path}" is invalid: ${issue.message}`;
|
|
147
|
+
function withUtf8Signature(content) {
|
|
148
|
+
if (!containsNonAscii(content) || content.startsWith(UTF8_SIGNATURE)) return content;
|
|
149
|
+
return `${UTF8_SIGNATURE}${content}`;
|
|
357
150
|
}
|
|
358
|
-
function
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
return result.data;
|
|
151
|
+
function shouldUseUtf8Signature(route) {
|
|
152
|
+
if (route.kind === "mdx") return true;
|
|
153
|
+
return /\.ya?ml$/i.test(route.contentArtifactUrl ?? "");
|
|
362
154
|
}
|
|
363
|
-
function
|
|
364
|
-
|
|
365
|
-
const firstLocale = i18n.locales[0]?.code;
|
|
366
|
-
const defaultLocale = i18n.defaultLocale ?? firstLocale;
|
|
367
|
-
if (!defaultLocale) return void 0;
|
|
368
|
-
return {
|
|
369
|
-
defaultLocale,
|
|
370
|
-
missing: i18n.missing ?? "fallback",
|
|
371
|
-
locales: i18n.locales
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
function resolveProjectConfig(config = {}) {
|
|
375
|
-
return {
|
|
376
|
-
title: config.title ?? "Clarify Docs",
|
|
377
|
-
description: config.description ?? "",
|
|
378
|
-
siteUrl: config.siteUrl,
|
|
379
|
-
source: config.source,
|
|
380
|
-
logo: config.logo,
|
|
381
|
-
favicon: config.favicon,
|
|
382
|
-
routePrefix: config.routePrefix ?? "/",
|
|
383
|
-
theme: resolveThemeConfig(config.theme),
|
|
384
|
-
navbar: config.navbar,
|
|
385
|
-
banner: config.banner,
|
|
386
|
-
footer: config.footer,
|
|
387
|
-
i18n: resolveI18nConfig(config.i18n),
|
|
388
|
-
tabs: config.tabs
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
//#endregion
|
|
392
|
-
//#region source/plugins/content-artifacts/artifacts.ts
|
|
393
|
-
var UTF8_SIGNATURE = "";
|
|
394
|
-
function normalizeBasePath(basePath) {
|
|
395
|
-
if (!basePath || basePath === "/") return "";
|
|
396
|
-
return "/" + basePath.replace(/^\/+|\/+$/g, "");
|
|
397
|
-
}
|
|
398
|
-
function containsNonAscii(content) {
|
|
399
|
-
return [...content].some((character) => character.codePointAt(0) > 127);
|
|
400
|
-
}
|
|
401
|
-
function withUtf8Signature(content) {
|
|
402
|
-
if (!containsNonAscii(content) || content.startsWith(UTF8_SIGNATURE)) return content;
|
|
403
|
-
return `${UTF8_SIGNATURE}${content}`;
|
|
404
|
-
}
|
|
405
|
-
function shouldUseUtf8Signature(route) {
|
|
406
|
-
if (route.kind === "mdx") return true;
|
|
407
|
-
return /\.ya?ml$/i.test(route.contentArtifactUrl ?? "");
|
|
408
|
-
}
|
|
409
|
-
function routeToMarkdownArtifactUrl(routePath) {
|
|
410
|
-
return `${routePath === "/" ? "/index" : routePath.replace(/\/$/, "")}.md`;
|
|
155
|
+
function routeToMarkdownArtifactUrl(routePath) {
|
|
156
|
+
return `${routePath === "/" ? "/index" : routePath.replace(/\/$/, "")}.md`;
|
|
411
157
|
}
|
|
412
158
|
function routeToOpenAPIArtifactUrl(routePath, filePath) {
|
|
413
159
|
const extension = (0, node_path.extname)(filePath).toLowerCase() || ".json";
|
|
@@ -1246,6 +992,265 @@ function createBuiltinPlugins(options = {}) {
|
|
|
1246
992
|
return plugins;
|
|
1247
993
|
}
|
|
1248
994
|
//#endregion
|
|
995
|
+
//#region source/core/config-schema.ts
|
|
996
|
+
var clarifyLogoConfigSchema = zod.z.union([zod.z.string(), zod.z.object({
|
|
997
|
+
light: zod.z.string().optional(),
|
|
998
|
+
dark: zod.z.string().optional()
|
|
999
|
+
})]);
|
|
1000
|
+
var clarifyFaviconConfigSchema = zod.z.union([zod.z.string(), zod.z.object({
|
|
1001
|
+
light: zod.z.string().optional(),
|
|
1002
|
+
dark: zod.z.string().optional()
|
|
1003
|
+
})]);
|
|
1004
|
+
var clarifyLocalizedTextSchema = zod.z.union([zod.z.string(), zod.z.record(zod.z.string(), zod.z.string())]);
|
|
1005
|
+
var clarifyLocaleConfigSchema = zod.z.object({
|
|
1006
|
+
code: zod.z.string(),
|
|
1007
|
+
label: zod.z.string(),
|
|
1008
|
+
dir: zod.z.union([zod.z.literal("ltr"), zod.z.literal("rtl")]).optional()
|
|
1009
|
+
});
|
|
1010
|
+
var clarifyI18nConfigSchema = zod.z.object({
|
|
1011
|
+
defaultLocale: zod.z.string().optional(),
|
|
1012
|
+
missing: zod.z.union([
|
|
1013
|
+
zod.z.literal("fallback"),
|
|
1014
|
+
zod.z.literal("404"),
|
|
1015
|
+
zod.z.literal("hide")
|
|
1016
|
+
]).optional(),
|
|
1017
|
+
locales: zod.z.array(clarifyLocaleConfigSchema).min(1)
|
|
1018
|
+
}).superRefine((config, ctx) => {
|
|
1019
|
+
const localeCodes = /* @__PURE__ */ new Set();
|
|
1020
|
+
for (const [index, locale] of config.locales.entries()) {
|
|
1021
|
+
if (localeCodes.has(locale.code)) ctx.addIssue({
|
|
1022
|
+
code: zod.z.ZodIssueCode.custom,
|
|
1023
|
+
message: `Duplicate locale code "${locale.code}"`,
|
|
1024
|
+
path: [
|
|
1025
|
+
"locales",
|
|
1026
|
+
index,
|
|
1027
|
+
"code"
|
|
1028
|
+
]
|
|
1029
|
+
});
|
|
1030
|
+
localeCodes.add(locale.code);
|
|
1031
|
+
}
|
|
1032
|
+
if (config.defaultLocale && !localeCodes.has(config.defaultLocale)) ctx.addIssue({
|
|
1033
|
+
code: zod.z.ZodIssueCode.custom,
|
|
1034
|
+
message: "defaultLocale must be one of i18n.locales",
|
|
1035
|
+
path: ["defaultLocale"]
|
|
1036
|
+
});
|
|
1037
|
+
});
|
|
1038
|
+
var clarifyNavbarLinkSchema = zod.z.object({
|
|
1039
|
+
label: clarifyLocalizedTextSchema,
|
|
1040
|
+
href: zod.z.string(),
|
|
1041
|
+
external: zod.z.boolean().optional()
|
|
1042
|
+
});
|
|
1043
|
+
var clarifyBannerConfigSchema = zod.z.object({
|
|
1044
|
+
content: clarifyLocalizedTextSchema,
|
|
1045
|
+
dismissible: zod.z.boolean().optional()
|
|
1046
|
+
});
|
|
1047
|
+
var clarifyFooterConfigSchema = zod.z.object({
|
|
1048
|
+
links: zod.z.array(clarifyNavbarLinkSchema).optional(),
|
|
1049
|
+
socials: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
1050
|
+
copyright: clarifyLocalizedTextSchema.optional()
|
|
1051
|
+
});
|
|
1052
|
+
var clarifySourceConfigSchema = zod.z.object({
|
|
1053
|
+
repository: zod.z.string(),
|
|
1054
|
+
branch: zod.z.string().optional(),
|
|
1055
|
+
directory: zod.z.string().optional()
|
|
1056
|
+
});
|
|
1057
|
+
var clarifyPagesItemSchema = zod.z.union([
|
|
1058
|
+
zod.z.string(),
|
|
1059
|
+
zod.z.object({
|
|
1060
|
+
page: zod.z.string(),
|
|
1061
|
+
title: clarifyLocalizedTextSchema.optional(),
|
|
1062
|
+
icon: zod.z.string().optional(),
|
|
1063
|
+
redirect: zod.z.string().optional()
|
|
1064
|
+
}),
|
|
1065
|
+
zod.z.object({
|
|
1066
|
+
openapi: zod.z.string(),
|
|
1067
|
+
icon: zod.z.string().optional(),
|
|
1068
|
+
title: clarifyLocalizedTextSchema.optional(),
|
|
1069
|
+
filter: zod.z.object({ tags: zod.z.array(zod.z.string()).optional() }).optional()
|
|
1070
|
+
})
|
|
1071
|
+
]);
|
|
1072
|
+
var clarifyPagesGroupSchema = zod.z.object({
|
|
1073
|
+
group: clarifyLocalizedTextSchema,
|
|
1074
|
+
icon: zod.z.string().optional(),
|
|
1075
|
+
pages: zod.z.array(clarifyPagesItemSchema)
|
|
1076
|
+
});
|
|
1077
|
+
var clarifyPagesConfigSchema = zod.z.union([zod.z.array(clarifyPagesGroupSchema), zod.z.literal("FileTree")]);
|
|
1078
|
+
var clarifyTabItemSchema = zod.z.object({
|
|
1079
|
+
tab: clarifyLocalizedTextSchema,
|
|
1080
|
+
icon: zod.z.string().optional(),
|
|
1081
|
+
pages: clarifyPagesConfigSchema.optional()
|
|
1082
|
+
});
|
|
1083
|
+
var clarifyTabsConfigSchema = zod.z.array(clarifyTabItemSchema);
|
|
1084
|
+
var clarifyThemePresetSchema = zod.z.enum(["default", "base"]);
|
|
1085
|
+
var clarifyThemeModeColorValueSchema = zod.z.object({
|
|
1086
|
+
light: zod.z.string().optional(),
|
|
1087
|
+
dark: zod.z.string().optional()
|
|
1088
|
+
});
|
|
1089
|
+
var clarifyThemeColorValueSchema = zod.z.union([zod.z.string(), clarifyThemeModeColorValueSchema]);
|
|
1090
|
+
var clarifyThemeColorTokensConfigSchema = zod.z.object({
|
|
1091
|
+
primary: clarifyThemeColorValueSchema.optional(),
|
|
1092
|
+
accent: clarifyThemeColorValueSchema.optional(),
|
|
1093
|
+
background: clarifyThemeColorValueSchema.optional(),
|
|
1094
|
+
foreground: clarifyThemeColorValueSchema.optional(),
|
|
1095
|
+
surface: clarifyThemeColorValueSchema.optional(),
|
|
1096
|
+
muted: clarifyThemeColorValueSchema.optional(),
|
|
1097
|
+
border: clarifyThemeColorValueSchema.optional(),
|
|
1098
|
+
codeBackground: clarifyThemeColorValueSchema.optional()
|
|
1099
|
+
});
|
|
1100
|
+
var clarifyThemeRadiusTokensConfigSchema = zod.z.object({
|
|
1101
|
+
sm: zod.z.string().optional(),
|
|
1102
|
+
md: zod.z.string().optional(),
|
|
1103
|
+
lg: zod.z.string().optional(),
|
|
1104
|
+
xl: zod.z.string().optional()
|
|
1105
|
+
});
|
|
1106
|
+
var clarifyThemeTokensConfigSchema = zod.z.object({
|
|
1107
|
+
colors: clarifyThemeColorTokensConfigSchema.optional(),
|
|
1108
|
+
radius: clarifyThemeRadiusTokensConfigSchema.optional()
|
|
1109
|
+
});
|
|
1110
|
+
var clarifyThemeLayoutConfigSchema = zod.z.object({ maxWidth: zod.z.string().optional() });
|
|
1111
|
+
var clarifyThemeConfigSchema = zod.z.object({
|
|
1112
|
+
preset: clarifyThemePresetSchema.optional(),
|
|
1113
|
+
tokens: clarifyThemeTokensConfigSchema.optional(),
|
|
1114
|
+
layout: clarifyThemeLayoutConfigSchema.optional(),
|
|
1115
|
+
editor: zod.z.boolean().optional()
|
|
1116
|
+
});
|
|
1117
|
+
var clarifyProjectConfigSchema = zod.z.object({
|
|
1118
|
+
title: zod.z.string().optional(),
|
|
1119
|
+
description: zod.z.string().optional(),
|
|
1120
|
+
siteUrl: zod.z.string().optional(),
|
|
1121
|
+
source: clarifySourceConfigSchema.optional(),
|
|
1122
|
+
logo: clarifyLogoConfigSchema.optional(),
|
|
1123
|
+
favicon: clarifyFaviconConfigSchema.optional(),
|
|
1124
|
+
theme: clarifyThemeConfigSchema.optional(),
|
|
1125
|
+
routePrefix: zod.z.string().optional(),
|
|
1126
|
+
navbar: zod.z.object({ links: zod.z.array(clarifyNavbarLinkSchema).optional() }).optional(),
|
|
1127
|
+
banner: clarifyBannerConfigSchema.optional(),
|
|
1128
|
+
footer: clarifyFooterConfigSchema.optional(),
|
|
1129
|
+
i18n: clarifyI18nConfigSchema.optional(),
|
|
1130
|
+
tabs: clarifyTabsConfigSchema.optional()
|
|
1131
|
+
});
|
|
1132
|
+
//#endregion
|
|
1133
|
+
//#region source/core/theme.ts
|
|
1134
|
+
var clarifyThemePresets = {
|
|
1135
|
+
default: {
|
|
1136
|
+
preset: "default",
|
|
1137
|
+
tokens: {
|
|
1138
|
+
colors: {
|
|
1139
|
+
primary: "#047857",
|
|
1140
|
+
accent: "#0D9488",
|
|
1141
|
+
background: "#ffffff",
|
|
1142
|
+
foreground: "#111827",
|
|
1143
|
+
surface: "#ffffff",
|
|
1144
|
+
muted: "#64748b",
|
|
1145
|
+
border: "rgb(15 23 42 / 0.12)",
|
|
1146
|
+
codeBackground: "#f6fbf8"
|
|
1147
|
+
},
|
|
1148
|
+
radius: {
|
|
1149
|
+
sm: "6px",
|
|
1150
|
+
md: "10px",
|
|
1151
|
+
lg: "14px",
|
|
1152
|
+
xl: "18px"
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1155
|
+
layout: { maxWidth: "82rem" },
|
|
1156
|
+
editor: false
|
|
1157
|
+
},
|
|
1158
|
+
base: {
|
|
1159
|
+
preset: "base",
|
|
1160
|
+
tokens: {
|
|
1161
|
+
colors: {
|
|
1162
|
+
primary: "#18181b",
|
|
1163
|
+
accent: "#52525b",
|
|
1164
|
+
background: "#ffffff",
|
|
1165
|
+
foreground: "#18181b",
|
|
1166
|
+
surface: "#ffffff",
|
|
1167
|
+
muted: "#71717a",
|
|
1168
|
+
border: "rgb(24 24 27 / 0.12)",
|
|
1169
|
+
codeBackground: "#f4f4f5"
|
|
1170
|
+
},
|
|
1171
|
+
radius: {
|
|
1172
|
+
sm: "6px",
|
|
1173
|
+
md: "8px",
|
|
1174
|
+
lg: "12px",
|
|
1175
|
+
xl: "16px"
|
|
1176
|
+
}
|
|
1177
|
+
},
|
|
1178
|
+
layout: { maxWidth: "80rem" },
|
|
1179
|
+
editor: false
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
function resolveThemeConfig(theme = {}) {
|
|
1183
|
+
const preset = theme.preset ?? "default";
|
|
1184
|
+
const presetTheme = clarifyThemePresets[preset];
|
|
1185
|
+
return {
|
|
1186
|
+
preset,
|
|
1187
|
+
tokens: {
|
|
1188
|
+
colors: {
|
|
1189
|
+
...presetTheme.tokens.colors,
|
|
1190
|
+
...theme.tokens?.colors
|
|
1191
|
+
},
|
|
1192
|
+
radius: {
|
|
1193
|
+
...presetTheme.tokens.radius,
|
|
1194
|
+
...theme.tokens?.radius
|
|
1195
|
+
}
|
|
1196
|
+
},
|
|
1197
|
+
layout: {
|
|
1198
|
+
...presetTheme.layout,
|
|
1199
|
+
...theme.layout
|
|
1200
|
+
},
|
|
1201
|
+
editor: theme.editor ?? presetTheme.editor
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
//#endregion
|
|
1205
|
+
//#region source/core/config.ts
|
|
1206
|
+
function formatIssuePath(path) {
|
|
1207
|
+
return path.reduce((result, segment) => {
|
|
1208
|
+
if (typeof segment === "number") return `${result}[${segment}]`;
|
|
1209
|
+
const key = String(segment);
|
|
1210
|
+
return result ? `${result}.${key}` : key;
|
|
1211
|
+
}, "");
|
|
1212
|
+
}
|
|
1213
|
+
function formatProjectConfigError(error) {
|
|
1214
|
+
const issue = error.issues[0];
|
|
1215
|
+
if (!issue) return "[clarify] config is invalid";
|
|
1216
|
+
const path = formatIssuePath(issue.path);
|
|
1217
|
+
if (!path) return `[clarify] config must contain an object: ${issue.message}`;
|
|
1218
|
+
return `[clarify] config field "${path}" is invalid: ${issue.message}`;
|
|
1219
|
+
}
|
|
1220
|
+
function validateProjectConfig(value) {
|
|
1221
|
+
const result = clarifyProjectConfigSchema.safeParse(value);
|
|
1222
|
+
if (!result.success) throw new Error(formatProjectConfigError(result.error));
|
|
1223
|
+
return result.data;
|
|
1224
|
+
}
|
|
1225
|
+
function resolveI18nConfig(i18n) {
|
|
1226
|
+
if (!i18n) return void 0;
|
|
1227
|
+
const firstLocale = i18n.locales[0]?.code;
|
|
1228
|
+
const defaultLocale = i18n.defaultLocale ?? firstLocale;
|
|
1229
|
+
if (!defaultLocale) return void 0;
|
|
1230
|
+
return {
|
|
1231
|
+
defaultLocale,
|
|
1232
|
+
missing: i18n.missing ?? "fallback",
|
|
1233
|
+
locales: i18n.locales
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
function resolveProjectConfig(config = {}) {
|
|
1237
|
+
return {
|
|
1238
|
+
title: config.title ?? "Clarify Docs",
|
|
1239
|
+
description: config.description ?? "",
|
|
1240
|
+
siteUrl: config.siteUrl,
|
|
1241
|
+
source: config.source,
|
|
1242
|
+
logo: config.logo,
|
|
1243
|
+
favicon: config.favicon,
|
|
1244
|
+
routePrefix: config.routePrefix ?? "/",
|
|
1245
|
+
theme: resolveThemeConfig(config.theme),
|
|
1246
|
+
navbar: config.navbar,
|
|
1247
|
+
banner: config.banner,
|
|
1248
|
+
footer: config.footer,
|
|
1249
|
+
i18n: resolveI18nConfig(config.i18n),
|
|
1250
|
+
tabs: config.tabs
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
//#endregion
|
|
1249
1254
|
//#region source/core/hooks.ts
|
|
1250
1255
|
async function runHooks(plugins, hookName, input, ctx) {
|
|
1251
1256
|
let result = input;
|
|
@@ -1816,4 +1821,4 @@ Object.defineProperty(exports, "resolveClarifySite", {
|
|
|
1816
1821
|
}
|
|
1817
1822
|
});
|
|
1818
1823
|
|
|
1819
|
-
//# sourceMappingURL=plugin-
|
|
1824
|
+
//# sourceMappingURL=plugin-GTN_SQ7d.cjs.map
|