fumadocs-mdx 11.8.1 → 11.8.3
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/{build-mdx-DMe0r3s_.d.cts → build-mdx-DnC1jKvn.d.cts} +6 -4
- package/dist/{build-mdx-DMe0r3s_.d.ts → build-mdx-DnC1jKvn.d.ts} +6 -4
- package/dist/{chunk-BCOXAJMC.js → chunk-BWRDVK5L.js} +1 -1
- package/dist/{chunk-7JFPDRW7.js → chunk-QQWCBFFE.js} +2 -4
- package/dist/{chunk-S73DGUHI.js → chunk-QVZ7JH4H.js} +1 -1
- package/dist/{chunk-DJNS22RO.js → chunk-SMSNZ6N5.js} +37 -23
- package/dist/chunk-SVTXMVLQ.js +139 -0
- package/dist/config/index.cjs +118 -84
- package/dist/config/index.d.cts +6 -2
- package/dist/config/index.d.ts +6 -2
- package/dist/config/index.js +2 -2
- package/dist/config/zod-3.cjs +118 -84
- package/dist/config/zod-3.d.cts +2 -2
- package/dist/config/zod-3.d.ts +2 -2
- package/dist/config/zod-3.js +2 -2
- package/dist/{define-DnJzAZrj.d.ts → define-DAZmbu3U.d.cts} +1 -1
- package/dist/{define-DnJzAZrj.d.cts → define-DAZmbu3U.d.ts} +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/loader-mdx.cjs +127 -102
- package/dist/loader-mdx.js +8 -8
- package/dist/{mdx-options-ILHLYYTL.js → mdx-options-T73E4LQB.js} +1 -1
- package/dist/next/index.cjs +43 -38
- package/dist/next/index.js +4 -6
- package/dist/runtime/async.cjs +121 -96
- package/dist/runtime/async.d.cts +3 -3
- package/dist/runtime/async.d.ts +3 -3
- package/dist/runtime/async.js +3 -3
- package/dist/runtime/vite.d.cts +2 -2
- package/dist/runtime/vite.d.ts +2 -2
- package/dist/{types-DvnkeVI3.d.cts → types-B2kQsHs7.d.cts} +2 -2
- package/dist/{types-zBRxlyaM.d.ts → types-CkmezNbX.d.ts} +2 -2
- package/dist/vite/index.cjs +136 -98
- package/dist/vite/index.js +18 -3
- package/package.json +10 -8
- package/dist/chunk-IGXZS2W6.js +0 -119
package/dist/vite/index.cjs
CHANGED
|
@@ -30,15 +30,40 @@ 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-plugins/remark-
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
// src/mdx-plugins/remark-postprocess.ts
|
|
34
|
+
function remarkPostprocess({
|
|
35
|
+
injectExports
|
|
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]));
|
|
39
58
|
}
|
|
40
59
|
};
|
|
41
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
|
+
}
|
|
42
67
|
function getMdastExport(name, value) {
|
|
43
68
|
return {
|
|
44
69
|
type: "mdxjsEsm",
|
|
@@ -50,6 +75,7 @@ function getMdastExport(name, value) {
|
|
|
50
75
|
body: [
|
|
51
76
|
{
|
|
52
77
|
type: "ExportNamedDeclaration",
|
|
78
|
+
attributes: [],
|
|
53
79
|
specifiers: [],
|
|
54
80
|
source: null,
|
|
55
81
|
declaration: {
|
|
@@ -72,32 +98,12 @@ function getMdastExport(name, value) {
|
|
|
72
98
|
}
|
|
73
99
|
};
|
|
74
100
|
}
|
|
75
|
-
var import_estree_util_value_to_estree;
|
|
76
|
-
var
|
|
77
|
-
"src/mdx-plugins/remark-
|
|
78
|
-
"use strict";
|
|
79
|
-
import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// src/mdx-plugins/remark-extract.ts
|
|
84
|
-
function remarkExtract() {
|
|
85
|
-
return (tree, file) => {
|
|
86
|
-
const urls = [];
|
|
87
|
-
(0, import_unist_util_visit.visit)(tree, "link", (node) => {
|
|
88
|
-
urls.push({
|
|
89
|
-
href: node.url
|
|
90
|
-
});
|
|
91
|
-
return "skip";
|
|
92
|
-
});
|
|
93
|
-
file.data.extractedReferences = urls;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
var import_unist_util_visit;
|
|
97
|
-
var init_remark_extract = __esm({
|
|
98
|
-
"src/mdx-plugins/remark-extract.ts"() {
|
|
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"() {
|
|
99
104
|
"use strict";
|
|
100
105
|
import_unist_util_visit = require("unist-util-visit");
|
|
106
|
+
import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
101
107
|
}
|
|
102
108
|
});
|
|
103
109
|
|
|
@@ -156,12 +162,14 @@ function getDefaultMDXOptions({
|
|
|
156
162
|
],
|
|
157
163
|
"remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
|
|
158
164
|
...v,
|
|
159
|
-
remarkExtract,
|
|
160
165
|
remarkStructureOptions !== false && [
|
|
161
166
|
plugins.remarkStructure,
|
|
162
167
|
remarkStructureOptions
|
|
163
168
|
],
|
|
164
|
-
[
|
|
169
|
+
[
|
|
170
|
+
remarkPostprocess,
|
|
171
|
+
{ injectExports: mdxExports }
|
|
172
|
+
]
|
|
165
173
|
],
|
|
166
174
|
mdxOptions.remarkPlugins
|
|
167
175
|
);
|
|
@@ -185,8 +193,7 @@ var init_mdx_options = __esm({
|
|
|
185
193
|
"src/utils/mdx-options.ts"() {
|
|
186
194
|
"use strict";
|
|
187
195
|
plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
188
|
-
|
|
189
|
-
init_remark_extract();
|
|
196
|
+
init_remark_postprocess();
|
|
190
197
|
}
|
|
191
198
|
});
|
|
192
199
|
|
|
@@ -196,6 +203,7 @@ __export(vite_exports, {
|
|
|
196
203
|
default: () => mdx
|
|
197
204
|
});
|
|
198
205
|
module.exports = __toCommonJS(vite_exports);
|
|
206
|
+
var import_vite = require("vite");
|
|
199
207
|
|
|
200
208
|
// src/config/build.ts
|
|
201
209
|
function buildConfig(config) {
|
|
@@ -251,6 +259,7 @@ function buildConfig(config) {
|
|
|
251
259
|
var import_mdx = require("@mdx-js/mdx");
|
|
252
260
|
|
|
253
261
|
// src/mdx-plugins/remark-include.ts
|
|
262
|
+
var import_unified = require("unified");
|
|
254
263
|
var import_unist_util_visit2 = require("unist-util-visit");
|
|
255
264
|
var path = __toESM(require("path"), 1);
|
|
256
265
|
var fs = __toESM(require("fs/promises"), 1);
|
|
@@ -272,9 +281,13 @@ function fumaMatter(input) {
|
|
|
272
281
|
}
|
|
273
282
|
|
|
274
283
|
// src/mdx-plugins/remark-include.ts
|
|
275
|
-
|
|
284
|
+
var import_remark_parse = __toESM(require("remark-parse"), 1);
|
|
285
|
+
var import_remark_mdx = __toESM(require("remark-mdx"), 1);
|
|
286
|
+
var import_mdx_plugins = require("fumadocs-core/mdx-plugins");
|
|
287
|
+
var baseProcessor = (0, import_unified.unified)().use(import_mdx_plugins.remarkHeading);
|
|
288
|
+
function flattenNode2(node) {
|
|
276
289
|
if ("children" in node)
|
|
277
|
-
return node.children.map((child) =>
|
|
290
|
+
return node.children.map((child) => flattenNode2(child)).join("");
|
|
278
291
|
if ("value" in node) return node.value;
|
|
279
292
|
return "";
|
|
280
293
|
}
|
|
@@ -287,86 +300,96 @@ function parseSpecifier(specifier) {
|
|
|
287
300
|
};
|
|
288
301
|
}
|
|
289
302
|
function extractSection(root, section) {
|
|
303
|
+
let nodes;
|
|
290
304
|
for (const node of root.children) {
|
|
291
305
|
if (node.type === "mdxJsxFlowElement" && node.name === "section" && node.attributes.some(
|
|
292
306
|
(attr) => attr.type === "mdxJsxAttribute" && attr.name === "id" && attr.value === section
|
|
293
307
|
)) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
children: node.children
|
|
297
|
-
};
|
|
308
|
+
nodes = node.children;
|
|
309
|
+
break;
|
|
298
310
|
}
|
|
311
|
+
if (node.type === "heading" && node.data?.hProperties?.id === section) {
|
|
312
|
+
nodes = [node];
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (!nodes) continue;
|
|
316
|
+
if (node.type === "heading") break;
|
|
317
|
+
nodes.push(node);
|
|
299
318
|
}
|
|
319
|
+
if (nodes)
|
|
320
|
+
return {
|
|
321
|
+
type: "root",
|
|
322
|
+
children: nodes
|
|
323
|
+
};
|
|
300
324
|
}
|
|
301
325
|
function remarkInclude() {
|
|
302
326
|
const TagName = "include";
|
|
327
|
+
async function embedContent(file, heading, params, data) {
|
|
328
|
+
let content;
|
|
329
|
+
try {
|
|
330
|
+
content = (await fs.readFile(file)).toString();
|
|
331
|
+
} catch (e) {
|
|
332
|
+
throw new Error(
|
|
333
|
+
`failed to read file ${file}
|
|
334
|
+
${e instanceof Error ? e.message : String(e)}`,
|
|
335
|
+
{ cause: e }
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
const ext = path.extname(file);
|
|
339
|
+
data._compiler?.addDependency(file);
|
|
340
|
+
if (params.lang || ext !== ".md" && ext !== ".mdx") {
|
|
341
|
+
const lang = params.lang ?? ext.slice(1);
|
|
342
|
+
return {
|
|
343
|
+
type: "code",
|
|
344
|
+
lang,
|
|
345
|
+
meta: params.meta,
|
|
346
|
+
value: content,
|
|
347
|
+
data: {}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
const processor = (data._getProcessor ?? getDefaultProcessor)(
|
|
351
|
+
ext === ".mdx" ? "mdx" : "md"
|
|
352
|
+
);
|
|
353
|
+
let parsed = await baseProcessor.run(
|
|
354
|
+
processor.parse(fumaMatter(content).content)
|
|
355
|
+
);
|
|
356
|
+
if (heading) {
|
|
357
|
+
const extracted = extractSection(parsed, heading);
|
|
358
|
+
if (!extracted)
|
|
359
|
+
throw new Error(
|
|
360
|
+
`Cannot find section ${heading} in ${file}, make sure you have encapsulated the section in a <section id="${heading}"> tag.`
|
|
361
|
+
);
|
|
362
|
+
parsed = extracted;
|
|
363
|
+
}
|
|
364
|
+
await update(parsed, path.dirname(file), data);
|
|
365
|
+
return parsed;
|
|
366
|
+
}
|
|
303
367
|
async function update(tree, directory, data) {
|
|
304
368
|
const queue = [];
|
|
305
369
|
(0, import_unist_util_visit2.visit)(
|
|
306
370
|
tree,
|
|
307
371
|
["mdxJsxFlowElement", "mdxJsxTextElement"],
|
|
308
|
-
(
|
|
309
|
-
|
|
372
|
+
(_node, _, parent) => {
|
|
373
|
+
const node = _node;
|
|
374
|
+
if (node.name !== TagName) return;
|
|
310
375
|
const params = {};
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
params[attr.name] = attr.value;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
specifier = value;
|
|
376
|
+
const specifier = flattenNode2(node);
|
|
377
|
+
if (specifier.length === 0) return "skip";
|
|
378
|
+
for (const attr of node.attributes) {
|
|
379
|
+
if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
|
|
380
|
+
params[attr.name] = attr.value;
|
|
320
381
|
}
|
|
321
382
|
}
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
const targetPath = path.resolve(
|
|
383
|
+
const { file: relativePath, section } = parseSpecifier(specifier);
|
|
384
|
+
const file = path.resolve(
|
|
325
385
|
"cwd" in params ? process.cwd() : directory,
|
|
326
|
-
|
|
386
|
+
relativePath
|
|
327
387
|
);
|
|
328
|
-
const asCode = params.lang || !file.endsWith(".md") && !file.endsWith(".mdx");
|
|
329
388
|
queue.push(
|
|
330
|
-
|
|
331
|
-
data._compiler?.addDependency(targetPath);
|
|
332
|
-
if (asCode) {
|
|
333
|
-
const lang = params.lang ?? path.extname(file).slice(1);
|
|
334
|
-
Object.assign(node, {
|
|
335
|
-
type: "code",
|
|
336
|
-
lang,
|
|
337
|
-
meta: params.meta,
|
|
338
|
-
value: content,
|
|
339
|
-
data: {}
|
|
340
|
-
});
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
const processor = data._processor ? data._processor.getProcessor(
|
|
344
|
-
targetPath.endsWith(".md") ? "md" : "mdx"
|
|
345
|
-
) : this;
|
|
346
|
-
let parsed = processor.parse(fumaMatter(content).content);
|
|
347
|
-
if (section) {
|
|
348
|
-
const extracted = extractSection(parsed, section);
|
|
349
|
-
if (!extracted)
|
|
350
|
-
throw new Error(
|
|
351
|
-
`Cannot find section ${section} in ${file}, make sure you have encapsulated the section in a <section id="${section}"> tag`
|
|
352
|
-
);
|
|
353
|
-
parsed = extracted;
|
|
354
|
-
}
|
|
355
|
-
await update.call(
|
|
356
|
-
processor,
|
|
357
|
-
parsed,
|
|
358
|
-
path.dirname(targetPath),
|
|
359
|
-
data
|
|
360
|
-
);
|
|
389
|
+
embedContent(file, section, params, data).then((replace) => {
|
|
361
390
|
Object.assign(
|
|
362
391
|
parent && parent.type === "paragraph" ? parent : node,
|
|
363
|
-
|
|
364
|
-
);
|
|
365
|
-
}).catch((e) => {
|
|
366
|
-
throw new Error(
|
|
367
|
-
`failed to read file ${targetPath}
|
|
368
|
-
${e instanceof Error ? e.message : String(e)}`,
|
|
369
|
-
{ cause: e }
|
|
392
|
+
replace
|
|
370
393
|
);
|
|
371
394
|
})
|
|
372
395
|
);
|
|
@@ -376,9 +399,14 @@ ${e instanceof Error ? e.message : String(e)}`,
|
|
|
376
399
|
await Promise.all(queue);
|
|
377
400
|
}
|
|
378
401
|
return async (tree, file) => {
|
|
379
|
-
await update
|
|
402
|
+
await update(tree, path.dirname(file.path), file.data);
|
|
380
403
|
};
|
|
381
404
|
}
|
|
405
|
+
function getDefaultProcessor(format) {
|
|
406
|
+
const mdProcessor = (0, import_unified.unified)().use(import_remark_parse.default);
|
|
407
|
+
if (format === "md") return mdProcessor;
|
|
408
|
+
return mdProcessor.use(import_remark_mdx.default);
|
|
409
|
+
}
|
|
382
410
|
|
|
383
411
|
// src/utils/build-mdx.ts
|
|
384
412
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -407,9 +435,7 @@ async function buildMDX(cacheKey, source, options) {
|
|
|
407
435
|
...data,
|
|
408
436
|
frontmatter,
|
|
409
437
|
_compiler,
|
|
410
|
-
|
|
411
|
-
getProcessor
|
|
412
|
-
}
|
|
438
|
+
_getProcessor: getProcessor
|
|
413
439
|
}
|
|
414
440
|
});
|
|
415
441
|
}
|
|
@@ -597,6 +623,7 @@ function meta(name, collection) {
|
|
|
597
623
|
}
|
|
598
624
|
|
|
599
625
|
// src/vite/index.ts
|
|
626
|
+
var FumadocsDeps = ["fumadocs-core", "fumadocs-ui", "fumadocs-openapi"];
|
|
600
627
|
var querySchema = import_zod.z.object({
|
|
601
628
|
only: import_zod.z.literal(["frontmatter", "all"]).default("all"),
|
|
602
629
|
collection: import_zod.z.string().optional()
|
|
@@ -701,6 +728,17 @@ function mdx(config, options = {}) {
|
|
|
701
728
|
name: "fumadocs-mdx",
|
|
702
729
|
// needed, otherwise other plugins will be executed before our `transform`.
|
|
703
730
|
enforce: "pre",
|
|
731
|
+
config(config2) {
|
|
732
|
+
return (0, import_vite.mergeConfig)(config2, {
|
|
733
|
+
optimizeDeps: {
|
|
734
|
+
exclude: FumadocsDeps
|
|
735
|
+
},
|
|
736
|
+
resolve: {
|
|
737
|
+
noExternal: FumadocsDeps,
|
|
738
|
+
dedupe: FumadocsDeps
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
},
|
|
704
742
|
async buildStart() {
|
|
705
743
|
if (!generateIndexFile) return;
|
|
706
744
|
console.log("[Fumadocs MDX] Generating index files");
|
package/dist/vite/index.js
CHANGED
|
@@ -13,16 +13,19 @@ import {
|
|
|
13
13
|
} from "../chunk-GX3THK2Q.js";
|
|
14
14
|
import {
|
|
15
15
|
buildMDX
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-IGXZS2W6.js";
|
|
16
|
+
} from "../chunk-QQWCBFFE.js";
|
|
18
17
|
import {
|
|
19
18
|
buildConfig
|
|
20
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-QVZ7JH4H.js";
|
|
20
|
+
import "../chunk-SVTXMVLQ.js";
|
|
21
21
|
import {
|
|
22
22
|
fumaMatter
|
|
23
23
|
} from "../chunk-VWJKRQZR.js";
|
|
24
24
|
|
|
25
25
|
// src/vite/index.ts
|
|
26
|
+
import {
|
|
27
|
+
mergeConfig
|
|
28
|
+
} from "vite";
|
|
26
29
|
import { parse } from "querystring";
|
|
27
30
|
import { z } from "zod";
|
|
28
31
|
import * as fs from "fs/promises";
|
|
@@ -92,6 +95,7 @@ function meta(name, collection) {
|
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
// src/vite/index.ts
|
|
98
|
+
var FumadocsDeps = ["fumadocs-core", "fumadocs-ui", "fumadocs-openapi"];
|
|
95
99
|
var querySchema = z.object({
|
|
96
100
|
only: z.literal(["frontmatter", "all"]).default("all"),
|
|
97
101
|
collection: z.string().optional()
|
|
@@ -196,6 +200,17 @@ function mdx(config, options = {}) {
|
|
|
196
200
|
name: "fumadocs-mdx",
|
|
197
201
|
// needed, otherwise other plugins will be executed before our `transform`.
|
|
198
202
|
enforce: "pre",
|
|
203
|
+
config(config2) {
|
|
204
|
+
return mergeConfig(config2, {
|
|
205
|
+
optimizeDeps: {
|
|
206
|
+
exclude: FumadocsDeps
|
|
207
|
+
},
|
|
208
|
+
resolve: {
|
|
209
|
+
noExternal: FumadocsDeps,
|
|
210
|
+
dedupe: FumadocsDeps
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
},
|
|
199
214
|
async buildStart() {
|
|
200
215
|
if (!generateIndexFile) return;
|
|
201
216
|
console.log("[Fumadocs MDX] Generating index files");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "11.8.
|
|
3
|
+
"version": "11.8.3",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"bin.js"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@mdx-js/mdx": "^3.1.
|
|
59
|
+
"@mdx-js/mdx": "^3.1.1",
|
|
60
60
|
"@standard-schema/spec": "^1.0.0",
|
|
61
61
|
"chokidar": "^4.0.3",
|
|
62
62
|
"esbuild": "^0.25.9",
|
|
@@ -64,28 +64,30 @@
|
|
|
64
64
|
"js-yaml": "^4.1.0",
|
|
65
65
|
"lru-cache": "^11.1.0",
|
|
66
66
|
"picocolors": "^1.1.1",
|
|
67
|
+
"remark-mdx": "^3.1.1",
|
|
68
|
+
"remark-parse": "^11.0.0",
|
|
67
69
|
"tinyexec": "^1.0.1",
|
|
68
70
|
"tinyglobby": "^0.2.14",
|
|
71
|
+
"unified": "^11.0.5",
|
|
69
72
|
"unist-util-visit": "^5.0.0",
|
|
70
|
-
"zod": "^4.1.
|
|
73
|
+
"zod": "^4.1.5"
|
|
71
74
|
},
|
|
72
75
|
"devDependencies": {
|
|
73
76
|
"@types/js-yaml": "^4.0.9",
|
|
74
77
|
"@types/mdast": "^4.0.3",
|
|
75
78
|
"@types/mdx": "^2.0.13",
|
|
76
79
|
"@types/node": "^24.3.0",
|
|
77
|
-
"@types/react": "^19.1.
|
|
80
|
+
"@types/react": "^19.1.12",
|
|
78
81
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
79
|
-
"next": "^15.5.
|
|
82
|
+
"next": "^15.5.2",
|
|
80
83
|
"react": "^19.1.1",
|
|
81
|
-
"rollup": "^4.
|
|
82
|
-
"unified": "^11.0.5",
|
|
84
|
+
"rollup": "^4.50.0",
|
|
83
85
|
"vfile": "^6.0.3",
|
|
84
86
|
"vite": "^7.1.3",
|
|
85
87
|
"webpack": "^5.101.3",
|
|
86
88
|
"@fumadocs/mdx-remote": "1.4.0",
|
|
87
89
|
"eslint-config-custom": "0.0.0",
|
|
88
|
-
"fumadocs-core": "15.7.
|
|
90
|
+
"fumadocs-core": "15.7.8",
|
|
89
91
|
"tsconfig": "0.0.0"
|
|
90
92
|
},
|
|
91
93
|
"peerDependencies": {
|
package/dist/chunk-IGXZS2W6.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fumaMatter
|
|
3
|
-
} from "./chunk-VWJKRQZR.js";
|
|
4
|
-
|
|
5
|
-
// src/mdx-plugins/remark-include.ts
|
|
6
|
-
import { visit } from "unist-util-visit";
|
|
7
|
-
import * as path from "path";
|
|
8
|
-
import * as fs from "fs/promises";
|
|
9
|
-
function flattenNode(node) {
|
|
10
|
-
if ("children" in node)
|
|
11
|
-
return node.children.map((child) => flattenNode(child)).join("");
|
|
12
|
-
if ("value" in node) return node.value;
|
|
13
|
-
return "";
|
|
14
|
-
}
|
|
15
|
-
function parseSpecifier(specifier) {
|
|
16
|
-
const idx = specifier.lastIndexOf("#");
|
|
17
|
-
if (idx === -1) return { file: specifier };
|
|
18
|
-
return {
|
|
19
|
-
file: specifier.slice(0, idx),
|
|
20
|
-
section: specifier.slice(idx + 1)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function extractSection(root, section) {
|
|
24
|
-
for (const node of root.children) {
|
|
25
|
-
if (node.type === "mdxJsxFlowElement" && node.name === "section" && node.attributes.some(
|
|
26
|
-
(attr) => attr.type === "mdxJsxAttribute" && attr.name === "id" && attr.value === section
|
|
27
|
-
)) {
|
|
28
|
-
return {
|
|
29
|
-
type: "root",
|
|
30
|
-
children: node.children
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function remarkInclude() {
|
|
36
|
-
const TagName = "include";
|
|
37
|
-
async function update(tree, directory, data) {
|
|
38
|
-
const queue = [];
|
|
39
|
-
visit(
|
|
40
|
-
tree,
|
|
41
|
-
["mdxJsxFlowElement", "mdxJsxTextElement"],
|
|
42
|
-
(node, _, parent) => {
|
|
43
|
-
let specifier;
|
|
44
|
-
const params = {};
|
|
45
|
-
if ((node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && node.name === TagName) {
|
|
46
|
-
const value = flattenNode(node);
|
|
47
|
-
if (value.length > 0) {
|
|
48
|
-
for (const attr of node.attributes) {
|
|
49
|
-
if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
|
|
50
|
-
params[attr.name] = attr.value;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
specifier = value;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (!specifier) return;
|
|
57
|
-
const { file, section } = parseSpecifier(specifier);
|
|
58
|
-
const targetPath = path.resolve(
|
|
59
|
-
"cwd" in params ? process.cwd() : directory,
|
|
60
|
-
file
|
|
61
|
-
);
|
|
62
|
-
const asCode = params.lang || !file.endsWith(".md") && !file.endsWith(".mdx");
|
|
63
|
-
queue.push(
|
|
64
|
-
fs.readFile(targetPath).then((buffer) => buffer.toString()).then(async (content) => {
|
|
65
|
-
data._compiler?.addDependency(targetPath);
|
|
66
|
-
if (asCode) {
|
|
67
|
-
const lang = params.lang ?? path.extname(file).slice(1);
|
|
68
|
-
Object.assign(node, {
|
|
69
|
-
type: "code",
|
|
70
|
-
lang,
|
|
71
|
-
meta: params.meta,
|
|
72
|
-
value: content,
|
|
73
|
-
data: {}
|
|
74
|
-
});
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const processor = data._processor ? data._processor.getProcessor(
|
|
78
|
-
targetPath.endsWith(".md") ? "md" : "mdx"
|
|
79
|
-
) : this;
|
|
80
|
-
let parsed = processor.parse(fumaMatter(content).content);
|
|
81
|
-
if (section) {
|
|
82
|
-
const extracted = extractSection(parsed, section);
|
|
83
|
-
if (!extracted)
|
|
84
|
-
throw new Error(
|
|
85
|
-
`Cannot find section ${section} in ${file}, make sure you have encapsulated the section in a <section id="${section}"> tag`
|
|
86
|
-
);
|
|
87
|
-
parsed = extracted;
|
|
88
|
-
}
|
|
89
|
-
await update.call(
|
|
90
|
-
processor,
|
|
91
|
-
parsed,
|
|
92
|
-
path.dirname(targetPath),
|
|
93
|
-
data
|
|
94
|
-
);
|
|
95
|
-
Object.assign(
|
|
96
|
-
parent && parent.type === "paragraph" ? parent : node,
|
|
97
|
-
parsed
|
|
98
|
-
);
|
|
99
|
-
}).catch((e) => {
|
|
100
|
-
throw new Error(
|
|
101
|
-
`failed to read file ${targetPath}
|
|
102
|
-
${e instanceof Error ? e.message : String(e)}`,
|
|
103
|
-
{ cause: e }
|
|
104
|
-
);
|
|
105
|
-
})
|
|
106
|
-
);
|
|
107
|
-
return "skip";
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
await Promise.all(queue);
|
|
111
|
-
}
|
|
112
|
-
return async (tree, file) => {
|
|
113
|
-
await update.call(this, tree, path.dirname(file.path), file.data);
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export {
|
|
118
|
-
remarkInclude
|
|
119
|
-
};
|