fumadocs-mdx 11.5.2 → 11.5.4
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/dist/{chunk-USWGH3VH.js → chunk-2FUWXPXA.js} +4 -5
- package/dist/{chunk-3PXNPJQ2.js → chunk-IZURUUPO.js} +1 -1
- package/dist/chunk-KGLACICA.js +43 -0
- package/dist/config/index.d.cts +2 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +4 -19
- package/dist/{define-B4aTedg-.d.cts → define-DxwgTgV6.d.cts} +15 -20
- package/dist/{define-B4aTedg-.d.ts → define-DxwgTgV6.d.ts} +15 -20
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/loader-mdx.cjs +49 -38
- package/dist/loader-mdx.js +11 -34
- package/dist/next/index.cjs +143 -84
- package/dist/next/index.js +105 -80
- package/dist/runtime/async.cjs +1 -1
- package/dist/runtime/async.d.cts +3 -3
- package/dist/runtime/async.d.ts +3 -3
- package/dist/runtime/async.js +1 -1
- package/dist/{types-qPYo6njm.d.ts → types-8ecOBKxa.d.cts} +3 -3
- package/dist/{types-C214DTNR.d.cts → types-BQ1vyPw8.d.ts} +3 -3
- package/package.json +4 -6
|
@@ -10,7 +10,7 @@ import { pathToFileURL } from "node:url";
|
|
|
10
10
|
function findConfigFile() {
|
|
11
11
|
return path.resolve("source.config.ts");
|
|
12
12
|
}
|
|
13
|
-
var cache =
|
|
13
|
+
var cache = null;
|
|
14
14
|
async function compileConfig(configPath) {
|
|
15
15
|
const { build } = await import("esbuild");
|
|
16
16
|
const transformed = await build({
|
|
@@ -32,9 +32,8 @@ async function compileConfig(configPath) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
async function loadConfig(configPath, hash, build = false) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return await cached.config;
|
|
35
|
+
if (cache && cache.hash === hash) {
|
|
36
|
+
return await cache.config;
|
|
38
37
|
}
|
|
39
38
|
if (build) await compileConfig(configPath);
|
|
40
39
|
const url = pathToFileURL(path.resolve(".source/source.config.mjs"));
|
|
@@ -46,7 +45,7 @@ async function loadConfig(configPath, hash, build = false) {
|
|
|
46
45
|
if (err !== null) throw new Error(err);
|
|
47
46
|
return config2;
|
|
48
47
|
});
|
|
49
|
-
cache
|
|
48
|
+
cache = { config, hash };
|
|
50
49
|
return await config;
|
|
51
50
|
}
|
|
52
51
|
async function getConfigHash(configPath) {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/utils/schema.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var metaSchema = z.object({
|
|
4
|
+
title: z.string().optional(),
|
|
5
|
+
pages: z.array(z.string()).optional(),
|
|
6
|
+
description: z.string().optional(),
|
|
7
|
+
root: z.boolean().optional(),
|
|
8
|
+
defaultOpen: z.boolean().optional(),
|
|
9
|
+
icon: z.string().optional()
|
|
10
|
+
});
|
|
11
|
+
var frontmatterSchema = z.object({
|
|
12
|
+
title: z.string(),
|
|
13
|
+
description: z.string().optional(),
|
|
14
|
+
icon: z.string().optional(),
|
|
15
|
+
full: z.boolean().optional(),
|
|
16
|
+
// Fumadocs OpenAPI generated
|
|
17
|
+
_openapi: z.object({}).passthrough().optional()
|
|
18
|
+
});
|
|
19
|
+
async function validate(schema, data, context, errorMessage) {
|
|
20
|
+
if (typeof schema === "function" && !("~standard" in schema)) {
|
|
21
|
+
schema = schema(context);
|
|
22
|
+
}
|
|
23
|
+
if ("~standard" in schema) {
|
|
24
|
+
const result = await schema["~standard"].validate(
|
|
25
|
+
data
|
|
26
|
+
);
|
|
27
|
+
if (result.issues) {
|
|
28
|
+
throw new Error(formatError(errorMessage, result.issues));
|
|
29
|
+
}
|
|
30
|
+
return result.value;
|
|
31
|
+
}
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
function formatError(message, issues) {
|
|
35
|
+
return `${message}:
|
|
36
|
+
${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
metaSchema,
|
|
41
|
+
frontmatterSchema,
|
|
42
|
+
validate
|
|
43
|
+
};
|
package/dist/config/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a as BaseCollection, B as BaseCollectionEntry, C as CollectionSchema, h as DefaultMDXOptions, D as DocCollection, c as DocsCollection, F as FileInfo, G as GlobalConfig, M as MarkdownProps, b as MetaCollection, d as defineCollections, g as defineConfig, e as defineDocs, f as frontmatterSchema, i as getDefaultMDXOptions, m as metaSchema } from '../define-DxwgTgV6.cjs';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
4
|
import '@mdx-js/mdx';
|
|
@@ -6,8 +6,8 @@ import 'mdx/types';
|
|
|
6
6
|
import 'fumadocs-core/mdx-plugins';
|
|
7
7
|
import 'fumadocs-core/server';
|
|
8
8
|
import 'react';
|
|
9
|
-
import '@standard-schema/spec';
|
|
10
9
|
import 'zod';
|
|
10
|
+
import '@standard-schema/spec';
|
|
11
11
|
|
|
12
12
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
13
13
|
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a as BaseCollection, B as BaseCollectionEntry, C as CollectionSchema, h as DefaultMDXOptions, D as DocCollection, c as DocsCollection, F as FileInfo, G as GlobalConfig, M as MarkdownProps, b as MetaCollection, d as defineCollections, g as defineConfig, e as defineDocs, f as frontmatterSchema, i as getDefaultMDXOptions, m as metaSchema } from '../define-DxwgTgV6.js';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
4
|
import '@mdx-js/mdx';
|
|
@@ -6,8 +6,8 @@ import 'mdx/types';
|
|
|
6
6
|
import 'fumadocs-core/mdx-plugins';
|
|
7
7
|
import 'fumadocs-core/server';
|
|
8
8
|
import 'react';
|
|
9
|
-
import '@standard-schema/spec';
|
|
10
9
|
import 'zod';
|
|
10
|
+
import '@standard-schema/spec';
|
|
11
11
|
|
|
12
12
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
13
13
|
|
package/dist/config/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
frontmatterSchema,
|
|
3
|
+
metaSchema
|
|
4
|
+
} from "../chunk-KGLACICA.js";
|
|
1
5
|
import {
|
|
2
6
|
remarkInclude
|
|
3
7
|
} from "../chunk-PY2KKTR2.js";
|
|
@@ -5,25 +9,6 @@ import {
|
|
|
5
9
|
getDefaultMDXOptions
|
|
6
10
|
} from "../chunk-IOENRFUX.js";
|
|
7
11
|
|
|
8
|
-
// src/utils/schema.ts
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
var metaSchema = z.object({
|
|
11
|
-
title: z.string().optional(),
|
|
12
|
-
pages: z.array(z.string()).optional(),
|
|
13
|
-
description: z.string().optional(),
|
|
14
|
-
root: z.boolean().optional(),
|
|
15
|
-
defaultOpen: z.boolean().optional(),
|
|
16
|
-
icon: z.string().optional()
|
|
17
|
-
});
|
|
18
|
-
var frontmatterSchema = z.object({
|
|
19
|
-
title: z.string(),
|
|
20
|
-
description: z.string().optional(),
|
|
21
|
-
icon: z.string().optional(),
|
|
22
|
-
full: z.boolean().optional(),
|
|
23
|
-
// Fumadocs OpenAPI generated
|
|
24
|
-
_openapi: z.object({}).passthrough().optional()
|
|
25
|
-
});
|
|
26
|
-
|
|
27
12
|
// src/config/define.ts
|
|
28
13
|
function defineCollections(options) {
|
|
29
14
|
return {
|
|
@@ -5,8 +5,8 @@ import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
|
5
5
|
import { TableOfContents } from 'fumadocs-core/server';
|
|
6
6
|
import { Pluggable } from 'unified';
|
|
7
7
|
import { FC } from 'react';
|
|
8
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
9
8
|
import { z } from 'zod';
|
|
9
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
10
10
|
|
|
11
11
|
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
12
12
|
type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
|
|
@@ -42,12 +42,6 @@ interface GlobalConfig {
|
|
|
42
42
|
*/
|
|
43
43
|
generateManifest?: boolean;
|
|
44
44
|
}
|
|
45
|
-
type InferSchema<CollectionOut> = CollectionOut extends {
|
|
46
|
-
_type: {
|
|
47
|
-
schema: infer T;
|
|
48
|
-
};
|
|
49
|
-
} ? T : never;
|
|
50
|
-
type InferSchemaType<C> = InferSchema<C> extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<InferSchema<C>> : never;
|
|
51
45
|
interface FileInfo {
|
|
52
46
|
path: string;
|
|
53
47
|
absolutePath: string;
|
|
@@ -136,15 +130,8 @@ declare const frontmatterSchema: z.ZodObject<{
|
|
|
136
130
|
_openapi?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
137
131
|
}>;
|
|
138
132
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
source: string;
|
|
142
|
-
/**
|
|
143
|
-
* Compile MDX to JavaScript
|
|
144
|
-
*/
|
|
145
|
-
buildMDX: (source: string, options?: ProcessorOptions) => Promise<string>;
|
|
146
|
-
}
|
|
147
|
-
interface BaseCollection<Schema> {
|
|
133
|
+
type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
|
|
134
|
+
interface BaseCollection {
|
|
148
135
|
/**
|
|
149
136
|
* Directories to scan
|
|
150
137
|
*/
|
|
@@ -155,18 +142,25 @@ interface BaseCollection<Schema> {
|
|
|
155
142
|
* Include all files if not specified
|
|
156
143
|
*/
|
|
157
144
|
files?: string[];
|
|
158
|
-
schema?: Schema | ((ctx: TransformContext) => Schema);
|
|
159
145
|
}
|
|
160
|
-
interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection
|
|
146
|
+
interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection {
|
|
161
147
|
type: 'meta';
|
|
148
|
+
schema?: CollectionSchema<Schema, {
|
|
149
|
+
path: string;
|
|
150
|
+
source: string;
|
|
151
|
+
}>;
|
|
162
152
|
}
|
|
163
|
-
interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection
|
|
153
|
+
interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection {
|
|
164
154
|
type: 'doc';
|
|
165
155
|
mdxOptions?: MDXOptions;
|
|
166
156
|
/**
|
|
167
157
|
* Load files with async
|
|
168
158
|
*/
|
|
169
159
|
async?: Async;
|
|
160
|
+
schema?: CollectionSchema<Schema, {
|
|
161
|
+
path: string;
|
|
162
|
+
source: string;
|
|
163
|
+
}>;
|
|
170
164
|
}
|
|
171
165
|
interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> {
|
|
172
166
|
type: 'docs';
|
|
@@ -205,9 +199,10 @@ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmat
|
|
|
205
199
|
type: 'meta';
|
|
206
200
|
_type: {
|
|
207
201
|
schema: MetaSchema;
|
|
202
|
+
async: false;
|
|
208
203
|
};
|
|
209
204
|
};
|
|
210
205
|
};
|
|
211
206
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
212
207
|
|
|
213
|
-
export { type BaseCollectionEntry as B, type
|
|
208
|
+
export { type BaseCollectionEntry as B, type CollectionSchema as C, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type MarkdownProps as M, type BaseCollection as a, type MetaCollection as b, type DocsCollection as c, defineCollections as d, defineDocs as e, frontmatterSchema as f, defineConfig as g, type DefaultMDXOptions as h, getDefaultMDXOptions as i, metaSchema as m };
|
|
@@ -5,8 +5,8 @@ import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
|
5
5
|
import { TableOfContents } from 'fumadocs-core/server';
|
|
6
6
|
import { Pluggable } from 'unified';
|
|
7
7
|
import { FC } from 'react';
|
|
8
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
9
8
|
import { z } from 'zod';
|
|
9
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
10
10
|
|
|
11
11
|
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
12
12
|
type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
|
|
@@ -42,12 +42,6 @@ interface GlobalConfig {
|
|
|
42
42
|
*/
|
|
43
43
|
generateManifest?: boolean;
|
|
44
44
|
}
|
|
45
|
-
type InferSchema<CollectionOut> = CollectionOut extends {
|
|
46
|
-
_type: {
|
|
47
|
-
schema: infer T;
|
|
48
|
-
};
|
|
49
|
-
} ? T : never;
|
|
50
|
-
type InferSchemaType<C> = InferSchema<C> extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<InferSchema<C>> : never;
|
|
51
45
|
interface FileInfo {
|
|
52
46
|
path: string;
|
|
53
47
|
absolutePath: string;
|
|
@@ -136,15 +130,8 @@ declare const frontmatterSchema: z.ZodObject<{
|
|
|
136
130
|
_openapi?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
137
131
|
}>;
|
|
138
132
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
source: string;
|
|
142
|
-
/**
|
|
143
|
-
* Compile MDX to JavaScript
|
|
144
|
-
*/
|
|
145
|
-
buildMDX: (source: string, options?: ProcessorOptions) => Promise<string>;
|
|
146
|
-
}
|
|
147
|
-
interface BaseCollection<Schema> {
|
|
133
|
+
type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
|
|
134
|
+
interface BaseCollection {
|
|
148
135
|
/**
|
|
149
136
|
* Directories to scan
|
|
150
137
|
*/
|
|
@@ -155,18 +142,25 @@ interface BaseCollection<Schema> {
|
|
|
155
142
|
* Include all files if not specified
|
|
156
143
|
*/
|
|
157
144
|
files?: string[];
|
|
158
|
-
schema?: Schema | ((ctx: TransformContext) => Schema);
|
|
159
145
|
}
|
|
160
|
-
interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection
|
|
146
|
+
interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection {
|
|
161
147
|
type: 'meta';
|
|
148
|
+
schema?: CollectionSchema<Schema, {
|
|
149
|
+
path: string;
|
|
150
|
+
source: string;
|
|
151
|
+
}>;
|
|
162
152
|
}
|
|
163
|
-
interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection
|
|
153
|
+
interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection {
|
|
164
154
|
type: 'doc';
|
|
165
155
|
mdxOptions?: MDXOptions;
|
|
166
156
|
/**
|
|
167
157
|
* Load files with async
|
|
168
158
|
*/
|
|
169
159
|
async?: Async;
|
|
160
|
+
schema?: CollectionSchema<Schema, {
|
|
161
|
+
path: string;
|
|
162
|
+
source: string;
|
|
163
|
+
}>;
|
|
170
164
|
}
|
|
171
165
|
interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> {
|
|
172
166
|
type: 'docs';
|
|
@@ -205,9 +199,10 @@ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmat
|
|
|
205
199
|
type: 'meta';
|
|
206
200
|
_type: {
|
|
207
201
|
schema: MetaSchema;
|
|
202
|
+
async: false;
|
|
208
203
|
};
|
|
209
204
|
};
|
|
210
205
|
};
|
|
211
206
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
212
207
|
|
|
213
|
-
export { type BaseCollectionEntry as B, type
|
|
208
|
+
export { type BaseCollectionEntry as B, type CollectionSchema as C, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type MarkdownProps as M, type BaseCollection as a, type MetaCollection as b, type DocsCollection as c, defineCollections as d, defineDocs as e, frontmatterSchema as f, defineConfig as g, type DefaultMDXOptions as h, getDefaultMDXOptions as i, metaSchema as m };
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
-
import { B as BaseCollectionEntry } from './define-
|
|
3
|
-
import { R as Runtime } from './types-
|
|
4
|
-
export { a as RuntimeFile } from './types-
|
|
2
|
+
import { B as BaseCollectionEntry } from './define-DxwgTgV6.cjs';
|
|
3
|
+
import { R as Runtime } from './types-8ecOBKxa.cjs';
|
|
4
|
+
export { a as RuntimeFile } from './types-8ecOBKxa.cjs';
|
|
5
5
|
import '@mdx-js/mdx';
|
|
6
6
|
import 'mdx/types';
|
|
7
7
|
import 'fumadocs-core/mdx-plugins';
|
|
8
8
|
import 'fumadocs-core/server';
|
|
9
9
|
import 'unified';
|
|
10
10
|
import 'react';
|
|
11
|
-
import '@standard-schema/spec';
|
|
12
11
|
import 'zod';
|
|
12
|
+
import '@standard-schema/spec';
|
|
13
13
|
|
|
14
14
|
declare const _runtime: Runtime;
|
|
15
15
|
declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
-
import { B as BaseCollectionEntry } from './define-
|
|
3
|
-
import { R as Runtime } from './types-
|
|
4
|
-
export { a as RuntimeFile } from './types-
|
|
2
|
+
import { B as BaseCollectionEntry } from './define-DxwgTgV6.js';
|
|
3
|
+
import { R as Runtime } from './types-BQ1vyPw8.js';
|
|
4
|
+
export { a as RuntimeFile } from './types-BQ1vyPw8.js';
|
|
5
5
|
import '@mdx-js/mdx';
|
|
6
6
|
import 'mdx/types';
|
|
7
7
|
import 'fumadocs-core/mdx-plugins';
|
|
8
8
|
import 'fumadocs-core/server';
|
|
9
9
|
import 'unified';
|
|
10
10
|
import 'react';
|
|
11
|
-
import '@standard-schema/spec';
|
|
12
11
|
import 'zod';
|
|
12
|
+
import '@standard-schema/spec';
|
|
13
13
|
|
|
14
14
|
declare const _runtime: Runtime;
|
|
15
15
|
declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
|
package/dist/index.js
CHANGED
package/dist/loader-mdx.cjs
CHANGED
|
@@ -222,7 +222,7 @@ function buildConfig(config) {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
// src/utils/config.ts
|
|
225
|
-
var cache =
|
|
225
|
+
var cache = null;
|
|
226
226
|
async function compileConfig(configPath) {
|
|
227
227
|
const { build } = await import("esbuild");
|
|
228
228
|
const transformed = await build({
|
|
@@ -244,9 +244,8 @@ async function compileConfig(configPath) {
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
async function loadConfig(configPath, hash, build = false) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return await cached.config;
|
|
247
|
+
if (cache && cache.hash === hash) {
|
|
248
|
+
return await cache.config;
|
|
250
249
|
}
|
|
251
250
|
if (build) await compileConfig(configPath);
|
|
252
251
|
const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
|
|
@@ -258,7 +257,7 @@ async function loadConfig(configPath, hash, build = false) {
|
|
|
258
257
|
if (err !== null) throw new Error(err);
|
|
259
258
|
return config2;
|
|
260
259
|
});
|
|
261
|
-
cache
|
|
260
|
+
cache = { config, hash };
|
|
262
261
|
return await config;
|
|
263
262
|
}
|
|
264
263
|
async function getConfigHash(configPath) {
|
|
@@ -355,12 +354,6 @@ async function buildMDX(cacheKey, source, options = {}) {
|
|
|
355
354
|
});
|
|
356
355
|
}
|
|
357
356
|
|
|
358
|
-
// src/utils/format-error.ts
|
|
359
|
-
function formatError(message, issues) {
|
|
360
|
-
return `${message}:
|
|
361
|
-
${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
357
|
// src/utils/git-timestamp.ts
|
|
365
358
|
var import_node_path = __toESM(require("path"), 1);
|
|
366
359
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
@@ -389,6 +382,44 @@ function getGitTimestamp(file) {
|
|
|
389
382
|
});
|
|
390
383
|
}
|
|
391
384
|
|
|
385
|
+
// src/utils/schema.ts
|
|
386
|
+
var import_zod = require("zod");
|
|
387
|
+
var metaSchema = import_zod.z.object({
|
|
388
|
+
title: import_zod.z.string().optional(),
|
|
389
|
+
pages: import_zod.z.array(import_zod.z.string()).optional(),
|
|
390
|
+
description: import_zod.z.string().optional(),
|
|
391
|
+
root: import_zod.z.boolean().optional(),
|
|
392
|
+
defaultOpen: import_zod.z.boolean().optional(),
|
|
393
|
+
icon: import_zod.z.string().optional()
|
|
394
|
+
});
|
|
395
|
+
var frontmatterSchema = import_zod.z.object({
|
|
396
|
+
title: import_zod.z.string(),
|
|
397
|
+
description: import_zod.z.string().optional(),
|
|
398
|
+
icon: import_zod.z.string().optional(),
|
|
399
|
+
full: import_zod.z.boolean().optional(),
|
|
400
|
+
// Fumadocs OpenAPI generated
|
|
401
|
+
_openapi: import_zod.z.object({}).passthrough().optional()
|
|
402
|
+
});
|
|
403
|
+
async function validate(schema, data, context, errorMessage) {
|
|
404
|
+
if (typeof schema === "function" && !("~standard" in schema)) {
|
|
405
|
+
schema = schema(context);
|
|
406
|
+
}
|
|
407
|
+
if ("~standard" in schema) {
|
|
408
|
+
const result = await schema["~standard"].validate(
|
|
409
|
+
data
|
|
410
|
+
);
|
|
411
|
+
if (result.issues) {
|
|
412
|
+
throw new Error(formatError(errorMessage, result.issues));
|
|
413
|
+
}
|
|
414
|
+
return result.value;
|
|
415
|
+
}
|
|
416
|
+
return data;
|
|
417
|
+
}
|
|
418
|
+
function formatError(message, issues) {
|
|
419
|
+
return `${message}:
|
|
420
|
+
${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
421
|
+
}
|
|
422
|
+
|
|
392
423
|
// src/loader-mdx.ts
|
|
393
424
|
function parseQuery(query) {
|
|
394
425
|
let collection;
|
|
@@ -417,35 +448,15 @@ async function loader(source, callback) {
|
|
|
417
448
|
}
|
|
418
449
|
const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
|
|
419
450
|
if (collection?.schema) {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const res = await buildMDX(
|
|
425
|
-
`${configHash}:${collectionId ?? "global"}`,
|
|
426
|
-
v,
|
|
427
|
-
options
|
|
428
|
-
);
|
|
429
|
-
return String(res.value);
|
|
430
|
-
},
|
|
451
|
+
matter2.data = await validate(
|
|
452
|
+
collection.schema,
|
|
453
|
+
matter2.data,
|
|
454
|
+
{
|
|
431
455
|
source,
|
|
432
456
|
path: filePath
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
const result = await schema["~standard"].validate(
|
|
437
|
-
matter2.data
|
|
438
|
-
);
|
|
439
|
-
if (result.issues) {
|
|
440
|
-
callback(
|
|
441
|
-
new Error(
|
|
442
|
-
formatError(`invalid frontmatter in ${filePath}:`, result.issues)
|
|
443
|
-
)
|
|
444
|
-
);
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
matter2.data = result.value;
|
|
448
|
-
}
|
|
457
|
+
},
|
|
458
|
+
`invalid frontmatter in ${filePath}:`
|
|
459
|
+
);
|
|
449
460
|
}
|
|
450
461
|
let timestamp;
|
|
451
462
|
if (config.global?.lastModifiedTime === "git")
|
package/dist/loader-mdx.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getConfigHash,
|
|
3
3
|
loadConfig
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2FUWXPXA.js";
|
|
5
|
+
import {
|
|
6
|
+
validate
|
|
7
|
+
} from "./chunk-KGLACICA.js";
|
|
5
8
|
import {
|
|
6
9
|
remarkInclude
|
|
7
10
|
} from "./chunk-PY2KKTR2.js";
|
|
@@ -45,12 +48,6 @@ async function buildMDX(cacheKey, source, options = {}) {
|
|
|
45
48
|
});
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
// src/utils/format-error.ts
|
|
49
|
-
function formatError(message, issues) {
|
|
50
|
-
return `${message}:
|
|
51
|
-
${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
51
|
// src/utils/git-timestamp.ts
|
|
55
52
|
import path from "node:path";
|
|
56
53
|
import fs from "node:fs";
|
|
@@ -107,35 +104,15 @@ async function loader(source, callback) {
|
|
|
107
104
|
}
|
|
108
105
|
const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
|
|
109
106
|
if (collection?.schema) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const res = await buildMDX(
|
|
115
|
-
`${configHash}:${collectionId ?? "global"}`,
|
|
116
|
-
v,
|
|
117
|
-
options
|
|
118
|
-
);
|
|
119
|
-
return String(res.value);
|
|
120
|
-
},
|
|
107
|
+
matter.data = await validate(
|
|
108
|
+
collection.schema,
|
|
109
|
+
matter.data,
|
|
110
|
+
{
|
|
121
111
|
source,
|
|
122
112
|
path: filePath
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const result = await schema["~standard"].validate(
|
|
127
|
-
matter.data
|
|
128
|
-
);
|
|
129
|
-
if (result.issues) {
|
|
130
|
-
callback(
|
|
131
|
-
new Error(
|
|
132
|
-
formatError(`invalid frontmatter in ${filePath}:`, result.issues)
|
|
133
|
-
)
|
|
134
|
-
);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
matter.data = result.value;
|
|
138
|
-
}
|
|
113
|
+
},
|
|
114
|
+
`invalid frontmatter in ${filePath}:`
|
|
115
|
+
);
|
|
139
116
|
}
|
|
140
117
|
let timestamp;
|
|
141
118
|
if (config.global?.lastModifiedTime === "git")
|