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/next/index.js
CHANGED
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
findConfigFile,
|
|
14
14
|
getConfigHash,
|
|
15
15
|
loadConfig
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-
|
|
16
|
+
} from "../chunk-POXTQZ4D.js";
|
|
17
|
+
import "../chunk-YC25YEBF.js";
|
|
18
18
|
import {
|
|
19
19
|
fumaMatter
|
|
20
20
|
} from "../chunk-VWJKRQZR.js";
|
|
@@ -81,7 +81,7 @@ async function generateJS(configPath, config, importPath, configHash = false) {
|
|
|
81
81
|
getImportCode({
|
|
82
82
|
type: "namespace",
|
|
83
83
|
name: importId,
|
|
84
|
-
specifier: `${toImportPath(file.
|
|
84
|
+
specifier: `${toImportPath(file.fullPath, importPath)}?${params.join("&")}`
|
|
85
85
|
})
|
|
86
86
|
);
|
|
87
87
|
return `{ info: ${JSON.stringify(file)}, data: ${importId} }`;
|
|
@@ -90,17 +90,17 @@ async function generateJS(configPath, config, importPath, configHash = false) {
|
|
|
90
90
|
}
|
|
91
91
|
async function getMetaEntries(collection, files) {
|
|
92
92
|
const items = files.map(async (file) => {
|
|
93
|
-
const source = await readFileWithCache(file.
|
|
94
|
-
let data = source.length === 0 ? {} : parseMetaEntry(file.
|
|
93
|
+
const source = await readFileWithCache(file.fullPath).catch(() => "");
|
|
94
|
+
let data = source.length === 0 ? {} : parseMetaEntry(file.fullPath, source);
|
|
95
95
|
if (collection?.schema) {
|
|
96
96
|
data = await validate(
|
|
97
97
|
collection.schema,
|
|
98
98
|
data,
|
|
99
99
|
{
|
|
100
100
|
source,
|
|
101
|
-
path: file.
|
|
101
|
+
path: file.fullPath
|
|
102
102
|
},
|
|
103
|
-
`invalid data in ${file.
|
|
103
|
+
`invalid data in ${file.fullPath}`
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
return JSON.stringify({
|
|
@@ -124,20 +124,20 @@ async function generateJS(configPath, config, importPath, configHash = false) {
|
|
|
124
124
|
}
|
|
125
125
|
const entries2 = files.map(async (file) => {
|
|
126
126
|
const parsed = fumaMatter(
|
|
127
|
-
await readFileWithCache(file.
|
|
127
|
+
await readFileWithCache(file.fullPath).catch(() => "")
|
|
128
128
|
);
|
|
129
129
|
let data = parsed.data;
|
|
130
130
|
if (collection.schema) {
|
|
131
131
|
data = await validate(
|
|
132
132
|
collection.schema,
|
|
133
133
|
parsed.data,
|
|
134
|
-
{ path: file.
|
|
135
|
-
`invalid frontmatter in ${file.
|
|
134
|
+
{ path: file.fullPath, source: parsed.content },
|
|
135
|
+
`invalid frontmatter in ${file.fullPath}`
|
|
136
136
|
);
|
|
137
137
|
}
|
|
138
138
|
let lastModified;
|
|
139
139
|
if (config.global?.lastModifiedTime === "git") {
|
|
140
|
-
lastModified = await getGitTimestamp(file.
|
|
140
|
+
lastModified = await getGitTimestamp(file.fullPath);
|
|
141
141
|
}
|
|
142
142
|
return JSON.stringify({
|
|
143
143
|
info: file,
|
|
@@ -184,14 +184,14 @@ async function getCollectionFiles(collection) {
|
|
|
184
184
|
await Promise.all(
|
|
185
185
|
dirs.map(async (dir) => {
|
|
186
186
|
const result = await glob(patterns, {
|
|
187
|
-
cwd: path.resolve(dir)
|
|
188
|
-
absolute: true
|
|
187
|
+
cwd: path.resolve(dir)
|
|
189
188
|
});
|
|
190
189
|
for (const item of result) {
|
|
191
190
|
if (!isFileSupported(item, collection)) continue;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
const fullPath = path.join(dir, item);
|
|
192
|
+
files.set(fullPath, {
|
|
193
|
+
path: item,
|
|
194
|
+
fullPath
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
})
|
package/dist/node/loader.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_visit.visit)(tree, ["heading", "link"], (node) => {
|
|
41
|
-
if (node.type === "heading" && node.depth === 1) {
|
|
42
|
-
title = flattenNode(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 flattenNode(node) {
|
|
62
|
-
if ("children" in node)
|
|
63
|
-
return node.children.map((child) => flattenNode(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_visit, 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_visit = 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
|
|
|
@@ -245,7 +165,7 @@ function buildConfig(config) {
|
|
|
245
165
|
const input = this.global.mdxOptions;
|
|
246
166
|
async function uncached() {
|
|
247
167
|
const options = typeof input === "function" ? await input() : input;
|
|
248
|
-
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (
|
|
168
|
+
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_preset(), preset_exports));
|
|
249
169
|
if (options?.preset === "minimal") return options;
|
|
250
170
|
return getDefaultMDXOptions2({
|
|
251
171
|
...options,
|
|
@@ -264,35 +184,6 @@ function findConfigFile() {
|
|
|
264
184
|
return path.resolve("source.config.ts");
|
|
265
185
|
}
|
|
266
186
|
var cache = null;
|
|
267
|
-
async function isZod3() {
|
|
268
|
-
try {
|
|
269
|
-
const content = JSON.parse(
|
|
270
|
-
(await fs.readFile("node_modules/zod/package.json")).toString()
|
|
271
|
-
);
|
|
272
|
-
const version = content.version;
|
|
273
|
-
return typeof version === "string" && version.startsWith("3.");
|
|
274
|
-
} catch {
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function createCompatZodPlugin() {
|
|
279
|
-
return {
|
|
280
|
-
name: "replace-zod-import",
|
|
281
|
-
async setup(build) {
|
|
282
|
-
const usingZod3 = await isZod3();
|
|
283
|
-
if (!usingZod3) return;
|
|
284
|
-
console.warn(
|
|
285
|
-
"[Fumadocs MDX] Noticed Zod v3 in your node_modules, we recommend upgrading to Zod v4 for better compatibility."
|
|
286
|
-
);
|
|
287
|
-
build.onResolve({ filter: /^fumadocs-mdx\/config$/ }, () => {
|
|
288
|
-
return {
|
|
289
|
-
path: "fumadocs-mdx/config/zod-3",
|
|
290
|
-
external: true
|
|
291
|
-
};
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
187
|
async function compileConfig(configPath, outDir) {
|
|
297
188
|
const { build } = await import("esbuild");
|
|
298
189
|
const transformed = await build({
|
|
@@ -304,7 +195,6 @@ async function compileConfig(configPath, outDir) {
|
|
|
304
195
|
platform: "node",
|
|
305
196
|
format: "esm",
|
|
306
197
|
packages: "external",
|
|
307
|
-
plugins: [createCompatZodPlugin()],
|
|
308
198
|
outExtension: {
|
|
309
199
|
".js": ".mjs"
|
|
310
200
|
},
|
|
@@ -423,21 +313,21 @@ function countLines(s) {
|
|
|
423
313
|
return num;
|
|
424
314
|
}
|
|
425
315
|
|
|
426
|
-
// src/
|
|
316
|
+
// src/mdx/build-mdx.ts
|
|
427
317
|
var import_mdx = require("@mdx-js/mdx");
|
|
428
318
|
|
|
429
|
-
// src/mdx
|
|
319
|
+
// src/mdx/remark-include.ts
|
|
430
320
|
var import_unified = require("unified");
|
|
431
|
-
var
|
|
321
|
+
var import_unist_util_visit = require("unist-util-visit");
|
|
432
322
|
var path3 = __toESM(require("path"), 1);
|
|
433
323
|
var fs2 = __toESM(require("fs/promises"), 1);
|
|
434
324
|
var import_remark_parse = __toESM(require("remark-parse"), 1);
|
|
435
325
|
var import_remark_mdx = __toESM(require("remark-mdx"), 1);
|
|
436
326
|
var import_mdx_plugins = require("fumadocs-core/mdx-plugins");
|
|
437
327
|
var baseProcessor = (0, import_unified.unified)().use(import_mdx_plugins.remarkHeading);
|
|
438
|
-
function
|
|
328
|
+
function flattenNode(node) {
|
|
439
329
|
if ("children" in node)
|
|
440
|
-
return node.children.map((child) =>
|
|
330
|
+
return node.children.map((child) => flattenNode(child)).join("");
|
|
441
331
|
if ("value" in node) return node.value;
|
|
442
332
|
return "";
|
|
443
333
|
}
|
|
@@ -516,14 +406,14 @@ ${e instanceof Error ? e.message : String(e)}`,
|
|
|
516
406
|
}
|
|
517
407
|
async function update(tree, directory, data) {
|
|
518
408
|
const queue = [];
|
|
519
|
-
(0,
|
|
409
|
+
(0, import_unist_util_visit.visit)(
|
|
520
410
|
tree,
|
|
521
411
|
["mdxJsxFlowElement", "mdxJsxTextElement"],
|
|
522
412
|
(_node, _, parent) => {
|
|
523
413
|
const node = _node;
|
|
524
414
|
if (node.name !== TagName) return;
|
|
525
415
|
const params = {};
|
|
526
|
-
const specifier =
|
|
416
|
+
const specifier = flattenNode(node);
|
|
527
417
|
if (specifier.length === 0) return "skip";
|
|
528
418
|
for (const attr of node.attributes) {
|
|
529
419
|
if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
|
|
@@ -558,7 +448,90 @@ function getDefaultProcessor(format) {
|
|
|
558
448
|
return mdProcessor.use(import_remark_mdx.default);
|
|
559
449
|
}
|
|
560
450
|
|
|
561
|
-
// src/
|
|
451
|
+
// src/mdx/remark-postprocess.ts
|
|
452
|
+
var import_unist_util_visit2 = require("unist-util-visit");
|
|
453
|
+
var import_mdast_util_to_markdown = require("mdast-util-to-markdown");
|
|
454
|
+
var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
455
|
+
function remarkPostprocess({
|
|
456
|
+
includeProcessedMarkdown = false,
|
|
457
|
+
valueToExport = []
|
|
458
|
+
} = {}) {
|
|
459
|
+
return (tree, file) => {
|
|
460
|
+
let title;
|
|
461
|
+
const urls = [];
|
|
462
|
+
(0, import_unist_util_visit2.visit)(tree, ["heading", "link"], (node) => {
|
|
463
|
+
if (node.type === "heading" && node.depth === 1) {
|
|
464
|
+
title = flattenNode2(node);
|
|
465
|
+
}
|
|
466
|
+
if (node.type !== "link") return;
|
|
467
|
+
urls.push({
|
|
468
|
+
href: node.url
|
|
469
|
+
});
|
|
470
|
+
return "skip";
|
|
471
|
+
});
|
|
472
|
+
if (title) {
|
|
473
|
+
file.data.frontmatter ??= {};
|
|
474
|
+
if (!file.data.frontmatter.title) file.data.frontmatter.title = title;
|
|
475
|
+
}
|
|
476
|
+
file.data.extractedReferences = urls;
|
|
477
|
+
if (includeProcessedMarkdown) {
|
|
478
|
+
file.data._markdown = (0, import_mdast_util_to_markdown.toMarkdown)(tree, {
|
|
479
|
+
...this.data("settings"),
|
|
480
|
+
// @ts-expect-error - from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js
|
|
481
|
+
extensions: this.data("toMarkdownExtensions") || []
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
for (const { name, value } of file.data["mdx-export"] ?? []) {
|
|
485
|
+
tree.children.unshift(getMdastExport(name, value));
|
|
486
|
+
}
|
|
487
|
+
for (const name of valueToExport) {
|
|
488
|
+
if (!(name in file.data)) continue;
|
|
489
|
+
tree.children.unshift(getMdastExport(name, file.data[name]));
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
function getMdastExport(name, value) {
|
|
494
|
+
return {
|
|
495
|
+
type: "mdxjsEsm",
|
|
496
|
+
value: "",
|
|
497
|
+
data: {
|
|
498
|
+
estree: {
|
|
499
|
+
type: "Program",
|
|
500
|
+
sourceType: "module",
|
|
501
|
+
body: [
|
|
502
|
+
{
|
|
503
|
+
type: "ExportNamedDeclaration",
|
|
504
|
+
attributes: [],
|
|
505
|
+
specifiers: [],
|
|
506
|
+
source: null,
|
|
507
|
+
declaration: {
|
|
508
|
+
type: "VariableDeclaration",
|
|
509
|
+
kind: "let",
|
|
510
|
+
declarations: [
|
|
511
|
+
{
|
|
512
|
+
type: "VariableDeclarator",
|
|
513
|
+
id: {
|
|
514
|
+
type: "Identifier",
|
|
515
|
+
name
|
|
516
|
+
},
|
|
517
|
+
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
518
|
+
}
|
|
519
|
+
]
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
]
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
function flattenNode2(node) {
|
|
528
|
+
if ("children" in node)
|
|
529
|
+
return node.children.map((child) => flattenNode2(child)).join("");
|
|
530
|
+
if ("value" in node) return node.value;
|
|
531
|
+
return "";
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// src/mdx/build-mdx.ts
|
|
562
535
|
var cache3 = /* @__PURE__ */ new Map();
|
|
563
536
|
async function buildMDX(cacheKey, source, options) {
|
|
564
537
|
const { filePath, frontmatter, data, _compiler, ...rest } = options;
|
|
@@ -569,7 +542,24 @@ async function buildMDX(cacheKey, source, options) {
|
|
|
569
542
|
processor = (0, import_mdx.createProcessor)({
|
|
570
543
|
outputFormat: "program",
|
|
571
544
|
...rest,
|
|
572
|
-
remarkPlugins: [
|
|
545
|
+
remarkPlugins: [
|
|
546
|
+
remarkInclude,
|
|
547
|
+
...rest.remarkPlugins ?? [],
|
|
548
|
+
[
|
|
549
|
+
remarkPostprocess,
|
|
550
|
+
{
|
|
551
|
+
...options.postprocess,
|
|
552
|
+
valueToExport: [
|
|
553
|
+
...options.postprocess?.valueToExport ?? [],
|
|
554
|
+
"structuredData",
|
|
555
|
+
"extractedReferences",
|
|
556
|
+
"frontmatter",
|
|
557
|
+
"lastModified",
|
|
558
|
+
"_markdown"
|
|
559
|
+
]
|
|
560
|
+
}
|
|
561
|
+
]
|
|
562
|
+
],
|
|
573
563
|
format
|
|
574
564
|
});
|
|
575
565
|
cache3.set(key, processor);
|
|
@@ -625,21 +615,18 @@ function createMdxLoader(configLoader) {
|
|
|
625
615
|
if (cached && cached.hash === generateCacheHash(value)) return cached;
|
|
626
616
|
}
|
|
627
617
|
const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
|
|
628
|
-
let
|
|
629
|
-
let mdxOptions;
|
|
618
|
+
let docCollection;
|
|
630
619
|
switch (collection?.type) {
|
|
631
620
|
case "doc":
|
|
632
|
-
|
|
633
|
-
schema = collection.schema;
|
|
621
|
+
docCollection = collection;
|
|
634
622
|
break;
|
|
635
623
|
case "docs":
|
|
636
|
-
|
|
637
|
-
schema = collection.docs.schema;
|
|
624
|
+
docCollection = collection.docs;
|
|
638
625
|
break;
|
|
639
626
|
}
|
|
640
|
-
if (schema) {
|
|
627
|
+
if (docCollection?.schema) {
|
|
641
628
|
matter.data = await validate(
|
|
642
|
-
schema,
|
|
629
|
+
docCollection.schema,
|
|
643
630
|
matter.data,
|
|
644
631
|
{
|
|
645
632
|
source: value,
|
|
@@ -664,7 +651,8 @@ function createMdxLoader(configLoader) {
|
|
|
664
651
|
"\n".repeat(lineOffset) + matter.content,
|
|
665
652
|
{
|
|
666
653
|
development: isDevelopment,
|
|
667
|
-
...mdxOptions ?? await loaded.getDefaultMDXOptions(),
|
|
654
|
+
...docCollection?.mdxOptions ?? await loaded.getDefaultMDXOptions(),
|
|
655
|
+
postprocess: docCollection?.postprocess,
|
|
668
656
|
data,
|
|
669
657
|
filePath,
|
|
670
658
|
frontmatter: matter.data,
|
package/dist/node/loader.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
toNode
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-VXEBLM4X.js";
|
|
4
4
|
import {
|
|
5
5
|
createMdxLoader,
|
|
6
6
|
dynamicConfig
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-QQWCBFFE.js";
|
|
9
|
-
import "../chunk-SVTXMVLQ.js";
|
|
7
|
+
} from "../chunk-KGUBBRL6.js";
|
|
10
8
|
import "../chunk-IQAEAI4P.js";
|
|
11
9
|
import {
|
|
12
10
|
findConfigFile
|
|
13
|
-
} from "../chunk-
|
|
14
|
-
import "../chunk-
|
|
11
|
+
} from "../chunk-POXTQZ4D.js";
|
|
12
|
+
import "../chunk-SWNOXPYJ.js";
|
|
13
|
+
import "../chunk-KTDVTBMH.js";
|
|
14
|
+
import "../chunk-YC25YEBF.js";
|
|
15
15
|
import "../chunk-VWJKRQZR.js";
|
|
16
16
|
|
|
17
17
|
// src/node/loader.ts
|