fumadocs-mdx 11.4.0 → 11.5.0
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-IU4D6M3A.js → chunk-2C4NRJ5O.js} +1 -1
- package/dist/chunk-3PXNPJQ2.js +72 -0
- package/dist/{chunk-2DJQ3DOD.js → chunk-6ZVE73IT.js} +9 -6
- package/dist/config/index.cjs +1 -1
- package/dist/config/index.d.cts +4 -4
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js +1 -1
- package/dist/define-_brlBG8j.d.cts +201 -0
- package/dist/define-_brlBG8j.d.ts +201 -0
- package/dist/index.cjs +34 -17
- package/dist/index.d.cts +23 -6
- package/dist/index.d.ts +23 -6
- package/dist/index.js +7 -51
- package/dist/loader-mdx.cjs +26 -30
- package/dist/loader-mdx.js +19 -26
- package/dist/next/index.cjs +159 -121
- package/dist/next/index.js +144 -117
- package/dist/runtime/async.cjs +125 -41
- package/dist/runtime/async.d.cts +25 -14
- package/dist/runtime/async.d.ts +25 -14
- package/dist/runtime/async.js +53 -35
- package/dist/{watcher-7ALL6XOY.js → watcher-IAZDSTU7.js} +10 -2
- package/package.json +7 -6
- package/dist/build-mdx-o0kbHSlp.d.cts +0 -109
- package/dist/build-mdx-o0kbHSlp.d.ts +0 -109
- package/dist/define-BB9hRiTI.d.cts +0 -106
- package/dist/define-D3l733EX.d.ts +0 -106
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
import { PageData, MetaData,
|
|
2
|
-
import { F as FileInfo, B as BaseCollectionEntry } from './
|
|
3
|
-
import '
|
|
1
|
+
import { Source, PageData, MetaData, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
+
import { F as FileInfo, e as defineCollections, M as MarkdownProps, B as BaseCollectionEntry, d as DocsCollection } from './define-_brlBG8j.cjs';
|
|
3
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
|
+
import '@mdx-js/mdx';
|
|
4
5
|
import 'mdx/types';
|
|
5
6
|
import 'fumadocs-core/mdx-plugins';
|
|
6
7
|
import 'fumadocs-core/server';
|
|
7
|
-
import '@mdx-js/mdx';
|
|
8
8
|
import 'unified';
|
|
9
9
|
import 'react';
|
|
10
|
+
import 'zod';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
interface RuntimeFile {
|
|
13
|
+
info: FileInfo;
|
|
14
|
+
data: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
interface Runtime {
|
|
17
|
+
doc: <C>(files: RuntimeFile[]) => C extends ReturnType<typeof defineCollections<'doc', infer Schema extends StandardSchemaV1, false>> ? (Omit<MarkdownProps, keyof StandardSchemaV1.InferOutput<Schema>> & StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry)[] : never;
|
|
18
|
+
meta: <C>(files: RuntimeFile[]) => C extends ReturnType<typeof defineCollections<'meta', infer Schema extends StandardSchemaV1, false>> ? (StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry)[] : never;
|
|
19
|
+
docs: <Docs>(docs: RuntimeFile[], metas: RuntimeFile[]) => Docs extends DocsCollection ? {
|
|
20
|
+
docs: ReturnType<typeof _runtime.doc<Docs['docs']>>;
|
|
21
|
+
meta: ReturnType<typeof _runtime.meta<Docs['meta']>>;
|
|
22
|
+
toFumadocsSource: () => Source<{
|
|
23
|
+
pageData: ReturnType<typeof _runtime.doc<Docs['docs']>>[number] extends PageData & BaseCollectionEntry ? ReturnType<typeof _runtime.doc<Docs['docs']>>[number] : never;
|
|
24
|
+
metaData: ReturnType<typeof _runtime.meta<Docs['meta']>>[number] extends MetaData & BaseCollectionEntry ? ReturnType<typeof _runtime.meta<Docs['meta']>>[number] : never;
|
|
25
|
+
}>;
|
|
26
|
+
} : never;
|
|
27
|
+
}
|
|
28
|
+
declare const _runtime: Runtime;
|
|
12
29
|
declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
|
|
13
30
|
pageData: Doc;
|
|
14
31
|
metaData: Meta;
|
|
@@ -20,4 +37,4 @@ interface ResolveOptions {
|
|
|
20
37
|
}
|
|
21
38
|
declare function resolveFiles({ docs, meta, rootDir, }: ResolveOptions): VirtualFile[];
|
|
22
39
|
|
|
23
|
-
export { createMDXSource, resolveFiles
|
|
40
|
+
export { type Runtime, type RuntimeFile, _runtime, createMDXSource, resolveFiles };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
import { PageData, MetaData,
|
|
2
|
-
import { F as FileInfo, B as BaseCollectionEntry } from './
|
|
3
|
-
import '
|
|
1
|
+
import { Source, PageData, MetaData, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
+
import { F as FileInfo, e as defineCollections, M as MarkdownProps, B as BaseCollectionEntry, d as DocsCollection } from './define-_brlBG8j.js';
|
|
3
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
|
+
import '@mdx-js/mdx';
|
|
4
5
|
import 'mdx/types';
|
|
5
6
|
import 'fumadocs-core/mdx-plugins';
|
|
6
7
|
import 'fumadocs-core/server';
|
|
7
|
-
import '@mdx-js/mdx';
|
|
8
8
|
import 'unified';
|
|
9
9
|
import 'react';
|
|
10
|
+
import 'zod';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
interface RuntimeFile {
|
|
13
|
+
info: FileInfo;
|
|
14
|
+
data: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
interface Runtime {
|
|
17
|
+
doc: <C>(files: RuntimeFile[]) => C extends ReturnType<typeof defineCollections<'doc', infer Schema extends StandardSchemaV1, false>> ? (Omit<MarkdownProps, keyof StandardSchemaV1.InferOutput<Schema>> & StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry)[] : never;
|
|
18
|
+
meta: <C>(files: RuntimeFile[]) => C extends ReturnType<typeof defineCollections<'meta', infer Schema extends StandardSchemaV1, false>> ? (StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry)[] : never;
|
|
19
|
+
docs: <Docs>(docs: RuntimeFile[], metas: RuntimeFile[]) => Docs extends DocsCollection ? {
|
|
20
|
+
docs: ReturnType<typeof _runtime.doc<Docs['docs']>>;
|
|
21
|
+
meta: ReturnType<typeof _runtime.meta<Docs['meta']>>;
|
|
22
|
+
toFumadocsSource: () => Source<{
|
|
23
|
+
pageData: ReturnType<typeof _runtime.doc<Docs['docs']>>[number] extends PageData & BaseCollectionEntry ? ReturnType<typeof _runtime.doc<Docs['docs']>>[number] : never;
|
|
24
|
+
metaData: ReturnType<typeof _runtime.meta<Docs['meta']>>[number] extends MetaData & BaseCollectionEntry ? ReturnType<typeof _runtime.meta<Docs['meta']>>[number] : never;
|
|
25
|
+
}>;
|
|
26
|
+
} : never;
|
|
27
|
+
}
|
|
28
|
+
declare const _runtime: Runtime;
|
|
12
29
|
declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
|
|
13
30
|
pageData: Doc;
|
|
14
31
|
metaData: Meta;
|
|
@@ -20,4 +37,4 @@ interface ResolveOptions {
|
|
|
20
37
|
}
|
|
21
38
|
declare function resolveFiles({ docs, meta, rootDir, }: ResolveOptions): VirtualFile[];
|
|
22
39
|
|
|
23
|
-
export { createMDXSource, resolveFiles
|
|
40
|
+
export { type Runtime, type RuntimeFile, _runtime, createMDXSource, resolveFiles };
|
package/dist/index.js
CHANGED
|
@@ -1,54 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
body,
|
|
7
|
-
...exports,
|
|
8
|
-
...frontmatter,
|
|
9
|
-
_exports: file,
|
|
10
|
-
_file: info
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
return {
|
|
14
|
-
...file.default,
|
|
15
|
-
_file: info
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function createMDXSource(docs, meta = []) {
|
|
19
|
-
return {
|
|
20
|
-
files: (rootDir) => resolveFiles({
|
|
21
|
-
docs,
|
|
22
|
-
meta,
|
|
23
|
-
rootDir
|
|
24
|
-
})
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function resolveFiles({
|
|
28
|
-
docs,
|
|
29
|
-
meta,
|
|
30
|
-
rootDir = ""
|
|
31
|
-
}) {
|
|
32
|
-
const outputs = [];
|
|
33
|
-
for (const entry of docs) {
|
|
34
|
-
if (!entry._file.path.startsWith(rootDir)) continue;
|
|
35
|
-
outputs.push({
|
|
36
|
-
type: "page",
|
|
37
|
-
path: entry._file.path,
|
|
38
|
-
data: entry
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
for (const entry of meta) {
|
|
42
|
-
outputs.push({
|
|
43
|
-
type: "meta",
|
|
44
|
-
path: entry._file.path,
|
|
45
|
-
data: entry
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return outputs;
|
|
49
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
_runtime,
|
|
3
|
+
createMDXSource,
|
|
4
|
+
resolveFiles
|
|
5
|
+
} from "./chunk-3PXNPJQ2.js";
|
|
50
6
|
export {
|
|
7
|
+
_runtime,
|
|
51
8
|
createMDXSource,
|
|
52
|
-
resolveFiles
|
|
53
|
-
toRuntime
|
|
9
|
+
resolveFiles
|
|
54
10
|
};
|
package/dist/loader-mdx.cjs
CHANGED
|
@@ -180,12 +180,15 @@ function buildConfig(config) {
|
|
|
180
180
|
if (!v) {
|
|
181
181
|
continue;
|
|
182
182
|
}
|
|
183
|
-
if (typeof v === "object" && "
|
|
184
|
-
|
|
185
|
-
k,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
183
|
+
if (typeof v === "object" && "type" in v) {
|
|
184
|
+
if (v.type === "docs") {
|
|
185
|
+
collections.set(k, v);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (v.type === "doc" || v.type === "meta") {
|
|
189
|
+
collections.set(k, v);
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
189
192
|
}
|
|
190
193
|
if (k === "default") {
|
|
191
194
|
globalConfig = v;
|
|
@@ -362,21 +365,9 @@ function buildMDX(group, configHash, source, options = {}) {
|
|
|
362
365
|
}
|
|
363
366
|
|
|
364
367
|
// src/utils/format-error.ts
|
|
365
|
-
function formatError(message,
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if (key !== void 0 || _errors.length > 0) {
|
|
369
|
-
const text = key ? `${key}: ${_errors.join("\n ")}` : _errors.join("\n");
|
|
370
|
-
lines2.push(
|
|
371
|
-
text.split("\n").map((line) => `${" ".repeat(padStart)}${line}`).join("\n")
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
for (const [k, v] of Object.entries(rest)) {
|
|
375
|
-
walk(key ? `${key}.${k}` : k, v, padStart + 2);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
walk(void 0, error.format());
|
|
379
|
-
return [message, ...lines2].join("\n");
|
|
368
|
+
function formatError(message, issues) {
|
|
369
|
+
return `${message}:
|
|
370
|
+
${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
380
371
|
}
|
|
381
372
|
|
|
382
373
|
// src/utils/git-timestamp.ts
|
|
@@ -429,13 +420,14 @@ async function loader(source, callback) {
|
|
|
429
420
|
} = parseQuery(this.resourceQuery);
|
|
430
421
|
const config = await loadConfigCached(_ctx.configPath, configHash);
|
|
431
422
|
let collection = collectionId !== void 0 ? config.collections.get(collectionId) : void 0;
|
|
423
|
+
if (collection && collection.type === "docs") collection = collection.docs;
|
|
432
424
|
if (collection && collection.type !== "doc") {
|
|
433
425
|
collection = void 0;
|
|
434
426
|
}
|
|
435
427
|
const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
|
|
436
428
|
if (collection?.schema) {
|
|
437
429
|
let schema = collection.schema;
|
|
438
|
-
if (typeof schema === "function") {
|
|
430
|
+
if (typeof schema === "function" && !("~standard" in schema)) {
|
|
439
431
|
schema = schema({
|
|
440
432
|
async buildMDX(v, options = mdxOptions) {
|
|
441
433
|
const res = await buildMDX(
|
|
@@ -450,16 +442,20 @@ async function loader(source, callback) {
|
|
|
450
442
|
path: filePath
|
|
451
443
|
});
|
|
452
444
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
new Error(
|
|
457
|
-
formatError(`invalid frontmatter in ${filePath}:`, result.error)
|
|
458
|
-
)
|
|
445
|
+
if ("~standard" in schema) {
|
|
446
|
+
const result = await schema["~standard"].validate(
|
|
447
|
+
matter2.data
|
|
459
448
|
);
|
|
460
|
-
|
|
449
|
+
if (result.issues) {
|
|
450
|
+
callback(
|
|
451
|
+
new Error(
|
|
452
|
+
formatError(`invalid frontmatter in ${filePath}:`, result.issues)
|
|
453
|
+
)
|
|
454
|
+
);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
matter2.data = result.value;
|
|
461
458
|
}
|
|
462
|
-
matter2.data = result.data;
|
|
463
459
|
}
|
|
464
460
|
let timestamp;
|
|
465
461
|
if (config.global?.lastModifiedTime === "git")
|
package/dist/loader-mdx.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getConfigHash,
|
|
3
3
|
loadConfigCached
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2C4NRJ5O.js";
|
|
5
5
|
import {
|
|
6
6
|
remarkInclude
|
|
7
7
|
} from "./chunk-PY2KKTR2.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-6ZVE73IT.js";
|
|
9
9
|
|
|
10
10
|
// src/loader-mdx.ts
|
|
11
11
|
import * as path2 from "node:path";
|
|
@@ -52,21 +52,9 @@ function buildMDX(group, configHash, source, options = {}) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// src/utils/format-error.ts
|
|
55
|
-
function formatError(message,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (key !== void 0 || _errors.length > 0) {
|
|
59
|
-
const text = key ? `${key}: ${_errors.join("\n ")}` : _errors.join("\n");
|
|
60
|
-
lines2.push(
|
|
61
|
-
text.split("\n").map((line) => `${" ".repeat(padStart)}${line}`).join("\n")
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
for (const [k, v] of Object.entries(rest)) {
|
|
65
|
-
walk(key ? `${key}.${k}` : k, v, padStart + 2);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
walk(void 0, error.format());
|
|
69
|
-
return [message, ...lines2].join("\n");
|
|
55
|
+
function formatError(message, issues) {
|
|
56
|
+
return `${message}:
|
|
57
|
+
${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
70
58
|
}
|
|
71
59
|
|
|
72
60
|
// src/utils/git-timestamp.ts
|
|
@@ -119,13 +107,14 @@ async function loader(source, callback) {
|
|
|
119
107
|
} = parseQuery(this.resourceQuery);
|
|
120
108
|
const config = await loadConfigCached(_ctx.configPath, configHash);
|
|
121
109
|
let collection = collectionId !== void 0 ? config.collections.get(collectionId) : void 0;
|
|
110
|
+
if (collection && collection.type === "docs") collection = collection.docs;
|
|
122
111
|
if (collection && collection.type !== "doc") {
|
|
123
112
|
collection = void 0;
|
|
124
113
|
}
|
|
125
114
|
const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
|
|
126
115
|
if (collection?.schema) {
|
|
127
116
|
let schema = collection.schema;
|
|
128
|
-
if (typeof schema === "function") {
|
|
117
|
+
if (typeof schema === "function" && !("~standard" in schema)) {
|
|
129
118
|
schema = schema({
|
|
130
119
|
async buildMDX(v, options = mdxOptions) {
|
|
131
120
|
const res = await buildMDX(
|
|
@@ -140,16 +129,20 @@ async function loader(source, callback) {
|
|
|
140
129
|
path: filePath
|
|
141
130
|
});
|
|
142
131
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
new Error(
|
|
147
|
-
formatError(`invalid frontmatter in ${filePath}:`, result.error)
|
|
148
|
-
)
|
|
132
|
+
if ("~standard" in schema) {
|
|
133
|
+
const result = await schema["~standard"].validate(
|
|
134
|
+
matter.data
|
|
149
135
|
);
|
|
150
|
-
|
|
136
|
+
if (result.issues) {
|
|
137
|
+
callback(
|
|
138
|
+
new Error(
|
|
139
|
+
formatError(`invalid frontmatter in ${filePath}:`, result.issues)
|
|
140
|
+
)
|
|
141
|
+
);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
matter.data = result.value;
|
|
151
145
|
}
|
|
152
|
-
matter.data = result.data;
|
|
153
146
|
}
|
|
154
147
|
let timestamp;
|
|
155
148
|
if (config.global?.lastModifiedTime === "git")
|