blodemd 0.0.8 → 0.0.10
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 +25 -9
- package/dev-server/app/[[...slug]]/page.tsx +1 -0
- package/dev-server/app/favicon.ico +0 -0
- package/dev-server/next.config.js +11 -13
- package/dev-server/package.json +1 -1
- package/dev-server/tsconfig.json +3 -0
- package/dist/cli.mjs +869 -184
- package/dist/cli.mjs.map +1 -1
- package/docs/app/globals.css +1 -1
- package/docs/components/animate-ui/primitives/buttons/button.tsx +14 -0
- package/docs/components/api/api-playground.tsx +255 -80
- package/docs/components/api/api-reference.tsx +11 -1
- package/docs/components/docs/contextual-menu.tsx +227 -142
- package/docs/components/docs/copy-page-menu.tsx +148 -85
- package/docs/components/docs/doc-header.tsx +13 -3
- package/docs/components/docs/doc-shell.tsx +25 -14
- package/docs/components/docs/mobile-nav.tsx +0 -6
- package/docs/components/mdx/code-group.tsx +171 -62
- package/docs/components/mdx/steps.tsx +1 -1
- package/docs/components/mdx/tabs.tsx +131 -26
- package/docs/components/ui/copy-button.tsx +122 -0
- package/docs/components/ui/input.tsx +0 -1
- package/docs/components/ui/search.tsx +241 -132
- package/docs/components/ui/site-footer.tsx +39 -0
- package/docs/lib/config.ts +7 -0
- package/docs/lib/content-root.ts +33 -0
- package/docs/lib/content-source.ts +70 -0
- package/docs/lib/contextual-options.ts +20 -0
- package/docs/lib/docs-runtime.tsx +595 -0
- package/docs/lib/edge-config.ts +95 -0
- package/docs/lib/env.ts +22 -0
- package/docs/lib/openapi-proxy.ts +88 -0
- package/docs/lib/platform-config.ts +6 -0
- package/docs/lib/routes.ts +39 -0
- package/docs/lib/supabase.ts +13 -0
- package/docs/lib/tenancy.ts +350 -0
- package/docs/lib/tenant-headers.ts +14 -0
- package/docs/lib/tenant-static.ts +529 -0
- package/docs/lib/tenant-utility-context.ts +62 -0
- package/docs/lib/tenants.ts +68 -0
- package/docs/lib/use-mobile.ts +19 -0
- package/package.json +3 -2
- package/packages/@repo/common/dist/index.d.ts +7 -0
- package/packages/@repo/common/dist/index.d.ts.map +1 -1
- package/packages/@repo/common/dist/index.js +42 -0
- package/packages/@repo/common/src/index.ts +50 -0
- package/packages/@repo/contracts/dist/project.d.ts +1 -1
- package/packages/@repo/contracts/dist/project.js +1 -1
- package/packages/@repo/contracts/src/project.ts +1 -1
- package/packages/@repo/models/dist/docs-config.d.ts +194 -29
- package/packages/@repo/models/dist/docs-config.d.ts.map +1 -1
- package/packages/@repo/models/dist/docs-config.js +3 -28
- package/packages/@repo/models/src/docs-config.ts +5 -31
- package/packages/@repo/previewing/dist/blob-source.d.ts.map +1 -1
- package/packages/@repo/previewing/dist/blob-source.js +7 -2
- package/packages/@repo/previewing/dist/fs-source.d.ts.map +1 -1
- package/packages/@repo/previewing/dist/fs-source.js +2 -3
- package/packages/@repo/previewing/dist/index.d.ts.map +1 -1
- package/packages/@repo/previewing/dist/index.js +20 -50
- package/packages/@repo/previewing/src/blob-source.ts +7 -4
- package/packages/@repo/previewing/src/fs-source.ts +2 -3
- package/packages/@repo/previewing/src/index.ts +29 -64
- package/packages/@repo/validation/dist/index.d.ts +2 -2
- package/packages/@repo/validation/dist/index.d.ts.map +1 -1
- package/packages/@repo/validation/dist/index.js +2 -2
- package/packages/@repo/validation/package.json +1 -0
- package/packages/@repo/validation/src/{mintlify-docs-schema.json → blodemd-docs-schema.json} +346 -1794
- package/packages/@repo/validation/src/index.ts +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,WAAW,EAEX,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACX,MAAM,cAAc,CAAC;AAQtB,OAAO,KAAK,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qBAAqB,GAAI,OAAO,YAAY,KAAG,MAIvB,CAAC;AAEtC,eAAO,MAAM,wBAAwB,GACnC,QAAQ,aAAa,KACpB,OAAO,CAAC,YAAY,GAAG,IAAI,CAoB7B,CAAC"}
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { ensureArray, normalizePath, slugify } from "@repo/common";
|
|
3
3
|
import { PageModeSchema } from "@repo/models";
|
|
4
4
|
import { extractOpenApiOperations, openApiIdentifier, openApiSlug, parseOpenApiSpec, } from "@repo/prebuild";
|
|
5
|
-
import { validateDocsConfig, validateFrontmatter } from "@repo/validation";
|
|
5
|
+
import { validateDocsConfig, validateFrontmatter, validateSiteConfig, } from "@repo/validation";
|
|
6
6
|
import YAML from "yaml";
|
|
7
7
|
export { BlobContentSource, createBlobSource } from "./blob-source.js";
|
|
8
8
|
export { createFsSource, FsContentSource } from "./fs-source.js";
|
|
@@ -116,35 +116,6 @@ const defaultLinkLabel = (input) => {
|
|
|
116
116
|
return input.href;
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
|
-
const buildGoogleFontsCssUrl = (fonts) => {
|
|
120
|
-
if (!fonts) {
|
|
121
|
-
return undefined;
|
|
122
|
-
}
|
|
123
|
-
const fontEntries = [];
|
|
124
|
-
if (fonts.family) {
|
|
125
|
-
fontEntries.push({ family: fonts.family, source: fonts.source });
|
|
126
|
-
}
|
|
127
|
-
if (fonts.body) {
|
|
128
|
-
fontEntries.push({
|
|
129
|
-
family: fonts.body.family,
|
|
130
|
-
source: fonts.body.source,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
if (fonts.heading) {
|
|
134
|
-
fontEntries.push({
|
|
135
|
-
family: fonts.heading.family,
|
|
136
|
-
source: fonts.heading.source,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
const googleFamilies = [
|
|
140
|
-
...new Set(fontEntries.filter((entry) => !entry.source).map((entry) => entry.family)),
|
|
141
|
-
];
|
|
142
|
-
if (!googleFamilies.length) {
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
const params = googleFamilies.map((family) => `family=${encodeURIComponent(family).replaceAll("%20", "+")}`);
|
|
146
|
-
return `https://fonts.googleapis.com/css2?${params.join("&")}&display=swap`;
|
|
147
|
-
};
|
|
148
119
|
// oxlint-disable-next-line eslint/complexity
|
|
149
120
|
const mapDocsConfig = (docs) => {
|
|
150
121
|
const navigation = {
|
|
@@ -199,15 +170,6 @@ const mapDocsConfig = (docs) => {
|
|
|
199
170
|
url: version.href,
|
|
200
171
|
})),
|
|
201
172
|
};
|
|
202
|
-
const baseFontFamily = docs.fonts?.family;
|
|
203
|
-
const fonts = docs.fonts && (baseFontFamily || docs.fonts.body || docs.fonts.heading)
|
|
204
|
-
? {
|
|
205
|
-
body: docs.fonts.body?.family ?? baseFontFamily,
|
|
206
|
-
cssUrl: buildGoogleFontsCssUrl(docs.fonts),
|
|
207
|
-
heading: docs.fonts.heading?.family ?? baseFontFamily,
|
|
208
|
-
provider: "google",
|
|
209
|
-
}
|
|
210
|
-
: undefined;
|
|
211
173
|
return {
|
|
212
174
|
collections: [
|
|
213
175
|
{
|
|
@@ -218,7 +180,6 @@ const mapDocsConfig = (docs) => {
|
|
|
218
180
|
type: "docs",
|
|
219
181
|
},
|
|
220
182
|
],
|
|
221
|
-
colors: docs.colors,
|
|
222
183
|
contextual: docs.contextual,
|
|
223
184
|
description: docs.description,
|
|
224
185
|
favicon: typeof docs.favicon === "string" ? docs.favicon : docs.favicon?.light,
|
|
@@ -228,10 +189,10 @@ const mapDocsConfig = (docs) => {
|
|
|
228
189
|
themeToggle: docs.appearance?.strict !== true,
|
|
229
190
|
toc: true,
|
|
230
191
|
},
|
|
231
|
-
fonts,
|
|
232
192
|
logo: docs.logo
|
|
233
193
|
? {
|
|
234
194
|
dark: typeof docs.logo === "string" ? docs.logo : docs.logo.dark,
|
|
195
|
+
href: typeof docs.logo === "string" ? undefined : docs.logo.href,
|
|
235
196
|
light: typeof docs.logo === "string" ? docs.logo : docs.logo.light,
|
|
236
197
|
}
|
|
237
198
|
: undefined,
|
|
@@ -242,7 +203,6 @@ const mapDocsConfig = (docs) => {
|
|
|
242
203
|
Boolean(docs.api?.openapi || docs.api?.asyncapi),
|
|
243
204
|
},
|
|
244
205
|
seo: docs.seo,
|
|
245
|
-
theme: docs.theme,
|
|
246
206
|
};
|
|
247
207
|
};
|
|
248
208
|
const readJsonConfig = async (source, relativePath) => JSON.parse(await source.readFile(relativePath));
|
|
@@ -311,15 +271,25 @@ const loadDocsConfig = async (source) => {
|
|
|
311
271
|
}
|
|
312
272
|
try {
|
|
313
273
|
const parsed = await readResolvedJsonConfig(source, DOCS_CONFIG_FILE);
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
274
|
+
// Try SiteConfig format first (has collections, theme, colors, etc.)
|
|
275
|
+
const siteResult = validateSiteConfig(parsed);
|
|
276
|
+
if (siteResult.success) {
|
|
277
|
+
return {
|
|
278
|
+
config: siteResult.data,
|
|
279
|
+
ok: true,
|
|
280
|
+
warnings: [],
|
|
281
|
+
};
|
|
317
282
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
283
|
+
// Fall back to DocsConfig format (Mintlify-compatible) and map to SiteConfig
|
|
284
|
+
const docsResult = validateDocsConfig(parsed);
|
|
285
|
+
if (docsResult.success) {
|
|
286
|
+
return {
|
|
287
|
+
config: mapDocsConfig(docsResult.data),
|
|
288
|
+
ok: true,
|
|
289
|
+
warnings: [],
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
return { errors: docsResult.errors, ok: false };
|
|
323
293
|
}
|
|
324
294
|
catch (error) {
|
|
325
295
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
|
-
import { normalizePath } from "@repo/common";
|
|
3
|
+
import { normalizePath, shouldIgnoreRootDocsFile } from "@repo/common";
|
|
4
4
|
|
|
5
5
|
import type { CompiledMdxResult, ContentSource } from "./content-source.js";
|
|
6
6
|
|
|
@@ -116,9 +116,12 @@ export class BlobContentSource implements ContentSource {
|
|
|
116
116
|
const manifest = await this.loadManifest();
|
|
117
117
|
const prefix = normalizeDirectory(directory);
|
|
118
118
|
|
|
119
|
-
const files = [...manifest.keys()].filter((file) =>
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
const files = [...manifest.keys()].filter((file) => {
|
|
120
|
+
if (shouldIgnoreRootDocsFile(file)) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return prefix ? file.startsWith(prefix) : true;
|
|
124
|
+
});
|
|
122
125
|
// oxlint-disable-next-line eslint-plugin-unicorn/no-array-sort
|
|
123
126
|
files.sort();
|
|
124
127
|
return files;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
-
import { normalizePath } from "@repo/common";
|
|
4
|
+
import { normalizePath, shouldIgnoreRootDocsFile } from "@repo/common";
|
|
5
5
|
|
|
6
6
|
import type { ContentSource } from "./content-source.js";
|
|
7
7
|
|
|
8
8
|
const IGNORED_DIRECTORIES = new Set(["app", "lib", "node_modules", "public"]);
|
|
9
|
-
const IGNORED_ROOT_FILES = new Set(["AGENTS.md", "README.md"]);
|
|
10
9
|
|
|
11
10
|
const isNotFoundError = (error: unknown) =>
|
|
12
11
|
Boolean(
|
|
@@ -54,7 +53,7 @@ const walkFiles = async (
|
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
if (entry.isFile()) {
|
|
57
|
-
if (!prefix &&
|
|
56
|
+
if (!prefix && shouldIgnoreRootDocsFile(entry.name)) {
|
|
58
57
|
continue;
|
|
59
58
|
}
|
|
60
59
|
files.push(normalizePath(relativePath));
|
|
@@ -4,9 +4,9 @@ import { ensureArray, normalizePath, slugify } from "@repo/common";
|
|
|
4
4
|
import type {
|
|
5
5
|
CollectionConfig,
|
|
6
6
|
ContentType,
|
|
7
|
+
DocsConfig,
|
|
7
8
|
DocsOpenApiSource,
|
|
8
9
|
FrontmatterByType,
|
|
9
|
-
MintlifyDocsConfig,
|
|
10
10
|
PageMode,
|
|
11
11
|
SiteConfig,
|
|
12
12
|
} from "@repo/models";
|
|
@@ -18,7 +18,11 @@ import {
|
|
|
18
18
|
parseOpenApiSpec,
|
|
19
19
|
} from "@repo/prebuild";
|
|
20
20
|
import type { OpenApiOperation, OpenApiSpec } from "@repo/prebuild";
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
validateDocsConfig,
|
|
23
|
+
validateFrontmatter,
|
|
24
|
+
validateSiteConfig,
|
|
25
|
+
} from "@repo/validation";
|
|
22
26
|
import YAML from "yaml";
|
|
23
27
|
|
|
24
28
|
import type { ContentSource } from "./content-source.js";
|
|
@@ -239,47 +243,8 @@ const defaultLinkLabel = (input: {
|
|
|
239
243
|
}
|
|
240
244
|
};
|
|
241
245
|
|
|
242
|
-
const buildGoogleFontsCssUrl = (
|
|
243
|
-
fonts: MintlifyDocsConfig["fonts"]
|
|
244
|
-
): string | undefined => {
|
|
245
|
-
if (!fonts) {
|
|
246
|
-
return undefined;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const fontEntries: { family: string; source?: string }[] = [];
|
|
250
|
-
if (fonts.family) {
|
|
251
|
-
fontEntries.push({ family: fonts.family, source: fonts.source });
|
|
252
|
-
}
|
|
253
|
-
if (fonts.body) {
|
|
254
|
-
fontEntries.push({
|
|
255
|
-
family: fonts.body.family,
|
|
256
|
-
source: fonts.body.source,
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
if (fonts.heading) {
|
|
260
|
-
fontEntries.push({
|
|
261
|
-
family: fonts.heading.family,
|
|
262
|
-
source: fonts.heading.source,
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const googleFamilies = [
|
|
267
|
-
...new Set(
|
|
268
|
-
fontEntries.filter((entry) => !entry.source).map((entry) => entry.family)
|
|
269
|
-
),
|
|
270
|
-
];
|
|
271
|
-
if (!googleFamilies.length) {
|
|
272
|
-
return undefined;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const params = googleFamilies.map(
|
|
276
|
-
(family) => `family=${encodeURIComponent(family).replaceAll("%20", "+")}`
|
|
277
|
-
);
|
|
278
|
-
return `https://fonts.googleapis.com/css2?${params.join("&")}&display=swap`;
|
|
279
|
-
};
|
|
280
|
-
|
|
281
246
|
// oxlint-disable-next-line eslint/complexity
|
|
282
|
-
const mapDocsConfig = (docs:
|
|
247
|
+
const mapDocsConfig = (docs: DocsConfig): SiteConfig => {
|
|
283
248
|
const navigation = {
|
|
284
249
|
global:
|
|
285
250
|
docs.navbar?.links?.length || docs.navigation.global?.anchors?.length
|
|
@@ -334,17 +299,6 @@ const mapDocsConfig = (docs: MintlifyDocsConfig): SiteConfig => {
|
|
|
334
299
|
})),
|
|
335
300
|
} satisfies SiteConfig["navigation"];
|
|
336
301
|
|
|
337
|
-
const baseFontFamily = docs.fonts?.family;
|
|
338
|
-
const fonts =
|
|
339
|
-
docs.fonts && (baseFontFamily || docs.fonts.body || docs.fonts.heading)
|
|
340
|
-
? {
|
|
341
|
-
body: docs.fonts.body?.family ?? baseFontFamily,
|
|
342
|
-
cssUrl: buildGoogleFontsCssUrl(docs.fonts),
|
|
343
|
-
heading: docs.fonts.heading?.family ?? baseFontFamily,
|
|
344
|
-
provider: "google" as const,
|
|
345
|
-
}
|
|
346
|
-
: undefined;
|
|
347
|
-
|
|
348
302
|
return {
|
|
349
303
|
collections: [
|
|
350
304
|
{
|
|
@@ -355,7 +309,6 @@ const mapDocsConfig = (docs: MintlifyDocsConfig): SiteConfig => {
|
|
|
355
309
|
type: "docs",
|
|
356
310
|
},
|
|
357
311
|
],
|
|
358
|
-
colors: docs.colors,
|
|
359
312
|
contextual: docs.contextual,
|
|
360
313
|
description: docs.description,
|
|
361
314
|
favicon:
|
|
@@ -366,10 +319,10 @@ const mapDocsConfig = (docs: MintlifyDocsConfig): SiteConfig => {
|
|
|
366
319
|
themeToggle: docs.appearance?.strict !== true,
|
|
367
320
|
toc: true,
|
|
368
321
|
},
|
|
369
|
-
fonts,
|
|
370
322
|
logo: docs.logo
|
|
371
323
|
? {
|
|
372
324
|
dark: typeof docs.logo === "string" ? docs.logo : docs.logo.dark,
|
|
325
|
+
href: typeof docs.logo === "string" ? undefined : docs.logo.href,
|
|
373
326
|
light: typeof docs.logo === "string" ? docs.logo : docs.logo.light,
|
|
374
327
|
}
|
|
375
328
|
: undefined,
|
|
@@ -381,7 +334,6 @@ const mapDocsConfig = (docs: MintlifyDocsConfig): SiteConfig => {
|
|
|
381
334
|
Boolean(docs.api?.openapi || docs.api?.asyncapi),
|
|
382
335
|
},
|
|
383
336
|
seo: docs.seo,
|
|
384
|
-
theme: docs.theme,
|
|
385
337
|
};
|
|
386
338
|
};
|
|
387
339
|
|
|
@@ -504,15 +456,28 @@ const loadDocsConfig = async (
|
|
|
504
456
|
|
|
505
457
|
try {
|
|
506
458
|
const parsed = await readResolvedJsonConfig(source, DOCS_CONFIG_FILE);
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
459
|
+
|
|
460
|
+
// Try SiteConfig format first (has collections, theme, colors, etc.)
|
|
461
|
+
const siteResult = validateSiteConfig(parsed);
|
|
462
|
+
if (siteResult.success) {
|
|
463
|
+
return {
|
|
464
|
+
config: siteResult.data,
|
|
465
|
+
ok: true,
|
|
466
|
+
warnings: [],
|
|
467
|
+
};
|
|
510
468
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
469
|
+
|
|
470
|
+
// Fall back to DocsConfig format (Mintlify-compatible) and map to SiteConfig
|
|
471
|
+
const docsResult = validateDocsConfig(parsed);
|
|
472
|
+
if (docsResult.success) {
|
|
473
|
+
return {
|
|
474
|
+
config: mapDocsConfig(docsResult.data),
|
|
475
|
+
ok: true,
|
|
476
|
+
warnings: [],
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return { errors: docsResult.errors, ok: false };
|
|
516
481
|
} catch (error) {
|
|
517
482
|
return {
|
|
518
483
|
errors: [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContentType,
|
|
1
|
+
import type { ContentType, DocsConfig, FrontmatterByType, SiteConfig } from "@repo/models";
|
|
2
2
|
export type ValidationResult<T> = {
|
|
3
3
|
success: true;
|
|
4
4
|
data: T;
|
|
@@ -7,6 +7,6 @@ export type ValidationResult<T> = {
|
|
|
7
7
|
errors: string[];
|
|
8
8
|
};
|
|
9
9
|
export declare const validateSiteConfig: (input: unknown) => ValidationResult<SiteConfig>;
|
|
10
|
-
export declare const validateDocsConfig: (input: unknown) => ValidationResult<
|
|
10
|
+
export declare const validateDocsConfig: (input: unknown) => ValidationResult<DocsConfig>;
|
|
11
11
|
export declare const validateFrontmatter: <Type extends ContentType>(type: Type, input: unknown) => ValidationResult<FrontmatterByType[Type]>;
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,UAAU,EACX,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC1B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC1B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAQzC,eAAO,MAAM,kBAAkB,GAC7B,OAAO,OAAO,KACb,gBAAgB,CAAC,UAAU,CAQ7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,OAAO,OAAO,KACb,gBAAgB,CAAC,UAAU,CAQ7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,IAAI,SAAS,WAAW,EAC1D,MAAM,IAAI,EACV,OAAO,OAAO,KACb,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAS1C,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocsConfigSchema, FrontmatterSchemaByType, SiteConfigSchema, } from "@repo/models";
|
|
2
2
|
const formatIssues = (issues) => issues.map((issue) => {
|
|
3
3
|
const path = issue.path.length ? issue.path.map(String).join(".") : "root";
|
|
4
4
|
return `${path}: ${issue.message}`;
|
|
@@ -12,7 +12,7 @@ export const validateSiteConfig = (input) => {
|
|
|
12
12
|
return { errors: issues, success: false };
|
|
13
13
|
};
|
|
14
14
|
export const validateDocsConfig = (input) => {
|
|
15
|
-
const result =
|
|
15
|
+
const result = DocsConfigSchema.safeParse(input);
|
|
16
16
|
if (result.success) {
|
|
17
17
|
return { data: result.data, success: true };
|
|
18
18
|
}
|