fumadocs-mdx 11.6.8 → 11.6.10
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-VC3Y6FLZ.js → chunk-64MMPGML.js} +12 -2
- package/dist/chunk-6PDS7MUA.js +49 -0
- package/dist/{chunk-KTLWF7GN.js → chunk-AVMO2SRO.js} +1 -1
- package/dist/chunk-KVWX6THC.js +19 -0
- package/dist/config/index.cjs +19 -30
- package/dist/config/index.d.cts +3 -2
- package/dist/config/index.d.ts +3 -2
- package/dist/config/index.js +6 -6
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/loader-mdx.cjs +145 -183
- package/dist/loader-mdx.js +9 -56
- package/dist/next/index.cjs +33 -40
- package/dist/next/index.js +28 -14
- package/dist/runtime/async.cjs +9 -30
- package/dist/runtime/async.d.cts +5 -5
- package/dist/runtime/async.d.ts +5 -5
- package/dist/runtime/async.js +2 -2
- package/dist/{types-BYJBKH4G.d.ts → types-Dk7DhSKZ.d.ts} +2 -15
- package/dist/{define-uoePrCQ_.d.ts → types-DvTNxAvo.d.cts} +67 -54
- package/dist/{define-uoePrCQ_.d.cts → types-DvTNxAvo.d.ts} +67 -54
- package/dist/{types-BsJd_P5O.d.cts → types-ZwLebhOl.d.cts} +2 -15
- package/dist/vite/index.cjs +384 -0
- package/dist/vite/index.d.cts +8 -0
- package/dist/vite/index.d.ts +8 -0
- package/dist/vite/index.js +71 -0
- package/package.json +19 -6
- package/dist/chunk-MXACIHNJ.js +0 -40
- package/dist/mdx-options-YGL3EP3M.js +0 -6
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/vite/index.ts
|
|
31
|
+
var vite_exports = {};
|
|
32
|
+
__export(vite_exports, {
|
|
33
|
+
default: () => unstable_mdx
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(vite_exports);
|
|
36
|
+
|
|
37
|
+
// src/config/build.ts
|
|
38
|
+
function buildConfig(config) {
|
|
39
|
+
const collections = /* @__PURE__ */ new Map();
|
|
40
|
+
let globalConfig;
|
|
41
|
+
for (const [k, v] of Object.entries(config)) {
|
|
42
|
+
if (!v) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (typeof v === "object" && "type" in v) {
|
|
46
|
+
if (v.type === "docs") {
|
|
47
|
+
collections.set(k, v);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (v.type === "doc" || v.type === "meta") {
|
|
51
|
+
collections.set(k, v);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (k === "default") {
|
|
56
|
+
globalConfig = v;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
return [
|
|
60
|
+
`Unknown export "${k}", you can only export collections from source configuration file.`,
|
|
61
|
+
null
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
return [
|
|
65
|
+
null,
|
|
66
|
+
{
|
|
67
|
+
global: globalConfig,
|
|
68
|
+
collections
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/utils/build-mdx.ts
|
|
74
|
+
var import_mdx = require("@mdx-js/mdx");
|
|
75
|
+
|
|
76
|
+
// src/mdx-plugins/remark-include.ts
|
|
77
|
+
var import_unist_util_visit = require("unist-util-visit");
|
|
78
|
+
var path = __toESM(require("path"), 1);
|
|
79
|
+
var fs = __toESM(require("fs/promises"), 1);
|
|
80
|
+
|
|
81
|
+
// src/utils/fuma-matter.ts
|
|
82
|
+
var import_js_yaml = require("js-yaml");
|
|
83
|
+
var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
|
|
84
|
+
function fumaMatter(input) {
|
|
85
|
+
const output = { matter: "", data: {}, content: input };
|
|
86
|
+
const match = regex.exec(input);
|
|
87
|
+
if (!match) {
|
|
88
|
+
return output;
|
|
89
|
+
}
|
|
90
|
+
output.matter = match[1];
|
|
91
|
+
output.content = input.slice(match[0].length);
|
|
92
|
+
const loaded = (0, import_js_yaml.load)(output.matter);
|
|
93
|
+
output.data = loaded ?? {};
|
|
94
|
+
return output;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/mdx-plugins/remark-include.ts
|
|
98
|
+
function flattenNode(node) {
|
|
99
|
+
if ("children" in node)
|
|
100
|
+
return node.children.map((child) => flattenNode(child)).join("");
|
|
101
|
+
if ("value" in node) return node.value;
|
|
102
|
+
return "";
|
|
103
|
+
}
|
|
104
|
+
function remarkInclude() {
|
|
105
|
+
const TagName = "include";
|
|
106
|
+
async function update(tree, file, processor, compiler) {
|
|
107
|
+
const queue = [];
|
|
108
|
+
(0, import_unist_util_visit.visit)(
|
|
109
|
+
tree,
|
|
110
|
+
["mdxJsxFlowElement", "mdxJsxTextElement"],
|
|
111
|
+
(node, _, parent) => {
|
|
112
|
+
let specifier;
|
|
113
|
+
const params = {};
|
|
114
|
+
if ((node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && node.name === TagName) {
|
|
115
|
+
const value = flattenNode(node);
|
|
116
|
+
if (value.length > 0) {
|
|
117
|
+
for (const attr of node.attributes) {
|
|
118
|
+
if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
|
|
119
|
+
params[attr.name] = attr.value;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
specifier = value;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (!specifier) return;
|
|
126
|
+
const targetPath = path.resolve(
|
|
127
|
+
"cwd" in params ? process.cwd() : path.dirname(file),
|
|
128
|
+
specifier
|
|
129
|
+
);
|
|
130
|
+
const asCode = params.lang || !specifier.endsWith(".md") && !specifier.endsWith(".mdx");
|
|
131
|
+
queue.push(
|
|
132
|
+
fs.readFile(targetPath).then((buffer) => buffer.toString()).then(async (content) => {
|
|
133
|
+
compiler?.addDependency(targetPath);
|
|
134
|
+
if (asCode) {
|
|
135
|
+
const lang = params.lang ?? path.extname(specifier).slice(1);
|
|
136
|
+
Object.assign(node, {
|
|
137
|
+
type: "code",
|
|
138
|
+
lang,
|
|
139
|
+
meta: params.meta,
|
|
140
|
+
value: content.toString(),
|
|
141
|
+
data: {}
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const parsed = processor.parse(fumaMatter(content).content);
|
|
146
|
+
await update(parsed, targetPath, processor, compiler);
|
|
147
|
+
Object.assign(
|
|
148
|
+
parent && parent.type === "paragraph" ? parent : node,
|
|
149
|
+
parsed
|
|
150
|
+
);
|
|
151
|
+
}).catch((e) => {
|
|
152
|
+
throw new Error(
|
|
153
|
+
`failed to read file ${targetPath}
|
|
154
|
+
${e instanceof Error ? e.message : String(e)}`
|
|
155
|
+
);
|
|
156
|
+
})
|
|
157
|
+
);
|
|
158
|
+
return "skip";
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
await Promise.all(queue);
|
|
162
|
+
}
|
|
163
|
+
return async (tree, file) => {
|
|
164
|
+
await update(tree, file.path, this, file.data._compiler);
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// src/utils/build-mdx.ts
|
|
169
|
+
var cache = /* @__PURE__ */ new Map();
|
|
170
|
+
async function buildMDX(cacheKey, source, options) {
|
|
171
|
+
const { filePath, frontmatter, data, ...rest } = options;
|
|
172
|
+
let format = options.format;
|
|
173
|
+
if (!format && filePath) {
|
|
174
|
+
format = filePath.endsWith(".mdx") ? "mdx" : "md";
|
|
175
|
+
}
|
|
176
|
+
format ??= "mdx";
|
|
177
|
+
const key = `${cacheKey}:${format}`;
|
|
178
|
+
let cached = cache.get(key);
|
|
179
|
+
if (!cached) {
|
|
180
|
+
cached = (0, import_mdx.createProcessor)({
|
|
181
|
+
outputFormat: "program",
|
|
182
|
+
...rest,
|
|
183
|
+
remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
|
|
184
|
+
format
|
|
185
|
+
});
|
|
186
|
+
cache.set(key, cached);
|
|
187
|
+
}
|
|
188
|
+
return cached.process({
|
|
189
|
+
value: source,
|
|
190
|
+
path: filePath,
|
|
191
|
+
data: {
|
|
192
|
+
...data,
|
|
193
|
+
frontmatter,
|
|
194
|
+
_compiler: options._compiler
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// src/vite/index.ts
|
|
200
|
+
var import_node_querystring = require("querystring");
|
|
201
|
+
|
|
202
|
+
// src/utils/count-lines.ts
|
|
203
|
+
function countLines(s) {
|
|
204
|
+
let num = 0;
|
|
205
|
+
for (const c of s) {
|
|
206
|
+
if (c === "\n") num++;
|
|
207
|
+
}
|
|
208
|
+
return num;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// src/utils/mdx-options.ts
|
|
212
|
+
var plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
213
|
+
|
|
214
|
+
// src/mdx-plugins/remark-exports.ts
|
|
215
|
+
var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
216
|
+
function remarkMdxExport({ values }) {
|
|
217
|
+
return (tree, vfile) => {
|
|
218
|
+
for (const name of values) {
|
|
219
|
+
if (!(name in vfile.data)) return;
|
|
220
|
+
tree.children.unshift(getMdastExport(name, vfile.data[name]));
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function getMdastExport(name, value) {
|
|
225
|
+
return {
|
|
226
|
+
type: "mdxjsEsm",
|
|
227
|
+
value: "",
|
|
228
|
+
data: {
|
|
229
|
+
estree: {
|
|
230
|
+
type: "Program",
|
|
231
|
+
sourceType: "module",
|
|
232
|
+
body: [
|
|
233
|
+
{
|
|
234
|
+
type: "ExportNamedDeclaration",
|
|
235
|
+
specifiers: [],
|
|
236
|
+
source: null,
|
|
237
|
+
declaration: {
|
|
238
|
+
type: "VariableDeclaration",
|
|
239
|
+
kind: "let",
|
|
240
|
+
declarations: [
|
|
241
|
+
{
|
|
242
|
+
type: "VariableDeclarator",
|
|
243
|
+
id: {
|
|
244
|
+
type: "Identifier",
|
|
245
|
+
name
|
|
246
|
+
},
|
|
247
|
+
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// src/utils/mdx-options.ts
|
|
259
|
+
function pluginOption(def, options = []) {
|
|
260
|
+
const list = def(Array.isArray(options) ? options : []).filter(
|
|
261
|
+
Boolean
|
|
262
|
+
);
|
|
263
|
+
if (typeof options === "function") {
|
|
264
|
+
return options(list);
|
|
265
|
+
}
|
|
266
|
+
return list;
|
|
267
|
+
}
|
|
268
|
+
function getDefaultMDXOptions({
|
|
269
|
+
valueToExport = [],
|
|
270
|
+
rehypeCodeOptions,
|
|
271
|
+
remarkImageOptions,
|
|
272
|
+
remarkHeadingOptions,
|
|
273
|
+
remarkStructureOptions,
|
|
274
|
+
remarkCodeTabOptions,
|
|
275
|
+
remarkNpmOptions,
|
|
276
|
+
...mdxOptions
|
|
277
|
+
}) {
|
|
278
|
+
const mdxExports = [
|
|
279
|
+
"structuredData",
|
|
280
|
+
"frontmatter",
|
|
281
|
+
"lastModified",
|
|
282
|
+
...valueToExport
|
|
283
|
+
];
|
|
284
|
+
const remarkPlugins = pluginOption(
|
|
285
|
+
(v) => [
|
|
286
|
+
plugins.remarkGfm,
|
|
287
|
+
[
|
|
288
|
+
plugins.remarkHeading,
|
|
289
|
+
{
|
|
290
|
+
generateToc: false,
|
|
291
|
+
...remarkHeadingOptions
|
|
292
|
+
}
|
|
293
|
+
],
|
|
294
|
+
remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
|
|
295
|
+
"remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
|
|
296
|
+
plugins.remarkCodeTab,
|
|
297
|
+
remarkCodeTabOptions
|
|
298
|
+
],
|
|
299
|
+
"remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
|
|
300
|
+
...v,
|
|
301
|
+
remarkStructureOptions !== false && [
|
|
302
|
+
plugins.remarkStructure,
|
|
303
|
+
remarkStructureOptions
|
|
304
|
+
],
|
|
305
|
+
[remarkMdxExport, { values: mdxExports }]
|
|
306
|
+
],
|
|
307
|
+
mdxOptions.remarkPlugins
|
|
308
|
+
);
|
|
309
|
+
const rehypePlugins = pluginOption(
|
|
310
|
+
(v) => [
|
|
311
|
+
rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
|
|
312
|
+
...v,
|
|
313
|
+
plugins.rehypeToc
|
|
314
|
+
],
|
|
315
|
+
mdxOptions.rehypePlugins
|
|
316
|
+
);
|
|
317
|
+
return {
|
|
318
|
+
...mdxOptions,
|
|
319
|
+
remarkPlugins,
|
|
320
|
+
rehypePlugins
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
async function loadDefaultOptions(config) {
|
|
324
|
+
const input = config.global?.mdxOptions;
|
|
325
|
+
config._mdx_loader ??= {};
|
|
326
|
+
const mdxLoader = config._mdx_loader;
|
|
327
|
+
if (!mdxLoader.cachedOptions) {
|
|
328
|
+
mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions(await input()) : getDefaultMDXOptions(input ?? {});
|
|
329
|
+
}
|
|
330
|
+
return mdxLoader.cachedOptions;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// src/vite/index.ts
|
|
334
|
+
var fileRegex = /\.(md|mdx)$/;
|
|
335
|
+
function unstable_mdx(config, _options = {}) {
|
|
336
|
+
const [err, loaded] = buildConfig(config);
|
|
337
|
+
if (err || !loaded) {
|
|
338
|
+
throw new Error(err);
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
name: "fumadocs-mdx",
|
|
342
|
+
// TODO: need a way to generate .source folder that works for non-RSC based frameworks, currently, we need to dynamic import MDX files using `import.meta.glob`.
|
|
343
|
+
// at the moment, RR and Tanstack Start has no stable support for RSC yet.
|
|
344
|
+
async transform(value, id) {
|
|
345
|
+
const [path2, query = ""] = id.split("?");
|
|
346
|
+
if (!fileRegex.test(path2)) return;
|
|
347
|
+
const matter = fumaMatter(value);
|
|
348
|
+
const isDevelopment = this.environment.mode === "dev";
|
|
349
|
+
const { collection: collectionId, raw } = (0, import_node_querystring.parse)(query);
|
|
350
|
+
const collection = collectionId ? loaded.collections.get(collectionId) : void 0;
|
|
351
|
+
const lineOffset = "\n".repeat(
|
|
352
|
+
isDevelopment ? countLines(matter.matter) : 0
|
|
353
|
+
);
|
|
354
|
+
let mdxOptions;
|
|
355
|
+
switch (collection?.type) {
|
|
356
|
+
case "doc":
|
|
357
|
+
mdxOptions = collection.mdxOptions;
|
|
358
|
+
break;
|
|
359
|
+
case "docs":
|
|
360
|
+
mdxOptions = collection.docs.mdxOptions;
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
mdxOptions ??= await loadDefaultOptions(loaded);
|
|
364
|
+
const file = await buildMDX(
|
|
365
|
+
collectionId ?? "global",
|
|
366
|
+
lineOffset + matter.content,
|
|
367
|
+
{
|
|
368
|
+
development: isDevelopment,
|
|
369
|
+
...mdxOptions,
|
|
370
|
+
filePath: path2,
|
|
371
|
+
frontmatter: matter.data,
|
|
372
|
+
_compiler: {
|
|
373
|
+
addDependency: (file2) => {
|
|
374
|
+
this.addWatchFile(file2);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
);
|
|
379
|
+
return {
|
|
380
|
+
code: typeof raw === "string" ? `export default ${JSON.stringify(file.value)}` : String(file.value)
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildMDX,
|
|
3
|
+
countLines
|
|
4
|
+
} from "../chunk-6PDS7MUA.js";
|
|
5
|
+
import {
|
|
6
|
+
loadDefaultOptions
|
|
7
|
+
} from "../chunk-64MMPGML.js";
|
|
8
|
+
import "../chunk-AVMO2SRO.js";
|
|
9
|
+
import {
|
|
10
|
+
buildConfig
|
|
11
|
+
} from "../chunk-DRVUBK5B.js";
|
|
12
|
+
import {
|
|
13
|
+
fumaMatter
|
|
14
|
+
} from "../chunk-KVWX6THC.js";
|
|
15
|
+
|
|
16
|
+
// src/vite/index.ts
|
|
17
|
+
import { parse } from "querystring";
|
|
18
|
+
var fileRegex = /\.(md|mdx)$/;
|
|
19
|
+
function unstable_mdx(config, _options = {}) {
|
|
20
|
+
const [err, loaded] = buildConfig(config);
|
|
21
|
+
if (err || !loaded) {
|
|
22
|
+
throw new Error(err);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
name: "fumadocs-mdx",
|
|
26
|
+
// TODO: need a way to generate .source folder that works for non-RSC based frameworks, currently, we need to dynamic import MDX files using `import.meta.glob`.
|
|
27
|
+
// at the moment, RR and Tanstack Start has no stable support for RSC yet.
|
|
28
|
+
async transform(value, id) {
|
|
29
|
+
const [path, query = ""] = id.split("?");
|
|
30
|
+
if (!fileRegex.test(path)) return;
|
|
31
|
+
const matter = fumaMatter(value);
|
|
32
|
+
const isDevelopment = this.environment.mode === "dev";
|
|
33
|
+
const { collection: collectionId, raw } = parse(query);
|
|
34
|
+
const collection = collectionId ? loaded.collections.get(collectionId) : void 0;
|
|
35
|
+
const lineOffset = "\n".repeat(
|
|
36
|
+
isDevelopment ? countLines(matter.matter) : 0
|
|
37
|
+
);
|
|
38
|
+
let mdxOptions;
|
|
39
|
+
switch (collection?.type) {
|
|
40
|
+
case "doc":
|
|
41
|
+
mdxOptions = collection.mdxOptions;
|
|
42
|
+
break;
|
|
43
|
+
case "docs":
|
|
44
|
+
mdxOptions = collection.docs.mdxOptions;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
mdxOptions ??= await loadDefaultOptions(loaded);
|
|
48
|
+
const file = await buildMDX(
|
|
49
|
+
collectionId ?? "global",
|
|
50
|
+
lineOffset + matter.content,
|
|
51
|
+
{
|
|
52
|
+
development: isDevelopment,
|
|
53
|
+
...mdxOptions,
|
|
54
|
+
filePath: path,
|
|
55
|
+
frontmatter: matter.data,
|
|
56
|
+
_compiler: {
|
|
57
|
+
addDependency: (file2) => {
|
|
58
|
+
this.addWatchFile(file2);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
return {
|
|
64
|
+
code: typeof raw === "string" ? `export default ${JSON.stringify(file.value)}` : String(file.value)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
unstable_mdx as default
|
|
71
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.10",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
"types": "./dist/next/index.d.ts",
|
|
24
24
|
"require": "./dist/next/index.cjs"
|
|
25
25
|
},
|
|
26
|
+
"./vite": {
|
|
27
|
+
"import": "./dist/vite/index.js",
|
|
28
|
+
"types": "./dist/vite/index.d.ts",
|
|
29
|
+
"require": "./dist/vite/index.cjs"
|
|
30
|
+
},
|
|
26
31
|
"./runtime/async": {
|
|
27
32
|
"import": "./dist/runtime/async.js",
|
|
28
33
|
"types": "./dist/runtime/async.d.ts"
|
|
@@ -53,7 +58,7 @@
|
|
|
53
58
|
"tinyexec": "^1.0.1",
|
|
54
59
|
"tinyglobby": "^0.2.14",
|
|
55
60
|
"unist-util-visit": "^5.0.0",
|
|
56
|
-
"zod": "^3.25.
|
|
61
|
+
"zod": "^3.25.67"
|
|
57
62
|
},
|
|
58
63
|
"devDependencies": {
|
|
59
64
|
"@types/js-yaml": "^4.0.9",
|
|
@@ -61,21 +66,29 @@
|
|
|
61
66
|
"@types/mdx": "^2.0.13",
|
|
62
67
|
"@types/react": "^19.1.8",
|
|
63
68
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
64
|
-
"next": "^15.3.
|
|
69
|
+
"next": "^15.3.4",
|
|
65
70
|
"unified": "^11.0.5",
|
|
66
71
|
"vfile": "^6.0.3",
|
|
72
|
+
"vite": "^7.0.0",
|
|
67
73
|
"webpack": "^5.99.9",
|
|
68
|
-
"@fumadocs/mdx-remote": "1.3.
|
|
74
|
+
"@fumadocs/mdx-remote": "1.3.4",
|
|
69
75
|
"eslint-config-custom": "0.0.0",
|
|
70
|
-
"fumadocs-core": "15.
|
|
76
|
+
"fumadocs-core": "15.6.0",
|
|
71
77
|
"tsconfig": "0.0.0"
|
|
72
78
|
},
|
|
73
79
|
"peerDependencies": {
|
|
74
80
|
"@fumadocs/mdx-remote": "^1.2.0",
|
|
75
81
|
"fumadocs-core": "^14.0.0 || ^15.0.0",
|
|
76
|
-
"next": "^15.3.0"
|
|
82
|
+
"next": "^15.3.0",
|
|
83
|
+
"vite": "6.x.x"
|
|
77
84
|
},
|
|
78
85
|
"peerDependenciesMeta": {
|
|
86
|
+
"next": {
|
|
87
|
+
"optional": true
|
|
88
|
+
},
|
|
89
|
+
"vite": {
|
|
90
|
+
"optional": true
|
|
91
|
+
},
|
|
79
92
|
"@fumadocs/mdx-remote": {
|
|
80
93
|
"optional": true
|
|
81
94
|
}
|
package/dist/chunk-MXACIHNJ.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// src/utils/fuma-matter.ts
|
|
2
|
-
import { LRUCache } from "lru-cache";
|
|
3
|
-
import { load } from "js-yaml";
|
|
4
|
-
var cache = new LRUCache({
|
|
5
|
-
max: 200
|
|
6
|
-
});
|
|
7
|
-
function fumaMatter(input) {
|
|
8
|
-
if (input === "") {
|
|
9
|
-
return { data: {}, content: input, matter: "" };
|
|
10
|
-
}
|
|
11
|
-
const cached = cache.get(input);
|
|
12
|
-
if (cached) return cached;
|
|
13
|
-
const result = parseMatter(input);
|
|
14
|
-
cache.set(input, result);
|
|
15
|
-
return structuredClone(result);
|
|
16
|
-
}
|
|
17
|
-
var delimiter = "---";
|
|
18
|
-
function parseMatter(str) {
|
|
19
|
-
const output = { matter: "", data: {}, content: str };
|
|
20
|
-
const open = delimiter + "\n";
|
|
21
|
-
const close = "\n" + delimiter;
|
|
22
|
-
if (!str.startsWith(open)) {
|
|
23
|
-
return output;
|
|
24
|
-
}
|
|
25
|
-
str = str.slice(open.length);
|
|
26
|
-
const len = str.length;
|
|
27
|
-
let closeIdx = str.indexOf(close);
|
|
28
|
-
if (closeIdx === -1) {
|
|
29
|
-
closeIdx = len;
|
|
30
|
-
}
|
|
31
|
-
output.matter = str.slice(0, closeIdx);
|
|
32
|
-
output.content = str.slice(closeIdx + close.length);
|
|
33
|
-
const loaded = load(output.matter);
|
|
34
|
-
output.data = loaded ?? {};
|
|
35
|
-
return output;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
fumaMatter
|
|
40
|
-
};
|