fumadocs-mdx 11.10.1 → 12.0.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/bin.cjs +29 -139
- package/dist/bin.js +1 -1
- package/dist/{browser-B2G8uAF2.d.cts → browser-D5lvL8vv.d.ts} +51 -4
- package/dist/{browser-DrH7tKRi.d.ts → browser-DjWADqp8.d.cts} +51 -4
- package/dist/bun/index.cjs +126 -108
- package/dist/bun/index.js +5 -5
- package/dist/chunk-3M4SHY6K.js +80 -0
- package/dist/{chunk-UOOPSLFY.js → chunk-AUOOMFAI.js} +27 -21
- package/dist/{chunk-QJCCVMBJ.js → chunk-KGUBBRL6.js} +11 -13
- package/dist/{chunk-SVTXMVLQ.js → chunk-KTDVTBMH.js} +1 -1
- package/dist/{chunk-766EAFX6.js → chunk-POXTQZ4D.js} +1 -31
- package/dist/chunk-SWNOXPYJ.js +142 -0
- package/dist/{chunk-XXSKWWMB.js → chunk-TLD6JMT6.js} +1 -1
- package/dist/{chunk-CNKI574E.js → chunk-VXEBLM4X.js} +1 -1
- package/dist/{chunk-QVZ7JH4H.js → chunk-YC25YEBF.js} +1 -1
- package/dist/chunk-ZLCSVXCD.js +10 -0
- package/dist/config/index.cjs +18 -97
- package/dist/config/index.d.cts +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +48 -9
- package/dist/{define-BH4bnHQl.d.ts → define--6HQ1ehX.d.cts} +18 -3
- package/dist/{define-BH4bnHQl.d.cts → define--6HQ1ehX.d.ts} +18 -3
- package/dist/loader-mdx.cjs +127 -139
- package/dist/loader-mdx.js +6 -6
- package/dist/next/index.cjs +29 -139
- package/dist/next/index.js +16 -16
- package/dist/node/loader.cjs +131 -143
- package/dist/node/loader.js +6 -6
- package/dist/postinstall-U7VROOY7.js +9 -0
- package/dist/{mdx-options-T73E4LQB.js → preset-WFEORCAB.js} +1 -1
- package/dist/runtime/next/async.cjs +198 -150
- package/dist/runtime/next/async.d.cts +3 -3
- package/dist/runtime/next/async.d.ts +3 -3
- package/dist/runtime/next/async.js +50 -30
- package/dist/runtime/next/index.cjs +32 -21
- package/dist/runtime/next/index.d.cts +11 -7
- package/dist/runtime/next/index.d.ts +11 -7
- package/dist/runtime/next/index.js +2 -1
- package/dist/runtime/vite/browser.d.cts +2 -3
- package/dist/runtime/vite/browser.d.ts +2 -3
- package/dist/runtime/vite/server.cjs +67 -21
- package/dist/runtime/vite/server.d.cts +14 -28
- package/dist/runtime/vite/server.d.ts +14 -28
- package/dist/runtime/vite/server.js +61 -21
- package/dist/shared-0QIuV0XZ.d.ts +70 -0
- package/dist/shared-CqgMnt9h.d.cts +70 -0
- package/dist/{types-DN9KrG7R.d.ts → types-DLIAvrgC.d.ts} +6 -32
- package/dist/{types-DT83Ijs6.d.cts → types-Dl8HLbm5.d.cts} +6 -32
- package/dist/vite/index.cjs +131 -143
- package/dist/vite/index.js +7 -7
- package/package.json +2 -6
- package/dist/build-mdx-DnC1jKvn.d.cts +0 -46
- package/dist/build-mdx-DnC1jKvn.d.ts +0 -46
- package/dist/chunk-GBMFGEC7.js +0 -57
- package/dist/chunk-QQWCBFFE.js +0 -40
- package/dist/chunk-SMSNZ6N5.js +0 -155
- package/dist/config/zod-3.cjs +0 -422
- package/dist/config/zod-3.d.cts +0 -53
- package/dist/config/zod-3.d.ts +0 -53
- package/dist/config/zod-3.js +0 -40
- package/dist/postinstall-XV4WSHZP.js +0 -9
package/dist/bun/index.cjs
CHANGED
|
@@ -30,86 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// src/mdx
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}) {
|
|
37
|
-
return (tree, file) => {
|
|
38
|
-
let title;
|
|
39
|
-
const urls = [];
|
|
40
|
-
(0, import_unist_util_visit2.visit)(tree, ["heading", "link"], (node) => {
|
|
41
|
-
if (node.type === "heading" && node.depth === 1) {
|
|
42
|
-
title = flattenNode2(node);
|
|
43
|
-
}
|
|
44
|
-
if (node.type !== "link") return;
|
|
45
|
-
urls.push({
|
|
46
|
-
href: node.url
|
|
47
|
-
});
|
|
48
|
-
return "skip";
|
|
49
|
-
});
|
|
50
|
-
if (title) {
|
|
51
|
-
file.data.frontmatter ??= {};
|
|
52
|
-
if (!file.data.frontmatter.title) file.data.frontmatter.title = title;
|
|
53
|
-
}
|
|
54
|
-
file.data.extractedReferences = urls;
|
|
55
|
-
for (const name of injectExports) {
|
|
56
|
-
if (!(name in file.data)) continue;
|
|
57
|
-
tree.children.unshift(getMdastExport(name, file.data[name]));
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function flattenNode2(node) {
|
|
62
|
-
if ("children" in node)
|
|
63
|
-
return node.children.map((child) => flattenNode2(child)).join("");
|
|
64
|
-
if ("value" in node) return node.value;
|
|
65
|
-
return "";
|
|
66
|
-
}
|
|
67
|
-
function getMdastExport(name, value) {
|
|
68
|
-
return {
|
|
69
|
-
type: "mdxjsEsm",
|
|
70
|
-
value: "",
|
|
71
|
-
data: {
|
|
72
|
-
estree: {
|
|
73
|
-
type: "Program",
|
|
74
|
-
sourceType: "module",
|
|
75
|
-
body: [
|
|
76
|
-
{
|
|
77
|
-
type: "ExportNamedDeclaration",
|
|
78
|
-
attributes: [],
|
|
79
|
-
specifiers: [],
|
|
80
|
-
source: null,
|
|
81
|
-
declaration: {
|
|
82
|
-
type: "VariableDeclaration",
|
|
83
|
-
kind: "let",
|
|
84
|
-
declarations: [
|
|
85
|
-
{
|
|
86
|
-
type: "VariableDeclarator",
|
|
87
|
-
id: {
|
|
88
|
-
type: "Identifier",
|
|
89
|
-
name
|
|
90
|
-
},
|
|
91
|
-
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
var import_unist_util_visit2, import_estree_util_value_to_estree;
|
|
102
|
-
var init_remark_postprocess = __esm({
|
|
103
|
-
"src/mdx-plugins/remark-postprocess.ts"() {
|
|
104
|
-
"use strict";
|
|
105
|
-
import_unist_util_visit2 = require("unist-util-visit");
|
|
106
|
-
import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// src/utils/mdx-options.ts
|
|
111
|
-
var mdx_options_exports = {};
|
|
112
|
-
__export(mdx_options_exports, {
|
|
33
|
+
// src/mdx/preset.ts
|
|
34
|
+
var preset_exports = {};
|
|
35
|
+
__export(preset_exports, {
|
|
113
36
|
getDefaultMDXOptions: () => getDefaultMDXOptions
|
|
114
37
|
});
|
|
115
38
|
function pluginOption(def, options = []) {
|
|
@@ -132,13 +55,6 @@ function getDefaultMDXOptions({
|
|
|
132
55
|
_withoutBundler = false,
|
|
133
56
|
...mdxOptions
|
|
134
57
|
}) {
|
|
135
|
-
const mdxExports = [
|
|
136
|
-
"structuredData",
|
|
137
|
-
"extractedReferences",
|
|
138
|
-
"frontmatter",
|
|
139
|
-
"lastModified",
|
|
140
|
-
...valueToExport
|
|
141
|
-
];
|
|
142
58
|
const remarkPlugins = pluginOption(
|
|
143
59
|
(v) => [
|
|
144
60
|
plugins.remarkGfm,
|
|
@@ -166,10 +82,15 @@ function getDefaultMDXOptions({
|
|
|
166
82
|
plugins.remarkStructure,
|
|
167
83
|
remarkStructureOptions
|
|
168
84
|
],
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
85
|
+
() => {
|
|
86
|
+
return (_, file) => {
|
|
87
|
+
file.data["mdx-export"] ??= [];
|
|
88
|
+
for (const name of valueToExport) {
|
|
89
|
+
if (name in file.data)
|
|
90
|
+
file.data["mdx-export"].push({ name, value: file.data[name] });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
173
94
|
],
|
|
174
95
|
mdxOptions.remarkPlugins
|
|
175
96
|
);
|
|
@@ -189,11 +110,10 @@ function getDefaultMDXOptions({
|
|
|
189
110
|
};
|
|
190
111
|
}
|
|
191
112
|
var plugins;
|
|
192
|
-
var
|
|
193
|
-
"src/
|
|
113
|
+
var init_preset = __esm({
|
|
114
|
+
"src/mdx/preset.ts"() {
|
|
194
115
|
"use strict";
|
|
195
116
|
plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
196
|
-
init_remark_postprocess();
|
|
197
117
|
}
|
|
198
118
|
});
|
|
199
119
|
|
|
@@ -290,10 +210,10 @@ function countLines(s) {
|
|
|
290
210
|
return num;
|
|
291
211
|
}
|
|
292
212
|
|
|
293
|
-
// src/
|
|
213
|
+
// src/mdx/build-mdx.ts
|
|
294
214
|
var import_mdx = require("@mdx-js/mdx");
|
|
295
215
|
|
|
296
|
-
// src/mdx
|
|
216
|
+
// src/mdx/remark-include.ts
|
|
297
217
|
var import_unified = require("unified");
|
|
298
218
|
var import_unist_util_visit = require("unist-util-visit");
|
|
299
219
|
var path2 = __toESM(require("path"), 1);
|
|
@@ -425,7 +345,90 @@ function getDefaultProcessor(format) {
|
|
|
425
345
|
return mdProcessor.use(import_remark_mdx.default);
|
|
426
346
|
}
|
|
427
347
|
|
|
428
|
-
// src/
|
|
348
|
+
// src/mdx/remark-postprocess.ts
|
|
349
|
+
var import_unist_util_visit2 = require("unist-util-visit");
|
|
350
|
+
var import_mdast_util_to_markdown = require("mdast-util-to-markdown");
|
|
351
|
+
var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
352
|
+
function remarkPostprocess({
|
|
353
|
+
includeProcessedMarkdown = false,
|
|
354
|
+
valueToExport = []
|
|
355
|
+
} = {}) {
|
|
356
|
+
return (tree, file) => {
|
|
357
|
+
let title;
|
|
358
|
+
const urls = [];
|
|
359
|
+
(0, import_unist_util_visit2.visit)(tree, ["heading", "link"], (node) => {
|
|
360
|
+
if (node.type === "heading" && node.depth === 1) {
|
|
361
|
+
title = flattenNode2(node);
|
|
362
|
+
}
|
|
363
|
+
if (node.type !== "link") return;
|
|
364
|
+
urls.push({
|
|
365
|
+
href: node.url
|
|
366
|
+
});
|
|
367
|
+
return "skip";
|
|
368
|
+
});
|
|
369
|
+
if (title) {
|
|
370
|
+
file.data.frontmatter ??= {};
|
|
371
|
+
if (!file.data.frontmatter.title) file.data.frontmatter.title = title;
|
|
372
|
+
}
|
|
373
|
+
file.data.extractedReferences = urls;
|
|
374
|
+
if (includeProcessedMarkdown) {
|
|
375
|
+
file.data._markdown = (0, import_mdast_util_to_markdown.toMarkdown)(tree, {
|
|
376
|
+
...this.data("settings"),
|
|
377
|
+
// @ts-expect-error - from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js
|
|
378
|
+
extensions: this.data("toMarkdownExtensions") || []
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
for (const { name, value } of file.data["mdx-export"] ?? []) {
|
|
382
|
+
tree.children.unshift(getMdastExport(name, value));
|
|
383
|
+
}
|
|
384
|
+
for (const name of valueToExport) {
|
|
385
|
+
if (!(name in file.data)) continue;
|
|
386
|
+
tree.children.unshift(getMdastExport(name, file.data[name]));
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
function getMdastExport(name, value) {
|
|
391
|
+
return {
|
|
392
|
+
type: "mdxjsEsm",
|
|
393
|
+
value: "",
|
|
394
|
+
data: {
|
|
395
|
+
estree: {
|
|
396
|
+
type: "Program",
|
|
397
|
+
sourceType: "module",
|
|
398
|
+
body: [
|
|
399
|
+
{
|
|
400
|
+
type: "ExportNamedDeclaration",
|
|
401
|
+
attributes: [],
|
|
402
|
+
specifiers: [],
|
|
403
|
+
source: null,
|
|
404
|
+
declaration: {
|
|
405
|
+
type: "VariableDeclaration",
|
|
406
|
+
kind: "let",
|
|
407
|
+
declarations: [
|
|
408
|
+
{
|
|
409
|
+
type: "VariableDeclarator",
|
|
410
|
+
id: {
|
|
411
|
+
type: "Identifier",
|
|
412
|
+
name
|
|
413
|
+
},
|
|
414
|
+
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
415
|
+
}
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function flattenNode2(node) {
|
|
425
|
+
if ("children" in node)
|
|
426
|
+
return node.children.map((child) => flattenNode2(child)).join("");
|
|
427
|
+
if ("value" in node) return node.value;
|
|
428
|
+
return "";
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// src/mdx/build-mdx.ts
|
|
429
432
|
var cache2 = /* @__PURE__ */ new Map();
|
|
430
433
|
async function buildMDX(cacheKey, source, options) {
|
|
431
434
|
const { filePath, frontmatter, data, _compiler, ...rest } = options;
|
|
@@ -436,7 +439,24 @@ async function buildMDX(cacheKey, source, options) {
|
|
|
436
439
|
processor = (0, import_mdx.createProcessor)({
|
|
437
440
|
outputFormat: "program",
|
|
438
441
|
...rest,
|
|
439
|
-
remarkPlugins: [
|
|
442
|
+
remarkPlugins: [
|
|
443
|
+
remarkInclude,
|
|
444
|
+
...rest.remarkPlugins ?? [],
|
|
445
|
+
[
|
|
446
|
+
remarkPostprocess,
|
|
447
|
+
{
|
|
448
|
+
...options.postprocess,
|
|
449
|
+
valueToExport: [
|
|
450
|
+
...options.postprocess?.valueToExport ?? [],
|
|
451
|
+
"structuredData",
|
|
452
|
+
"extractedReferences",
|
|
453
|
+
"frontmatter",
|
|
454
|
+
"lastModified",
|
|
455
|
+
"_markdown"
|
|
456
|
+
]
|
|
457
|
+
}
|
|
458
|
+
]
|
|
459
|
+
],
|
|
440
460
|
format
|
|
441
461
|
});
|
|
442
462
|
cache2.set(key, processor);
|
|
@@ -492,21 +512,18 @@ function createMdxLoader(configLoader) {
|
|
|
492
512
|
if (cached && cached.hash === generateCacheHash(value)) return cached;
|
|
493
513
|
}
|
|
494
514
|
const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
|
|
495
|
-
let
|
|
496
|
-
let mdxOptions;
|
|
515
|
+
let docCollection;
|
|
497
516
|
switch (collection?.type) {
|
|
498
517
|
case "doc":
|
|
499
|
-
|
|
500
|
-
schema = collection.schema;
|
|
518
|
+
docCollection = collection;
|
|
501
519
|
break;
|
|
502
520
|
case "docs":
|
|
503
|
-
|
|
504
|
-
schema = collection.docs.schema;
|
|
521
|
+
docCollection = collection.docs;
|
|
505
522
|
break;
|
|
506
523
|
}
|
|
507
|
-
if (schema) {
|
|
524
|
+
if (docCollection?.schema) {
|
|
508
525
|
matter.data = await validate(
|
|
509
|
-
schema,
|
|
526
|
+
docCollection.schema,
|
|
510
527
|
matter.data,
|
|
511
528
|
{
|
|
512
529
|
source: value,
|
|
@@ -531,7 +548,8 @@ function createMdxLoader(configLoader) {
|
|
|
531
548
|
"\n".repeat(lineOffset) + matter.content,
|
|
532
549
|
{
|
|
533
550
|
development: isDevelopment,
|
|
534
|
-
...mdxOptions ?? await loaded.getDefaultMDXOptions(),
|
|
551
|
+
...docCollection?.mdxOptions ?? await loaded.getDefaultMDXOptions(),
|
|
552
|
+
postprocess: docCollection?.postprocess,
|
|
535
553
|
data,
|
|
536
554
|
filePath,
|
|
537
555
|
frontmatter: matter.data,
|
|
@@ -600,7 +618,7 @@ function buildConfig(config) {
|
|
|
600
618
|
const input = this.global.mdxOptions;
|
|
601
619
|
async function uncached() {
|
|
602
620
|
const options = typeof input === "function" ? await input() : input;
|
|
603
|
-
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (
|
|
621
|
+
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_preset(), preset_exports));
|
|
604
622
|
if (options?.preset === "minimal") return options;
|
|
605
623
|
return getDefaultMDXOptions2({
|
|
606
624
|
...options,
|
package/dist/bun/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMdxLoader,
|
|
3
3
|
resolvedConfig
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-QQWCBFFE.js";
|
|
6
|
-
import "../chunk-SVTXMVLQ.js";
|
|
4
|
+
} from "../chunk-KGUBBRL6.js";
|
|
7
5
|
import "../chunk-IQAEAI4P.js";
|
|
8
6
|
import {
|
|
9
7
|
findConfigFile
|
|
10
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-POXTQZ4D.js";
|
|
9
|
+
import "../chunk-SWNOXPYJ.js";
|
|
10
|
+
import "../chunk-KTDVTBMH.js";
|
|
11
11
|
import {
|
|
12
12
|
buildConfig
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-YC25YEBF.js";
|
|
14
14
|
import "../chunk-VWJKRQZR.js";
|
|
15
15
|
|
|
16
16
|
// src/bun/index.ts
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/mdx/preset.ts
|
|
2
|
+
import * as plugins from "fumadocs-core/mdx-plugins";
|
|
3
|
+
function pluginOption(def, options = []) {
|
|
4
|
+
const list = def(Array.isArray(options) ? options : []).filter(
|
|
5
|
+
Boolean
|
|
6
|
+
);
|
|
7
|
+
if (typeof options === "function") {
|
|
8
|
+
return options(list);
|
|
9
|
+
}
|
|
10
|
+
return list;
|
|
11
|
+
}
|
|
12
|
+
function getDefaultMDXOptions({
|
|
13
|
+
valueToExport = [],
|
|
14
|
+
rehypeCodeOptions,
|
|
15
|
+
remarkImageOptions,
|
|
16
|
+
remarkHeadingOptions,
|
|
17
|
+
remarkStructureOptions,
|
|
18
|
+
remarkCodeTabOptions,
|
|
19
|
+
remarkNpmOptions,
|
|
20
|
+
_withoutBundler = false,
|
|
21
|
+
...mdxOptions
|
|
22
|
+
}) {
|
|
23
|
+
const remarkPlugins = pluginOption(
|
|
24
|
+
(v) => [
|
|
25
|
+
plugins.remarkGfm,
|
|
26
|
+
[
|
|
27
|
+
plugins.remarkHeading,
|
|
28
|
+
{
|
|
29
|
+
generateToc: false,
|
|
30
|
+
...remarkHeadingOptions
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
remarkImageOptions !== false && [
|
|
34
|
+
plugins.remarkImage,
|
|
35
|
+
{
|
|
36
|
+
...remarkImageOptions,
|
|
37
|
+
useImport: _withoutBundler ? false : remarkImageOptions?.useImport
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
|
|
41
|
+
plugins.remarkCodeTab,
|
|
42
|
+
remarkCodeTabOptions
|
|
43
|
+
],
|
|
44
|
+
"remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
|
|
45
|
+
...v,
|
|
46
|
+
remarkStructureOptions !== false && [
|
|
47
|
+
plugins.remarkStructure,
|
|
48
|
+
remarkStructureOptions
|
|
49
|
+
],
|
|
50
|
+
() => {
|
|
51
|
+
return (_, file) => {
|
|
52
|
+
file.data["mdx-export"] ??= [];
|
|
53
|
+
for (const name of valueToExport) {
|
|
54
|
+
if (name in file.data)
|
|
55
|
+
file.data["mdx-export"].push({ name, value: file.data[name] });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
mdxOptions.remarkPlugins
|
|
61
|
+
);
|
|
62
|
+
const rehypePlugins = pluginOption(
|
|
63
|
+
(v) => [
|
|
64
|
+
rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
|
|
65
|
+
...v,
|
|
66
|
+
plugins.rehypeToc
|
|
67
|
+
],
|
|
68
|
+
mdxOptions.rehypePlugins
|
|
69
|
+
);
|
|
70
|
+
return {
|
|
71
|
+
...mdxOptions,
|
|
72
|
+
outputFormat: _withoutBundler ? "function-body" : mdxOptions.outputFormat,
|
|
73
|
+
remarkPlugins,
|
|
74
|
+
rehypePlugins
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
getDefaultMDXOptions
|
|
80
|
+
};
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
missingProcessedMarkdown
|
|
3
|
+
} from "./chunk-ZLCSVXCD.js";
|
|
4
|
+
|
|
1
5
|
// src/runtime/next/index.ts
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
var cache = /* @__PURE__ */ new Map();
|
|
6
|
+
import * as fs from "fs/promises";
|
|
4
7
|
var _runtime = {
|
|
5
8
|
doc(files) {
|
|
6
9
|
return files.map((file) => {
|
|
7
|
-
const
|
|
10
|
+
const data = file.data;
|
|
11
|
+
const filePath = file.info.fullPath;
|
|
8
12
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
info: file.info,
|
|
14
|
+
_exports: data,
|
|
15
|
+
body: data.default,
|
|
16
|
+
lastModified: data.lastModified,
|
|
17
|
+
toc: data.toc,
|
|
18
|
+
structuredData: data.structuredData,
|
|
19
|
+
extractedReferences: data.extractedReferences,
|
|
20
|
+
...data.frontmatter,
|
|
21
|
+
async getText(type) {
|
|
22
|
+
if (type === "raw") {
|
|
23
|
+
return (await fs.readFile(filePath)).toString();
|
|
24
|
+
}
|
|
25
|
+
if (typeof data._markdown !== "string") missingProcessedMarkdown();
|
|
26
|
+
return data._markdown;
|
|
21
27
|
}
|
|
22
28
|
};
|
|
23
29
|
});
|
|
@@ -25,8 +31,8 @@ var _runtime = {
|
|
|
25
31
|
meta(files) {
|
|
26
32
|
return files.map((file) => {
|
|
27
33
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
info: file.info,
|
|
35
|
+
...file.data
|
|
30
36
|
};
|
|
31
37
|
});
|
|
32
38
|
},
|
|
@@ -55,16 +61,16 @@ function resolveFiles({ docs, meta }) {
|
|
|
55
61
|
for (const entry of docs) {
|
|
56
62
|
outputs.push({
|
|
57
63
|
type: "page",
|
|
58
|
-
absolutePath: entry.
|
|
59
|
-
path: entry.
|
|
64
|
+
absolutePath: entry.info.fullPath,
|
|
65
|
+
path: entry.info.path,
|
|
60
66
|
data: entry
|
|
61
67
|
});
|
|
62
68
|
}
|
|
63
69
|
for (const entry of meta) {
|
|
64
70
|
outputs.push({
|
|
65
71
|
type: "meta",
|
|
66
|
-
absolutePath: entry.
|
|
67
|
-
path: entry.
|
|
72
|
+
absolutePath: entry.info.fullPath,
|
|
73
|
+
path: entry.info.path,
|
|
68
74
|
data: entry
|
|
69
75
|
});
|
|
70
76
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildMDX
|
|
3
|
-
} from "./chunk-QQWCBFFE.js";
|
|
4
1
|
import {
|
|
5
2
|
getGitTimestamp,
|
|
6
3
|
validate
|
|
@@ -8,7 +5,10 @@ import {
|
|
|
8
5
|
import {
|
|
9
6
|
getConfigHash,
|
|
10
7
|
loadConfig
|
|
11
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-POXTQZ4D.js";
|
|
9
|
+
import {
|
|
10
|
+
buildMDX
|
|
11
|
+
} from "./chunk-SWNOXPYJ.js";
|
|
12
12
|
import {
|
|
13
13
|
fumaMatter
|
|
14
14
|
} from "./chunk-VWJKRQZR.js";
|
|
@@ -57,21 +57,18 @@ function createMdxLoader(configLoader) {
|
|
|
57
57
|
if (cached && cached.hash === generateCacheHash(value)) return cached;
|
|
58
58
|
}
|
|
59
59
|
const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
|
|
60
|
-
let
|
|
61
|
-
let mdxOptions;
|
|
60
|
+
let docCollection;
|
|
62
61
|
switch (collection?.type) {
|
|
63
62
|
case "doc":
|
|
64
|
-
|
|
65
|
-
schema = collection.schema;
|
|
63
|
+
docCollection = collection;
|
|
66
64
|
break;
|
|
67
65
|
case "docs":
|
|
68
|
-
|
|
69
|
-
schema = collection.docs.schema;
|
|
66
|
+
docCollection = collection.docs;
|
|
70
67
|
break;
|
|
71
68
|
}
|
|
72
|
-
if (schema) {
|
|
69
|
+
if (docCollection?.schema) {
|
|
73
70
|
matter.data = await validate(
|
|
74
|
-
schema,
|
|
71
|
+
docCollection.schema,
|
|
75
72
|
matter.data,
|
|
76
73
|
{
|
|
77
74
|
source: value,
|
|
@@ -96,7 +93,8 @@ function createMdxLoader(configLoader) {
|
|
|
96
93
|
"\n".repeat(lineOffset) + matter.content,
|
|
97
94
|
{
|
|
98
95
|
development: isDevelopment,
|
|
99
|
-
...mdxOptions ?? await loaded.getDefaultMDXOptions(),
|
|
96
|
+
...docCollection?.mdxOptions ?? await loaded.getDefaultMDXOptions(),
|
|
97
|
+
postprocess: docCollection?.postprocess,
|
|
100
98
|
data,
|
|
101
99
|
filePath,
|
|
102
100
|
frontmatter: matter.data,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YC25YEBF.js";
|
|
4
4
|
|
|
5
5
|
// src/utils/config.ts
|
|
6
6
|
import * as fs from "fs/promises";
|
|
@@ -10,35 +10,6 @@ function findConfigFile() {
|
|
|
10
10
|
return path.resolve("source.config.ts");
|
|
11
11
|
}
|
|
12
12
|
var cache = null;
|
|
13
|
-
async function isZod3() {
|
|
14
|
-
try {
|
|
15
|
-
const content = JSON.parse(
|
|
16
|
-
(await fs.readFile("node_modules/zod/package.json")).toString()
|
|
17
|
-
);
|
|
18
|
-
const version = content.version;
|
|
19
|
-
return typeof version === "string" && version.startsWith("3.");
|
|
20
|
-
} catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function createCompatZodPlugin() {
|
|
25
|
-
return {
|
|
26
|
-
name: "replace-zod-import",
|
|
27
|
-
async setup(build) {
|
|
28
|
-
const usingZod3 = await isZod3();
|
|
29
|
-
if (!usingZod3) return;
|
|
30
|
-
console.warn(
|
|
31
|
-
"[Fumadocs MDX] Noticed Zod v3 in your node_modules, we recommend upgrading to Zod v4 for better compatibility."
|
|
32
|
-
);
|
|
33
|
-
build.onResolve({ filter: /^fumadocs-mdx\/config$/ }, () => {
|
|
34
|
-
return {
|
|
35
|
-
path: "fumadocs-mdx/config/zod-3",
|
|
36
|
-
external: true
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
13
|
async function compileConfig(configPath, outDir) {
|
|
43
14
|
const { build } = await import("esbuild");
|
|
44
15
|
const transformed = await build({
|
|
@@ -50,7 +21,6 @@ async function compileConfig(configPath, outDir) {
|
|
|
50
21
|
platform: "node",
|
|
51
22
|
format: "esm",
|
|
52
23
|
packages: "external",
|
|
53
|
-
plugins: [createCompatZodPlugin()],
|
|
54
24
|
outExtension: {
|
|
55
25
|
".js": ".mjs"
|
|
56
26
|
},
|