fumadocs-mdx 11.7.5 → 11.8.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-OWZSTKKX.js → chunk-6Y5JDZHD.js} +8 -1
- package/dist/{chunk-HWSF4OGZ.js → chunk-7JFPDRW7.js} +1 -1
- package/dist/{chunk-3XN4P23K.js → chunk-IGXZS2W6.js} +1 -1
- package/dist/{chunk-KVWX6THC.js → chunk-VWJKRQZR.js} +2 -2
- package/dist/config/index.cjs +2 -2
- package/dist/config/index.js +2 -2
- package/dist/config/zod-3.cjs +2 -2
- package/dist/config/zod-3.js +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/loader-mdx.cjs +2 -2
- package/dist/loader-mdx.js +5 -5
- package/dist/next/index.cjs +11 -4
- package/dist/next/index.js +3 -3
- package/dist/runtime/async.cjs +10 -9
- package/dist/runtime/async.d.cts +1 -1
- package/dist/runtime/async.d.ts +1 -1
- package/dist/runtime/async.js +11 -10
- package/dist/runtime/vite.cjs +49 -41
- package/dist/runtime/vite.d.cts +25 -17
- package/dist/runtime/vite.d.ts +25 -17
- package/dist/runtime/vite.js +49 -41
- package/dist/{types-CU9nn_je.d.ts → types-B2ozVm_9.d.ts} +9 -3
- package/dist/{types-C-WXTx1W.d.cts → types-BukvTPdG.d.cts} +9 -3
- package/dist/vite/index.cjs +74 -51
- package/dist/vite/index.d.cts +6 -1
- package/dist/vite/index.d.ts +6 -1
- package/dist/vite/index.js +50 -34
- package/package.json +10 -10
|
@@ -15,7 +15,14 @@ function getImportCode(info) {
|
|
|
15
15
|
}
|
|
16
16
|
function toImportPath(file, config) {
|
|
17
17
|
const ext = path.extname(file);
|
|
18
|
-
|
|
18
|
+
let filename;
|
|
19
|
+
if (ext === ".ts" && config.jsExtension) {
|
|
20
|
+
filename = file.substring(0, file.length - ext.length) + ".js";
|
|
21
|
+
} else if (ext === ".ts") {
|
|
22
|
+
filename = file.substring(0, file.length - ext.length);
|
|
23
|
+
} else {
|
|
24
|
+
filename = file;
|
|
25
|
+
}
|
|
19
26
|
let importPath;
|
|
20
27
|
if ("relativeTo" in config) {
|
|
21
28
|
importPath = path.relative(config.relativeTo, filename);
|
|
@@ -7,9 +7,9 @@ function fumaMatter(input) {
|
|
|
7
7
|
if (!match) {
|
|
8
8
|
return output;
|
|
9
9
|
}
|
|
10
|
-
output.matter = match[
|
|
10
|
+
output.matter = match[0];
|
|
11
11
|
output.content = input.slice(match[0].length);
|
|
12
|
-
const loaded = load(
|
|
12
|
+
const loaded = load(match[1]);
|
|
13
13
|
output.data = loaded ?? {};
|
|
14
14
|
return output;
|
|
15
15
|
}
|
package/dist/config/index.cjs
CHANGED
|
@@ -225,9 +225,9 @@ function fumaMatter(input) {
|
|
|
225
225
|
if (!match) {
|
|
226
226
|
return output;
|
|
227
227
|
}
|
|
228
|
-
output.matter = match[
|
|
228
|
+
output.matter = match[0];
|
|
229
229
|
output.content = input.slice(match[0].length);
|
|
230
|
-
const loaded = (0, import_js_yaml.load)(
|
|
230
|
+
const loaded = (0, import_js_yaml.load)(match[1]);
|
|
231
231
|
output.data = loaded ?? {};
|
|
232
232
|
return output;
|
|
233
233
|
}
|
package/dist/config/index.js
CHANGED
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
} from "../chunk-GYWPPGFD.js";
|
|
11
11
|
import {
|
|
12
12
|
remarkInclude
|
|
13
|
-
} from "../chunk-
|
|
14
|
-
import "../chunk-
|
|
13
|
+
} from "../chunk-IGXZS2W6.js";
|
|
14
|
+
import "../chunk-VWJKRQZR.js";
|
|
15
15
|
export {
|
|
16
16
|
defineCollections,
|
|
17
17
|
defineConfig,
|
package/dist/config/zod-3.cjs
CHANGED
|
@@ -226,9 +226,9 @@ function fumaMatter(input) {
|
|
|
226
226
|
if (!match) {
|
|
227
227
|
return output;
|
|
228
228
|
}
|
|
229
|
-
output.matter = match[
|
|
229
|
+
output.matter = match[0];
|
|
230
230
|
output.content = input.slice(match[0].length);
|
|
231
|
-
const loaded = (0, import_js_yaml.load)(
|
|
231
|
+
const loaded = (0, import_js_yaml.load)(match[1]);
|
|
232
232
|
output.data = loaded ?? {};
|
|
233
233
|
return output;
|
|
234
234
|
}
|
package/dist/config/zod-3.js
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
} from "../chunk-GYWPPGFD.js";
|
|
9
9
|
import {
|
|
10
10
|
remarkInclude
|
|
11
|
-
} from "../chunk-
|
|
12
|
-
import "../chunk-
|
|
11
|
+
} from "../chunk-IGXZS2W6.js";
|
|
12
|
+
import "../chunk-VWJKRQZR.js";
|
|
13
13
|
|
|
14
14
|
// src/config/zod-3.ts
|
|
15
15
|
import { z } from "zod/v3";
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
-
import { R as Runtime, B as BaseCollectionEntry } from './types-
|
|
2
|
+
import { R as Runtime, B as BaseCollectionEntry } from './types-BukvTPdG.cjs';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import './define-DnJzAZrj.cjs';
|
|
5
5
|
import 'fumadocs-core/mdx-plugins';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
-
import { R as Runtime, B as BaseCollectionEntry } from './types-
|
|
2
|
+
import { R as Runtime, B as BaseCollectionEntry } from './types-B2ozVm_9.js';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import './define-DnJzAZrj.js';
|
|
5
5
|
import 'fumadocs-core/mdx-plugins';
|
package/dist/loader-mdx.cjs
CHANGED
|
@@ -322,9 +322,9 @@ function fumaMatter(input) {
|
|
|
322
322
|
if (!match) {
|
|
323
323
|
return output;
|
|
324
324
|
}
|
|
325
|
-
output.matter = match[
|
|
325
|
+
output.matter = match[0];
|
|
326
326
|
output.content = input.slice(match[0].length);
|
|
327
|
-
const loaded = (0, import_js_yaml.load)(
|
|
327
|
+
const loaded = (0, import_js_yaml.load)(match[1]);
|
|
328
328
|
output.data = loaded ?? {};
|
|
329
329
|
return output;
|
|
330
330
|
}
|
package/dist/loader-mdx.js
CHANGED
|
@@ -5,19 +5,19 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
countLines
|
|
7
7
|
} from "./chunk-UCY7OBZG.js";
|
|
8
|
-
import {
|
|
9
|
-
buildMDX
|
|
10
|
-
} from "./chunk-HWSF4OGZ.js";
|
|
11
|
-
import "./chunk-3XN4P23K.js";
|
|
12
8
|
import {
|
|
13
9
|
ValidationError,
|
|
14
10
|
getGitTimestamp,
|
|
15
11
|
validate
|
|
16
12
|
} from "./chunk-GX3THK2Q.js";
|
|
13
|
+
import {
|
|
14
|
+
buildMDX
|
|
15
|
+
} from "./chunk-7JFPDRW7.js";
|
|
16
|
+
import "./chunk-IGXZS2W6.js";
|
|
17
17
|
import "./chunk-XVL4ZQFK.js";
|
|
18
18
|
import {
|
|
19
19
|
fumaMatter
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-VWJKRQZR.js";
|
|
21
21
|
|
|
22
22
|
// src/loader-mdx.ts
|
|
23
23
|
import * as path from "path";
|
package/dist/next/index.cjs
CHANGED
|
@@ -440,9 +440,9 @@ function fumaMatter(input) {
|
|
|
440
440
|
if (!match) {
|
|
441
441
|
return output;
|
|
442
442
|
}
|
|
443
|
-
output.matter = match[
|
|
443
|
+
output.matter = match[0];
|
|
444
444
|
output.content = input.slice(match[0].length);
|
|
445
|
-
const loaded = (0, import_js_yaml.load)(
|
|
445
|
+
const loaded = (0, import_js_yaml.load)(match[1]);
|
|
446
446
|
output.data = loaded ?? {};
|
|
447
447
|
return output;
|
|
448
448
|
}
|
|
@@ -464,7 +464,14 @@ function getImportCode(info) {
|
|
|
464
464
|
}
|
|
465
465
|
function toImportPath(file, config) {
|
|
466
466
|
const ext = import_node_path2.default.extname(file);
|
|
467
|
-
|
|
467
|
+
let filename;
|
|
468
|
+
if (ext === ".ts" && config.jsExtension) {
|
|
469
|
+
filename = file.substring(0, file.length - ext.length) + ".js";
|
|
470
|
+
} else if (ext === ".ts") {
|
|
471
|
+
filename = file.substring(0, file.length - ext.length);
|
|
472
|
+
} else {
|
|
473
|
+
filename = file;
|
|
474
|
+
}
|
|
468
475
|
let importPath;
|
|
469
476
|
if ("relativeTo" in config) {
|
|
470
477
|
importPath = import_node_path2.default.relative(config.relativeTo, filename);
|
|
@@ -589,7 +596,7 @@ async function generateJS(configPath, config, importPath, configHash = false) {
|
|
|
589
596
|
info: file,
|
|
590
597
|
lastModified,
|
|
591
598
|
data,
|
|
592
|
-
content: parsed.content
|
|
599
|
+
content: { body: parsed.content, matter: parsed.matter }
|
|
593
600
|
});
|
|
594
601
|
});
|
|
595
602
|
return Promise.all(entries2);
|
package/dist/next/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getImportCode,
|
|
9
9
|
isFileSupported,
|
|
10
10
|
toImportPath
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-6Y5JDZHD.js";
|
|
12
12
|
import {
|
|
13
13
|
ValidationError,
|
|
14
14
|
getGitTimestamp,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import "../chunk-XVL4ZQFK.js";
|
|
18
18
|
import {
|
|
19
19
|
fumaMatter
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-VWJKRQZR.js";
|
|
21
21
|
|
|
22
22
|
// src/map/index.ts
|
|
23
23
|
import * as path2 from "path";
|
|
@@ -143,7 +143,7 @@ async function generateJS(configPath, config, importPath, configHash = false) {
|
|
|
143
143
|
info: file,
|
|
144
144
|
lastModified,
|
|
145
145
|
data,
|
|
146
|
-
content: parsed.content
|
|
146
|
+
content: { body: parsed.content, matter: parsed.matter }
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
149
|
return Promise.all(entries2);
|
package/dist/runtime/async.cjs
CHANGED
|
@@ -264,9 +264,9 @@ function fumaMatter(input) {
|
|
|
264
264
|
if (!match) {
|
|
265
265
|
return output;
|
|
266
266
|
}
|
|
267
|
-
output.matter = match[
|
|
267
|
+
output.matter = match[0];
|
|
268
268
|
output.content = input.slice(match[0].length);
|
|
269
|
-
const loaded = (0, import_js_yaml.load)(
|
|
269
|
+
const loaded = (0, import_js_yaml.load)(match[1]);
|
|
270
270
|
output.data = loaded ?? {};
|
|
271
271
|
return output;
|
|
272
272
|
}
|
|
@@ -482,10 +482,12 @@ var _runtimeAsync = {
|
|
|
482
482
|
return {
|
|
483
483
|
...data,
|
|
484
484
|
_file: file,
|
|
485
|
-
content
|
|
485
|
+
get content() {
|
|
486
|
+
return `${content.matter}${content.body}`;
|
|
487
|
+
},
|
|
486
488
|
async load() {
|
|
487
489
|
const mdxOptions = await initMdxOptions;
|
|
488
|
-
const out = await buildMDX(collection, content, {
|
|
490
|
+
const out = await buildMDX(collection, content.body, {
|
|
489
491
|
...mdxOptions,
|
|
490
492
|
development: false,
|
|
491
493
|
frontmatter: data,
|
|
@@ -494,15 +496,14 @@ var _runtimeAsync = {
|
|
|
494
496
|
},
|
|
495
497
|
filePath: file.absolutePath
|
|
496
498
|
});
|
|
497
|
-
const
|
|
499
|
+
const { default: body, ...rest } = await (0, import_client.executeMdx)(String(out), {
|
|
498
500
|
baseUrl: (0, import_node_url.pathToFileURL)(file.absolutePath)
|
|
499
501
|
});
|
|
500
502
|
return {
|
|
501
|
-
body: executed.default,
|
|
502
|
-
toc: executed.toc,
|
|
503
|
-
lastModified,
|
|
504
503
|
structuredData: out.data.structuredData,
|
|
505
|
-
|
|
504
|
+
body,
|
|
505
|
+
...rest,
|
|
506
|
+
lastModified
|
|
506
507
|
};
|
|
507
508
|
}
|
|
508
509
|
};
|
package/dist/runtime/async.d.cts
CHANGED
package/dist/runtime/async.d.ts
CHANGED
package/dist/runtime/async.js
CHANGED
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
} from "../chunk-NUDEC6C5.js";
|
|
5
5
|
import {
|
|
6
6
|
buildMDX
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-7JFPDRW7.js";
|
|
8
|
+
import "../chunk-IGXZS2W6.js";
|
|
9
9
|
import {
|
|
10
10
|
buildConfig
|
|
11
11
|
} from "../chunk-XVL4ZQFK.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-VWJKRQZR.js";
|
|
13
13
|
|
|
14
14
|
// src/runtime/async.ts
|
|
15
15
|
import { executeMdx } from "@fumadocs/mdx-remote/client";
|
|
@@ -27,10 +27,12 @@ var _runtimeAsync = {
|
|
|
27
27
|
return {
|
|
28
28
|
...data,
|
|
29
29
|
_file: file,
|
|
30
|
-
content
|
|
30
|
+
get content() {
|
|
31
|
+
return `${content.matter}${content.body}`;
|
|
32
|
+
},
|
|
31
33
|
async load() {
|
|
32
34
|
const mdxOptions = await initMdxOptions;
|
|
33
|
-
const out = await buildMDX(collection, content, {
|
|
35
|
+
const out = await buildMDX(collection, content.body, {
|
|
34
36
|
...mdxOptions,
|
|
35
37
|
development: false,
|
|
36
38
|
frontmatter: data,
|
|
@@ -39,15 +41,14 @@ var _runtimeAsync = {
|
|
|
39
41
|
},
|
|
40
42
|
filePath: file.absolutePath
|
|
41
43
|
});
|
|
42
|
-
const
|
|
44
|
+
const { default: body, ...rest } = await executeMdx(String(out), {
|
|
43
45
|
baseUrl: pathToFileURL(file.absolutePath)
|
|
44
46
|
});
|
|
45
47
|
return {
|
|
46
|
-
body: executed.default,
|
|
47
|
-
toc: executed.toc,
|
|
48
|
-
lastModified,
|
|
49
48
|
structuredData: out.data.structuredData,
|
|
50
|
-
|
|
49
|
+
body,
|
|
50
|
+
...rest,
|
|
51
|
+
lastModified
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
54
|
};
|
package/dist/runtime/vite.cjs
CHANGED
|
@@ -40,12 +40,22 @@ function fromConfig() {
|
|
|
40
40
|
return {
|
|
41
41
|
...frontmatter,
|
|
42
42
|
default: entry.default,
|
|
43
|
+
body: entry.default,
|
|
43
44
|
toc,
|
|
44
45
|
structuredData,
|
|
45
46
|
lastModified,
|
|
46
47
|
_exports: entry
|
|
47
48
|
};
|
|
48
49
|
}
|
|
50
|
+
function mapPageDataLazy(head, content) {
|
|
51
|
+
return {
|
|
52
|
+
...head,
|
|
53
|
+
async load() {
|
|
54
|
+
const { default: body, ...rest } = await content();
|
|
55
|
+
return { body, ...rest };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
49
59
|
return {
|
|
50
60
|
doc(_, glob) {
|
|
51
61
|
return normalize(glob);
|
|
@@ -53,51 +63,49 @@ function fromConfig() {
|
|
|
53
63
|
meta(_, glob) {
|
|
54
64
|
return normalize(glob);
|
|
55
65
|
},
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
doc: normalize(doc),
|
|
59
|
-
meta: normalize(meta)
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
source(doc, meta) {
|
|
63
|
-
const virtualFiles = [];
|
|
64
|
-
for (const [file, content] of Object.entries(doc)) {
|
|
65
|
-
virtualFiles.push({
|
|
66
|
-
type: "page",
|
|
67
|
-
path: file,
|
|
68
|
-
data: mapPageData(content)
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
for (const [file, content] of Object.entries(meta)) {
|
|
72
|
-
virtualFiles.push({
|
|
73
|
-
type: "meta",
|
|
74
|
-
path: file,
|
|
75
|
-
data: content
|
|
76
|
-
});
|
|
77
|
-
}
|
|
66
|
+
docLazy(_, head, body) {
|
|
78
67
|
return {
|
|
79
|
-
|
|
68
|
+
head: normalize(head),
|
|
69
|
+
body: normalize(body)
|
|
80
70
|
};
|
|
81
71
|
},
|
|
82
72
|
async sourceAsync(doc, meta) {
|
|
83
|
-
const virtualFiles = [
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
73
|
+
const virtualFiles = [
|
|
74
|
+
...Object.entries(doc).map(async ([file, content]) => {
|
|
75
|
+
return {
|
|
76
|
+
type: "page",
|
|
77
|
+
path: file,
|
|
78
|
+
data: mapPageData(await content())
|
|
79
|
+
};
|
|
80
|
+
}),
|
|
81
|
+
...Object.entries(meta).map(async ([file, content]) => {
|
|
82
|
+
return {
|
|
83
|
+
type: "meta",
|
|
84
|
+
path: file,
|
|
85
|
+
data: await content()
|
|
86
|
+
};
|
|
87
|
+
})
|
|
88
|
+
];
|
|
89
|
+
return { files: await Promise.all(virtualFiles) };
|
|
90
|
+
},
|
|
91
|
+
async sourceLazy(doc, meta) {
|
|
92
|
+
const virtualFiles = [
|
|
93
|
+
...Object.entries(doc.head).map(async ([file, frontmatter]) => {
|
|
94
|
+
return {
|
|
95
|
+
type: "page",
|
|
96
|
+
path: file,
|
|
97
|
+
data: mapPageDataLazy(await frontmatter(), doc.body[file])
|
|
98
|
+
};
|
|
99
|
+
}),
|
|
100
|
+
...Object.entries(meta).map(async ([file, content]) => {
|
|
101
|
+
return {
|
|
102
|
+
type: "meta",
|
|
103
|
+
path: file,
|
|
104
|
+
data: await content()
|
|
105
|
+
};
|
|
106
|
+
})
|
|
107
|
+
];
|
|
108
|
+
return { files: await Promise.all(virtualFiles) };
|
|
101
109
|
}
|
|
102
110
|
};
|
|
103
111
|
}
|
package/dist/runtime/vite.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { TableOfContents } from 'fumadocs-core/server';
|
|
|
2
2
|
import { FC, ReactNode } from 'react';
|
|
3
3
|
import { MDXProps } from 'mdx/types';
|
|
4
4
|
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
5
|
-
import { a as DocCollection,
|
|
5
|
+
import { a as DocCollection, b as DocsCollection, M as MetaCollection } from '../define-DnJzAZrj.cjs';
|
|
6
6
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
7
7
|
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
8
8
|
import '@mdx-js/mdx';
|
|
@@ -20,28 +20,36 @@ interface CompiledMDXProperties<Frontmatter> {
|
|
|
20
20
|
lastModified?: Date;
|
|
21
21
|
}
|
|
22
22
|
type CompiledMDXFile<Frontmatter> = CompiledMDXProperties<Frontmatter> & Record<string, unknown>;
|
|
23
|
-
type
|
|
23
|
+
type Override<A, B> = Omit<A, keyof B> & B;
|
|
24
|
+
type MDXFileToPageData<Frontmatter> = Override<Omit<CompiledMDXProperties<Frontmatter>, 'frontmatter' | 'default'>, Frontmatter & {
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated use `body` instead.
|
|
27
|
+
*/
|
|
28
|
+
default: FC<MDXProps>;
|
|
24
29
|
_exports: Record<string, unknown>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
docs: <Name extends keyof Config, DocGlobValue, MetaGlobValue>(name: Name, options: {
|
|
31
|
-
meta: Record<string, MetaGlobValue>;
|
|
32
|
-
doc: Record<string, DocGlobValue>;
|
|
33
|
-
}) => Config[Name] extends DocsCollection<infer DocSchema, infer MetaSchema> ? {
|
|
34
|
-
doc: Record<string, AttachGlobValue<DocGlobValue, CompiledMDXFile<StandardSchemaV1.InferOutput<DocSchema>>>>;
|
|
35
|
-
meta: Record<string, AttachGlobValue<MetaGlobValue, StandardSchemaV1.InferOutput<MetaSchema>>>;
|
|
36
|
-
} : never;
|
|
37
|
-
source: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, CompiledMDXFile<DocOut>>, meta: Record<string, MetaOut>) => Source<{
|
|
38
|
-
pageData: MDXFileToPageData<DocOut>;
|
|
39
|
-
metaData: MetaOut;
|
|
30
|
+
body: FC<MDXProps>;
|
|
31
|
+
}>;
|
|
32
|
+
type MDXFileToPageDataLazy<Frontmatter> = Override<Frontmatter, {
|
|
33
|
+
load: () => Promise<Omit<CompiledMDXFile<Frontmatter>, 'default'> & {
|
|
34
|
+
body: FC<MDXProps>;
|
|
40
35
|
}>;
|
|
36
|
+
}>;
|
|
37
|
+
interface LazyDocMap<Frontmatter> {
|
|
38
|
+
head: Record<string, () => Promise<Frontmatter>>;
|
|
39
|
+
body: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>;
|
|
40
|
+
}
|
|
41
|
+
declare function fromConfig<Config>(): {
|
|
42
|
+
doc: <Name extends keyof Config>(name: Name, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? Record<string, () => Promise<CompiledMDXFile<StandardSchemaV1.InferOutput<Schema>>>> : never;
|
|
43
|
+
docLazy: <Name extends keyof Config>(name: Name, headGlob: Record<string, () => Promise<unknown>>, bodyGlob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? LazyDocMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
44
|
+
meta: <Name extends keyof Config>(name: Name, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends MetaCollection<infer Schema> | DocsCollection<StandardSchemaV1, infer Schema> ? Record<string, () => Promise<StandardSchemaV1.InferOutput<Schema>>> : never;
|
|
41
45
|
sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, () => Promise<CompiledMDXFile<DocOut>>>, meta: Record<string, () => Promise<MetaOut>>) => Promise<Source<{
|
|
42
46
|
pageData: MDXFileToPageData<DocOut>;
|
|
43
47
|
metaData: MetaOut;
|
|
44
48
|
}>>;
|
|
49
|
+
sourceLazy: <DocOut extends PageData, MetaOut extends MetaData>(doc: LazyDocMap<DocOut>, meta: Record<string, () => Promise<MetaOut>>) => Promise<Source<{
|
|
50
|
+
pageData: MDXFileToPageDataLazy<DocOut>;
|
|
51
|
+
metaData: MetaOut;
|
|
52
|
+
}>>;
|
|
45
53
|
};
|
|
46
54
|
interface ClientLoaderOptions<Frontmatter, Props> {
|
|
47
55
|
/**
|
package/dist/runtime/vite.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { TableOfContents } from 'fumadocs-core/server';
|
|
|
2
2
|
import { FC, ReactNode } from 'react';
|
|
3
3
|
import { MDXProps } from 'mdx/types';
|
|
4
4
|
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
5
|
-
import { a as DocCollection,
|
|
5
|
+
import { a as DocCollection, b as DocsCollection, M as MetaCollection } from '../define-DnJzAZrj.js';
|
|
6
6
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
7
7
|
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
8
8
|
import '@mdx-js/mdx';
|
|
@@ -20,28 +20,36 @@ interface CompiledMDXProperties<Frontmatter> {
|
|
|
20
20
|
lastModified?: Date;
|
|
21
21
|
}
|
|
22
22
|
type CompiledMDXFile<Frontmatter> = CompiledMDXProperties<Frontmatter> & Record<string, unknown>;
|
|
23
|
-
type
|
|
23
|
+
type Override<A, B> = Omit<A, keyof B> & B;
|
|
24
|
+
type MDXFileToPageData<Frontmatter> = Override<Omit<CompiledMDXProperties<Frontmatter>, 'frontmatter' | 'default'>, Frontmatter & {
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated use `body` instead.
|
|
27
|
+
*/
|
|
28
|
+
default: FC<MDXProps>;
|
|
24
29
|
_exports: Record<string, unknown>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
docs: <Name extends keyof Config, DocGlobValue, MetaGlobValue>(name: Name, options: {
|
|
31
|
-
meta: Record<string, MetaGlobValue>;
|
|
32
|
-
doc: Record<string, DocGlobValue>;
|
|
33
|
-
}) => Config[Name] extends DocsCollection<infer DocSchema, infer MetaSchema> ? {
|
|
34
|
-
doc: Record<string, AttachGlobValue<DocGlobValue, CompiledMDXFile<StandardSchemaV1.InferOutput<DocSchema>>>>;
|
|
35
|
-
meta: Record<string, AttachGlobValue<MetaGlobValue, StandardSchemaV1.InferOutput<MetaSchema>>>;
|
|
36
|
-
} : never;
|
|
37
|
-
source: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, CompiledMDXFile<DocOut>>, meta: Record<string, MetaOut>) => Source<{
|
|
38
|
-
pageData: MDXFileToPageData<DocOut>;
|
|
39
|
-
metaData: MetaOut;
|
|
30
|
+
body: FC<MDXProps>;
|
|
31
|
+
}>;
|
|
32
|
+
type MDXFileToPageDataLazy<Frontmatter> = Override<Frontmatter, {
|
|
33
|
+
load: () => Promise<Omit<CompiledMDXFile<Frontmatter>, 'default'> & {
|
|
34
|
+
body: FC<MDXProps>;
|
|
40
35
|
}>;
|
|
36
|
+
}>;
|
|
37
|
+
interface LazyDocMap<Frontmatter> {
|
|
38
|
+
head: Record<string, () => Promise<Frontmatter>>;
|
|
39
|
+
body: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>;
|
|
40
|
+
}
|
|
41
|
+
declare function fromConfig<Config>(): {
|
|
42
|
+
doc: <Name extends keyof Config>(name: Name, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? Record<string, () => Promise<CompiledMDXFile<StandardSchemaV1.InferOutput<Schema>>>> : never;
|
|
43
|
+
docLazy: <Name extends keyof Config>(name: Name, headGlob: Record<string, () => Promise<unknown>>, bodyGlob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? LazyDocMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
44
|
+
meta: <Name extends keyof Config>(name: Name, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends MetaCollection<infer Schema> | DocsCollection<StandardSchemaV1, infer Schema> ? Record<string, () => Promise<StandardSchemaV1.InferOutput<Schema>>> : never;
|
|
41
45
|
sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, () => Promise<CompiledMDXFile<DocOut>>>, meta: Record<string, () => Promise<MetaOut>>) => Promise<Source<{
|
|
42
46
|
pageData: MDXFileToPageData<DocOut>;
|
|
43
47
|
metaData: MetaOut;
|
|
44
48
|
}>>;
|
|
49
|
+
sourceLazy: <DocOut extends PageData, MetaOut extends MetaData>(doc: LazyDocMap<DocOut>, meta: Record<string, () => Promise<MetaOut>>) => Promise<Source<{
|
|
50
|
+
pageData: MDXFileToPageDataLazy<DocOut>;
|
|
51
|
+
metaData: MetaOut;
|
|
52
|
+
}>>;
|
|
45
53
|
};
|
|
46
54
|
interface ClientLoaderOptions<Frontmatter, Props> {
|
|
47
55
|
/**
|
package/dist/runtime/vite.js
CHANGED
|
@@ -14,12 +14,22 @@ function fromConfig() {
|
|
|
14
14
|
return {
|
|
15
15
|
...frontmatter,
|
|
16
16
|
default: entry.default,
|
|
17
|
+
body: entry.default,
|
|
17
18
|
toc,
|
|
18
19
|
structuredData,
|
|
19
20
|
lastModified,
|
|
20
21
|
_exports: entry
|
|
21
22
|
};
|
|
22
23
|
}
|
|
24
|
+
function mapPageDataLazy(head, content) {
|
|
25
|
+
return {
|
|
26
|
+
...head,
|
|
27
|
+
async load() {
|
|
28
|
+
const { default: body, ...rest } = await content();
|
|
29
|
+
return { body, ...rest };
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
23
33
|
return {
|
|
24
34
|
doc(_, glob) {
|
|
25
35
|
return normalize(glob);
|
|
@@ -27,51 +37,49 @@ function fromConfig() {
|
|
|
27
37
|
meta(_, glob) {
|
|
28
38
|
return normalize(glob);
|
|
29
39
|
},
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
doc: normalize(doc),
|
|
33
|
-
meta: normalize(meta)
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
source(doc, meta) {
|
|
37
|
-
const virtualFiles = [];
|
|
38
|
-
for (const [file, content] of Object.entries(doc)) {
|
|
39
|
-
virtualFiles.push({
|
|
40
|
-
type: "page",
|
|
41
|
-
path: file,
|
|
42
|
-
data: mapPageData(content)
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
for (const [file, content] of Object.entries(meta)) {
|
|
46
|
-
virtualFiles.push({
|
|
47
|
-
type: "meta",
|
|
48
|
-
path: file,
|
|
49
|
-
data: content
|
|
50
|
-
});
|
|
51
|
-
}
|
|
40
|
+
docLazy(_, head, body) {
|
|
52
41
|
return {
|
|
53
|
-
|
|
42
|
+
head: normalize(head),
|
|
43
|
+
body: normalize(body)
|
|
54
44
|
};
|
|
55
45
|
},
|
|
56
46
|
async sourceAsync(doc, meta) {
|
|
57
|
-
const virtualFiles = [
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
47
|
+
const virtualFiles = [
|
|
48
|
+
...Object.entries(doc).map(async ([file, content]) => {
|
|
49
|
+
return {
|
|
50
|
+
type: "page",
|
|
51
|
+
path: file,
|
|
52
|
+
data: mapPageData(await content())
|
|
53
|
+
};
|
|
54
|
+
}),
|
|
55
|
+
...Object.entries(meta).map(async ([file, content]) => {
|
|
56
|
+
return {
|
|
57
|
+
type: "meta",
|
|
58
|
+
path: file,
|
|
59
|
+
data: await content()
|
|
60
|
+
};
|
|
61
|
+
})
|
|
62
|
+
];
|
|
63
|
+
return { files: await Promise.all(virtualFiles) };
|
|
64
|
+
},
|
|
65
|
+
async sourceLazy(doc, meta) {
|
|
66
|
+
const virtualFiles = [
|
|
67
|
+
...Object.entries(doc.head).map(async ([file, frontmatter]) => {
|
|
68
|
+
return {
|
|
69
|
+
type: "page",
|
|
70
|
+
path: file,
|
|
71
|
+
data: mapPageDataLazy(await frontmatter(), doc.body[file])
|
|
72
|
+
};
|
|
73
|
+
}),
|
|
74
|
+
...Object.entries(meta).map(async ([file, content]) => {
|
|
75
|
+
return {
|
|
76
|
+
type: "meta",
|
|
77
|
+
path: file,
|
|
78
|
+
data: await content()
|
|
79
|
+
};
|
|
80
|
+
})
|
|
81
|
+
];
|
|
82
|
+
return { files: await Promise.all(virtualFiles) };
|
|
75
83
|
}
|
|
76
84
|
};
|
|
77
85
|
}
|
|
@@ -27,7 +27,6 @@ interface MarkdownProps {
|
|
|
27
27
|
body: FC<MDXProps>;
|
|
28
28
|
structuredData: StructuredData;
|
|
29
29
|
toc: TableOfContents;
|
|
30
|
-
_exports: Record<string, unknown>;
|
|
31
30
|
/**
|
|
32
31
|
* Only available when `lastModifiedTime` is enabled on MDX loader
|
|
33
32
|
*/
|
|
@@ -40,10 +39,17 @@ interface RuntimeFile {
|
|
|
40
39
|
interface AsyncRuntimeFile {
|
|
41
40
|
info: FileInfo;
|
|
42
41
|
data: Record<string, unknown>;
|
|
43
|
-
content:
|
|
42
|
+
content: {
|
|
43
|
+
matter: string;
|
|
44
|
+
body: string;
|
|
45
|
+
};
|
|
44
46
|
lastModified?: Date;
|
|
45
47
|
}
|
|
46
48
|
type DocOut<Schema extends StandardSchemaV1> = Override<MarkdownProps & {
|
|
49
|
+
/**
|
|
50
|
+
* Other exports in the compiled Markdown/MDX file
|
|
51
|
+
*/
|
|
52
|
+
_exports: Record<string, unknown>;
|
|
47
53
|
/**
|
|
48
54
|
* Read the original content of file from file system.
|
|
49
55
|
*/
|
|
@@ -65,7 +71,7 @@ interface Runtime {
|
|
|
65
71
|
}
|
|
66
72
|
type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
|
|
67
73
|
content: string;
|
|
68
|
-
load: () => Promise<MarkdownProps
|
|
74
|
+
load: () => Promise<MarkdownProps & Record<string, unknown>>;
|
|
69
75
|
};
|
|
70
76
|
interface RuntimeAsync {
|
|
71
77
|
doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends DocCollection<infer Schema, true> ? AsyncDocOut<Schema>[] : never;
|
|
@@ -27,7 +27,6 @@ interface MarkdownProps {
|
|
|
27
27
|
body: FC<MDXProps>;
|
|
28
28
|
structuredData: StructuredData;
|
|
29
29
|
toc: TableOfContents;
|
|
30
|
-
_exports: Record<string, unknown>;
|
|
31
30
|
/**
|
|
32
31
|
* Only available when `lastModifiedTime` is enabled on MDX loader
|
|
33
32
|
*/
|
|
@@ -40,10 +39,17 @@ interface RuntimeFile {
|
|
|
40
39
|
interface AsyncRuntimeFile {
|
|
41
40
|
info: FileInfo;
|
|
42
41
|
data: Record<string, unknown>;
|
|
43
|
-
content:
|
|
42
|
+
content: {
|
|
43
|
+
matter: string;
|
|
44
|
+
body: string;
|
|
45
|
+
};
|
|
44
46
|
lastModified?: Date;
|
|
45
47
|
}
|
|
46
48
|
type DocOut<Schema extends StandardSchemaV1> = Override<MarkdownProps & {
|
|
49
|
+
/**
|
|
50
|
+
* Other exports in the compiled Markdown/MDX file
|
|
51
|
+
*/
|
|
52
|
+
_exports: Record<string, unknown>;
|
|
47
53
|
/**
|
|
48
54
|
* Read the original content of file from file system.
|
|
49
55
|
*/
|
|
@@ -65,7 +71,7 @@ interface Runtime {
|
|
|
65
71
|
}
|
|
66
72
|
type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
|
|
67
73
|
content: string;
|
|
68
|
-
load: () => Promise<MarkdownProps
|
|
74
|
+
load: () => Promise<MarkdownProps & Record<string, unknown>>;
|
|
69
75
|
};
|
|
70
76
|
interface RuntimeAsync {
|
|
71
77
|
doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends DocCollection<infer Schema, true> ? AsyncDocOut<Schema>[] : never;
|
package/dist/vite/index.cjs
CHANGED
|
@@ -240,9 +240,9 @@ function fumaMatter(input) {
|
|
|
240
240
|
if (!match) {
|
|
241
241
|
return output;
|
|
242
242
|
}
|
|
243
|
-
output.matter = match[
|
|
243
|
+
output.matter = match[0];
|
|
244
244
|
output.content = input.slice(match[0].length);
|
|
245
|
-
const loaded = (0, import_js_yaml.load)(
|
|
245
|
+
const loaded = (0, import_js_yaml.load)(match[1]);
|
|
246
246
|
output.data = loaded ?? {};
|
|
247
247
|
return output;
|
|
248
248
|
}
|
|
@@ -447,7 +447,14 @@ var import_zod = require("zod");
|
|
|
447
447
|
var import_node_path = __toESM(require("path"), 1);
|
|
448
448
|
function toImportPath(file, config) {
|
|
449
449
|
const ext = import_node_path.default.extname(file);
|
|
450
|
-
|
|
450
|
+
let filename;
|
|
451
|
+
if (ext === ".ts" && config.jsExtension) {
|
|
452
|
+
filename = file.substring(0, file.length - ext.length) + ".js";
|
|
453
|
+
} else if (ext === ".ts") {
|
|
454
|
+
filename = file.substring(0, file.length - ext.length);
|
|
455
|
+
} else {
|
|
456
|
+
filename = file;
|
|
457
|
+
}
|
|
451
458
|
let importPath;
|
|
452
459
|
if ("relativeTo" in config) {
|
|
453
460
|
importPath = import_node_path.default.relative(config.relativeTo, filename);
|
|
@@ -468,6 +475,29 @@ var fs2 = __toESM(require("fs/promises"), 1);
|
|
|
468
475
|
var path4 = __toESM(require("path"), 1);
|
|
469
476
|
var import_js_yaml2 = require("js-yaml");
|
|
470
477
|
|
|
478
|
+
// src/utils/git-timestamp.ts
|
|
479
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
480
|
+
var import_tinyexec = require("tinyexec");
|
|
481
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
482
|
+
async function getGitTimestamp(file) {
|
|
483
|
+
const cached = cache2.get(file);
|
|
484
|
+
if (cached) return cached;
|
|
485
|
+
try {
|
|
486
|
+
const out = await (0, import_tinyexec.x)(
|
|
487
|
+
"git",
|
|
488
|
+
["log", "-1", '--pretty="%ai"', import_node_path2.default.relative(process.cwd(), file)],
|
|
489
|
+
{
|
|
490
|
+
throwOnError: true
|
|
491
|
+
}
|
|
492
|
+
);
|
|
493
|
+
const time = new Date(out.stdout);
|
|
494
|
+
cache2.set(file, time);
|
|
495
|
+
return time;
|
|
496
|
+
} catch {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
471
501
|
// src/utils/collections.ts
|
|
472
502
|
function getSupportedFormats(collection) {
|
|
473
503
|
return {
|
|
@@ -481,17 +511,16 @@ function getGlobPatterns(collection) {
|
|
|
481
511
|
}
|
|
482
512
|
|
|
483
513
|
// src/vite/generate-glob.ts
|
|
484
|
-
function generateGlob(name, collection) {
|
|
514
|
+
function generateGlob(name, collection, globOptions) {
|
|
485
515
|
const patterns = mapGlobPatterns(getGlobPatterns(collection));
|
|
486
516
|
const options = {
|
|
517
|
+
...globOptions,
|
|
487
518
|
query: {
|
|
519
|
+
...globOptions?.query,
|
|
488
520
|
collection: name
|
|
489
521
|
},
|
|
490
522
|
base: getGlobBase(collection)
|
|
491
523
|
};
|
|
492
|
-
if (collection.type === "meta") {
|
|
493
|
-
options.import = "default";
|
|
494
|
-
}
|
|
495
524
|
return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(options, null, 2)})`;
|
|
496
525
|
}
|
|
497
526
|
function mapGlobPatterns(patterns) {
|
|
@@ -516,31 +545,38 @@ function getGlobBase(collection) {
|
|
|
516
545
|
return dir;
|
|
517
546
|
}
|
|
518
547
|
|
|
519
|
-
// src/
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
} catch {
|
|
538
|
-
return;
|
|
548
|
+
// src/vite/generate.ts
|
|
549
|
+
function docs(name, collection) {
|
|
550
|
+
const obj = [
|
|
551
|
+
ident(`doc: ${doc(name, collection.docs)}`),
|
|
552
|
+
ident(`meta: ${meta(name, collection.meta)}`)
|
|
553
|
+
].join(",\n");
|
|
554
|
+
return `{
|
|
555
|
+
${obj}
|
|
556
|
+
}`;
|
|
557
|
+
}
|
|
558
|
+
function doc(name, collection) {
|
|
559
|
+
if (collection.async) {
|
|
560
|
+
return `create.docLazy("${name}", ${generateGlob(name, collection, {
|
|
561
|
+
query: {
|
|
562
|
+
only: "frontmatter"
|
|
563
|
+
},
|
|
564
|
+
import: "frontmatter"
|
|
565
|
+
})}, ${generateGlob(name, collection)})`;
|
|
539
566
|
}
|
|
567
|
+
return `create.doc("${name}", ${generateGlob(name, collection)})`;
|
|
568
|
+
}
|
|
569
|
+
function meta(name, collection) {
|
|
570
|
+
return `create.meta("${name}", ${generateGlob(name, collection, {
|
|
571
|
+
import: "default"
|
|
572
|
+
})})`;
|
|
540
573
|
}
|
|
541
574
|
|
|
542
575
|
// src/vite/index.ts
|
|
543
|
-
var
|
|
576
|
+
var querySchema = import_zod.z.object({
|
|
577
|
+
only: import_zod.z.literal(["frontmatter", "all"]).default("all"),
|
|
578
|
+
collection: import_zod.z.string().optional()
|
|
579
|
+
}).loose();
|
|
544
580
|
function mdx(config, options = {}) {
|
|
545
581
|
const { generateIndexFile = true, configPath = "source.config.ts" } = options;
|
|
546
582
|
const loaded = buildConfig(config);
|
|
@@ -579,9 +615,8 @@ function mdx(config, options = {}) {
|
|
|
579
615
|
async function transformContent(file, query, value) {
|
|
580
616
|
const matter = fumaMatter(value);
|
|
581
617
|
const isDevelopment = this.environment.mode === "dev";
|
|
582
|
-
const parsed = (0, import_node_querystring.parse)(query);
|
|
618
|
+
const parsed = querySchema.parse((0, import_node_querystring.parse)(query));
|
|
583
619
|
const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
|
|
584
|
-
const only = parsed.only ? onlySchema.parse(parsed.only) : "all";
|
|
585
620
|
let schema;
|
|
586
621
|
let mdxOptions;
|
|
587
622
|
switch (collection?.type) {
|
|
@@ -605,7 +640,7 @@ function mdx(config, options = {}) {
|
|
|
605
640
|
`invalid frontmatter in ${file}`
|
|
606
641
|
);
|
|
607
642
|
}
|
|
608
|
-
if (only === "frontmatter") {
|
|
643
|
+
if (parsed.only === "frontmatter") {
|
|
609
644
|
return {
|
|
610
645
|
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
611
646
|
map: null
|
|
@@ -651,35 +686,23 @@ function mdx(config, options = {}) {
|
|
|
651
686
|
'/// <reference types="vite/client" />',
|
|
652
687
|
`import { fromConfig } from 'fumadocs-mdx/runtime/vite';`,
|
|
653
688
|
`import type * as Config from '${toImportPath(configPath, {
|
|
654
|
-
relativeTo: outdir
|
|
689
|
+
relativeTo: outdir,
|
|
690
|
+
jsExtension: typeof generateIndexFile === "object" ? generateIndexFile.addJsExtension : void 0
|
|
655
691
|
})}';`,
|
|
656
692
|
"",
|
|
657
693
|
`export const create = fromConfig<typeof Config>();`
|
|
658
694
|
];
|
|
659
|
-
function docs(name, collection) {
|
|
660
|
-
const args = [
|
|
661
|
-
ident(`doc: ${generateGlob(name, collection.docs)}`),
|
|
662
|
-
ident(`meta: ${generateGlob(name, collection.meta)}`)
|
|
663
|
-
].join(",\n");
|
|
664
|
-
return `export const ${name} = create.docs("${name}", {
|
|
665
|
-
${args}
|
|
666
|
-
});`;
|
|
667
|
-
}
|
|
668
|
-
function doc(name, collection) {
|
|
669
|
-
return `export const ${name} = create.doc("${name}", ${generateGlob(name, collection)});`;
|
|
670
|
-
}
|
|
671
|
-
function meta(name, collection) {
|
|
672
|
-
return `export const ${name} = create.meta("${name}", ${generateGlob(name, collection)});`;
|
|
673
|
-
}
|
|
674
695
|
for (const [name, collection] of loaded.collections.entries()) {
|
|
675
|
-
|
|
696
|
+
let body;
|
|
676
697
|
if (collection.type === "docs") {
|
|
677
|
-
|
|
698
|
+
body = docs(name, collection);
|
|
678
699
|
} else if (collection.type === "meta") {
|
|
679
|
-
|
|
700
|
+
body = meta(name, collection);
|
|
680
701
|
} else {
|
|
681
|
-
|
|
702
|
+
body = doc(name, collection);
|
|
682
703
|
}
|
|
704
|
+
lines.push("");
|
|
705
|
+
lines.push(`export const ${name} = ${body};`);
|
|
683
706
|
}
|
|
684
707
|
await fs2.writeFile(path4.join(outdir, outFile), lines.join("\n"));
|
|
685
708
|
},
|
package/dist/vite/index.d.cts
CHANGED
|
@@ -6,7 +6,12 @@ interface PluginOptions {
|
|
|
6
6
|
*
|
|
7
7
|
* @defaultValue true
|
|
8
8
|
*/
|
|
9
|
-
generateIndexFile?: boolean
|
|
9
|
+
generateIndexFile?: boolean | {
|
|
10
|
+
/**
|
|
11
|
+
* add `.js` extensions to imports, needed for ESM without bundler resolution
|
|
12
|
+
*/
|
|
13
|
+
addJsExtension?: boolean;
|
|
14
|
+
};
|
|
10
15
|
/**
|
|
11
16
|
* @defaultValue source.config.ts
|
|
12
17
|
*/
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -6,7 +6,12 @@ interface PluginOptions {
|
|
|
6
6
|
*
|
|
7
7
|
* @defaultValue true
|
|
8
8
|
*/
|
|
9
|
-
generateIndexFile?: boolean
|
|
9
|
+
generateIndexFile?: boolean | {
|
|
10
|
+
/**
|
|
11
|
+
* add `.js` extensions to imports, needed for ESM without bundler resolution
|
|
12
|
+
*/
|
|
13
|
+
addJsExtension?: boolean;
|
|
14
|
+
};
|
|
10
15
|
/**
|
|
11
16
|
* @defaultValue source.config.ts
|
|
12
17
|
*/
|
package/dist/vite/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
countLines
|
|
3
3
|
} from "../chunk-UCY7OBZG.js";
|
|
4
|
-
import {
|
|
5
|
-
buildMDX
|
|
6
|
-
} from "../chunk-HWSF4OGZ.js";
|
|
7
|
-
import "../chunk-3XN4P23K.js";
|
|
8
4
|
import {
|
|
9
5
|
getGlobPatterns,
|
|
10
6
|
ident,
|
|
11
7
|
toImportPath
|
|
12
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-6Y5JDZHD.js";
|
|
13
9
|
import {
|
|
14
10
|
ValidationError,
|
|
15
11
|
getGitTimestamp,
|
|
16
12
|
validate
|
|
17
13
|
} from "../chunk-GX3THK2Q.js";
|
|
14
|
+
import {
|
|
15
|
+
buildMDX
|
|
16
|
+
} from "../chunk-7JFPDRW7.js";
|
|
17
|
+
import "../chunk-IGXZS2W6.js";
|
|
18
18
|
import {
|
|
19
19
|
buildConfig
|
|
20
20
|
} from "../chunk-XVL4ZQFK.js";
|
|
21
21
|
import {
|
|
22
22
|
fumaMatter
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-VWJKRQZR.js";
|
|
24
24
|
|
|
25
25
|
// src/vite/index.ts
|
|
26
26
|
import { parse } from "querystring";
|
|
@@ -30,17 +30,16 @@ import * as path from "path";
|
|
|
30
30
|
import { load } from "js-yaml";
|
|
31
31
|
|
|
32
32
|
// src/vite/generate-glob.ts
|
|
33
|
-
function generateGlob(name, collection) {
|
|
33
|
+
function generateGlob(name, collection, globOptions) {
|
|
34
34
|
const patterns = mapGlobPatterns(getGlobPatterns(collection));
|
|
35
35
|
const options = {
|
|
36
|
+
...globOptions,
|
|
36
37
|
query: {
|
|
38
|
+
...globOptions?.query,
|
|
37
39
|
collection: name
|
|
38
40
|
},
|
|
39
41
|
base: getGlobBase(collection)
|
|
40
42
|
};
|
|
41
|
-
if (collection.type === "meta") {
|
|
42
|
-
options.import = "default";
|
|
43
|
-
}
|
|
44
43
|
return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(options, null, 2)})`;
|
|
45
44
|
}
|
|
46
45
|
function mapGlobPatterns(patterns) {
|
|
@@ -65,8 +64,38 @@ function getGlobBase(collection) {
|
|
|
65
64
|
return dir;
|
|
66
65
|
}
|
|
67
66
|
|
|
67
|
+
// src/vite/generate.ts
|
|
68
|
+
function docs(name, collection) {
|
|
69
|
+
const obj = [
|
|
70
|
+
ident(`doc: ${doc(name, collection.docs)}`),
|
|
71
|
+
ident(`meta: ${meta(name, collection.meta)}`)
|
|
72
|
+
].join(",\n");
|
|
73
|
+
return `{
|
|
74
|
+
${obj}
|
|
75
|
+
}`;
|
|
76
|
+
}
|
|
77
|
+
function doc(name, collection) {
|
|
78
|
+
if (collection.async) {
|
|
79
|
+
return `create.docLazy("${name}", ${generateGlob(name, collection, {
|
|
80
|
+
query: {
|
|
81
|
+
only: "frontmatter"
|
|
82
|
+
},
|
|
83
|
+
import: "frontmatter"
|
|
84
|
+
})}, ${generateGlob(name, collection)})`;
|
|
85
|
+
}
|
|
86
|
+
return `create.doc("${name}", ${generateGlob(name, collection)})`;
|
|
87
|
+
}
|
|
88
|
+
function meta(name, collection) {
|
|
89
|
+
return `create.meta("${name}", ${generateGlob(name, collection, {
|
|
90
|
+
import: "default"
|
|
91
|
+
})})`;
|
|
92
|
+
}
|
|
93
|
+
|
|
68
94
|
// src/vite/index.ts
|
|
69
|
-
var
|
|
95
|
+
var querySchema = z.object({
|
|
96
|
+
only: z.literal(["frontmatter", "all"]).default("all"),
|
|
97
|
+
collection: z.string().optional()
|
|
98
|
+
}).loose();
|
|
70
99
|
function mdx(config, options = {}) {
|
|
71
100
|
const { generateIndexFile = true, configPath = "source.config.ts" } = options;
|
|
72
101
|
const loaded = buildConfig(config);
|
|
@@ -105,9 +134,8 @@ function mdx(config, options = {}) {
|
|
|
105
134
|
async function transformContent(file, query, value) {
|
|
106
135
|
const matter = fumaMatter(value);
|
|
107
136
|
const isDevelopment = this.environment.mode === "dev";
|
|
108
|
-
const parsed = parse(query);
|
|
137
|
+
const parsed = querySchema.parse(parse(query));
|
|
109
138
|
const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
|
|
110
|
-
const only = parsed.only ? onlySchema.parse(parsed.only) : "all";
|
|
111
139
|
let schema;
|
|
112
140
|
let mdxOptions;
|
|
113
141
|
switch (collection?.type) {
|
|
@@ -131,7 +159,7 @@ function mdx(config, options = {}) {
|
|
|
131
159
|
`invalid frontmatter in ${file}`
|
|
132
160
|
);
|
|
133
161
|
}
|
|
134
|
-
if (only === "frontmatter") {
|
|
162
|
+
if (parsed.only === "frontmatter") {
|
|
135
163
|
return {
|
|
136
164
|
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
137
165
|
map: null
|
|
@@ -177,35 +205,23 @@ function mdx(config, options = {}) {
|
|
|
177
205
|
'/// <reference types="vite/client" />',
|
|
178
206
|
`import { fromConfig } from 'fumadocs-mdx/runtime/vite';`,
|
|
179
207
|
`import type * as Config from '${toImportPath(configPath, {
|
|
180
|
-
relativeTo: outdir
|
|
208
|
+
relativeTo: outdir,
|
|
209
|
+
jsExtension: typeof generateIndexFile === "object" ? generateIndexFile.addJsExtension : void 0
|
|
181
210
|
})}';`,
|
|
182
211
|
"",
|
|
183
212
|
`export const create = fromConfig<typeof Config>();`
|
|
184
213
|
];
|
|
185
|
-
function docs(name, collection) {
|
|
186
|
-
const args = [
|
|
187
|
-
ident(`doc: ${generateGlob(name, collection.docs)}`),
|
|
188
|
-
ident(`meta: ${generateGlob(name, collection.meta)}`)
|
|
189
|
-
].join(",\n");
|
|
190
|
-
return `export const ${name} = create.docs("${name}", {
|
|
191
|
-
${args}
|
|
192
|
-
});`;
|
|
193
|
-
}
|
|
194
|
-
function doc(name, collection) {
|
|
195
|
-
return `export const ${name} = create.doc("${name}", ${generateGlob(name, collection)});`;
|
|
196
|
-
}
|
|
197
|
-
function meta(name, collection) {
|
|
198
|
-
return `export const ${name} = create.meta("${name}", ${generateGlob(name, collection)});`;
|
|
199
|
-
}
|
|
200
214
|
for (const [name, collection] of loaded.collections.entries()) {
|
|
201
|
-
|
|
215
|
+
let body;
|
|
202
216
|
if (collection.type === "docs") {
|
|
203
|
-
|
|
217
|
+
body = docs(name, collection);
|
|
204
218
|
} else if (collection.type === "meta") {
|
|
205
|
-
|
|
219
|
+
body = meta(name, collection);
|
|
206
220
|
} else {
|
|
207
|
-
|
|
221
|
+
body = doc(name, collection);
|
|
208
222
|
}
|
|
223
|
+
lines.push("");
|
|
224
|
+
lines.push(`export const ${name} = ${body};`);
|
|
209
225
|
}
|
|
210
226
|
await fs.writeFile(path.join(outdir, outFile), lines.join("\n"));
|
|
211
227
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.8.0",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@mdx-js/mdx": "^3.1.0",
|
|
60
60
|
"@standard-schema/spec": "^1.0.0",
|
|
61
61
|
"chokidar": "^4.0.3",
|
|
62
|
-
"esbuild": "^0.25.
|
|
62
|
+
"esbuild": "^0.25.9",
|
|
63
63
|
"estree-util-value-to-estree": "^3.4.0",
|
|
64
64
|
"js-yaml": "^4.1.0",
|
|
65
65
|
"lru-cache": "^11.1.0",
|
|
@@ -73,19 +73,19 @@
|
|
|
73
73
|
"@types/js-yaml": "^4.0.9",
|
|
74
74
|
"@types/mdast": "^4.0.3",
|
|
75
75
|
"@types/mdx": "^2.0.13",
|
|
76
|
-
"@types/node": "^24.
|
|
77
|
-
"@types/react": "^19.1.
|
|
76
|
+
"@types/node": "^24.3.0",
|
|
77
|
+
"@types/react": "^19.1.10",
|
|
78
78
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
79
|
-
"next": "^15.
|
|
79
|
+
"next": "^15.5.0",
|
|
80
80
|
"react": "^19.1.1",
|
|
81
|
-
"rollup": "^4.46.
|
|
81
|
+
"rollup": "^4.46.3",
|
|
82
82
|
"unified": "^11.0.5",
|
|
83
83
|
"vfile": "^6.0.3",
|
|
84
|
-
"vite": "^7.1.
|
|
85
|
-
"webpack": "^5.101.
|
|
86
|
-
"fumadocs-core": "15.6.10",
|
|
87
|
-
"eslint-config-custom": "0.0.0",
|
|
84
|
+
"vite": "^7.1.3",
|
|
85
|
+
"webpack": "^5.101.3",
|
|
88
86
|
"@fumadocs/mdx-remote": "1.4.0",
|
|
87
|
+
"eslint-config-custom": "0.0.0",
|
|
88
|
+
"fumadocs-core": "15.7.0",
|
|
89
89
|
"tsconfig": "0.0.0"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|