fumadocs-mdx 11.7.4 → 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-7JFPDRW7.js +42 -0
- package/dist/chunk-GBMFGEC7.js +57 -0
- package/dist/{chunk-ZOWJF3OH.js → chunk-GX3THK2Q.js} +25 -20
- package/dist/{chunk-2CSSQTP6.js → chunk-GYWPPGFD.js} +9 -1
- package/dist/{chunk-PQCNPAD3.js → chunk-IGXZS2W6.js} +10 -7
- package/dist/chunk-UCY7OBZG.js +12 -0
- package/dist/{chunk-KVWX6THC.js → chunk-VWJKRQZR.js} +2 -2
- package/dist/{chunk-JFNBRKRV.js → chunk-XVL4ZQFK.js} +12 -6
- package/dist/{chunk-4CGSOZUZ.js → chunk-XZR5QXVY.js} +32 -2
- package/dist/config/index.cjs +21 -11
- package/dist/config/index.d.cts +2 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +9 -37
- package/dist/config/zod-3.cjs +371 -0
- package/dist/config/zod-3.d.cts +53 -0
- package/dist/config/zod-3.d.ts +53 -0
- package/dist/config/zod-3.js +40 -0
- package/dist/{define-E6TRBwBQ.d.cts → define-DnJzAZrj.d.cts} +3 -2
- package/dist/{define-E6TRBwBQ.d.ts → define-DnJzAZrj.d.ts} +3 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/loader-mdx.cjs +83 -50
- package/dist/loader-mdx.js +10 -10
- package/dist/{mdx-options-UDV5WEFU.js → mdx-options-3NB74EMB.js} +1 -1
- package/dist/next/index.cjs +63 -29
- package/dist/next/index.js +7 -9
- package/dist/runtime/async.cjs +167 -128
- package/dist/runtime/async.d.cts +3 -3
- package/dist/runtime/async.d.ts +3 -3
- package/dist/runtime/async.js +30 -46
- package/dist/runtime/vite.cjs +49 -41
- package/dist/runtime/vite.d.cts +26 -18
- package/dist/runtime/vite.d.ts +26 -18
- package/dist/runtime/vite.js +49 -41
- package/dist/{types-Lh_-Uuix.d.cts → types-B2ozVm_9.d.ts} +11 -5
- package/dist/{types-DiL328cG.d.ts → types-BukvTPdG.d.cts} +11 -5
- package/dist/vite/index.cjs +125 -99
- package/dist/vite/index.d.cts +6 -1
- package/dist/vite/index.d.ts +6 -1
- package/dist/vite/index.js +54 -38
- package/package.json +17 -12
- package/dist/chunk-2K55VKP6.js +0 -49
- package/dist/chunk-VUEZTR2H.js +0 -26
package/dist/runtime/async.cjs
CHANGED
|
@@ -102,6 +102,7 @@ function getDefaultMDXOptions({
|
|
|
102
102
|
remarkStructureOptions,
|
|
103
103
|
remarkCodeTabOptions,
|
|
104
104
|
remarkNpmOptions,
|
|
105
|
+
_withoutBundler = false,
|
|
105
106
|
...mdxOptions
|
|
106
107
|
}) {
|
|
107
108
|
const mdxExports = [
|
|
@@ -120,7 +121,13 @@ function getDefaultMDXOptions({
|
|
|
120
121
|
...remarkHeadingOptions
|
|
121
122
|
}
|
|
122
123
|
],
|
|
123
|
-
remarkImageOptions !== false && [
|
|
124
|
+
remarkImageOptions !== false && [
|
|
125
|
+
plugins.remarkImage,
|
|
126
|
+
{
|
|
127
|
+
...remarkImageOptions,
|
|
128
|
+
useImport: _withoutBundler ? false : remarkImageOptions?.useImport
|
|
129
|
+
}
|
|
130
|
+
],
|
|
124
131
|
"remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
|
|
125
132
|
plugins.remarkCodeTab,
|
|
126
133
|
remarkCodeTabOptions
|
|
@@ -145,6 +152,7 @@ function getDefaultMDXOptions({
|
|
|
145
152
|
);
|
|
146
153
|
return {
|
|
147
154
|
...mdxOptions,
|
|
155
|
+
outputFormat: _withoutBundler ? "function-body" : mdxOptions.outputFormat,
|
|
148
156
|
remarkPlugins,
|
|
149
157
|
rehypePlugins
|
|
150
158
|
};
|
|
@@ -165,12 +173,87 @@ __export(async_exports, {
|
|
|
165
173
|
buildConfig: () => buildConfig
|
|
166
174
|
});
|
|
167
175
|
module.exports = __toCommonJS(async_exports);
|
|
168
|
-
|
|
176
|
+
|
|
177
|
+
// src/runtime/index.ts
|
|
178
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
179
|
+
var cache = /* @__PURE__ */ new Map();
|
|
180
|
+
var _runtime = {
|
|
181
|
+
doc(files) {
|
|
182
|
+
return files.map((file) => {
|
|
183
|
+
const { default: body, frontmatter, ...exports2 } = file.data;
|
|
184
|
+
return {
|
|
185
|
+
body,
|
|
186
|
+
...exports2,
|
|
187
|
+
...frontmatter,
|
|
188
|
+
_file: file.info,
|
|
189
|
+
_exports: file.data,
|
|
190
|
+
get content() {
|
|
191
|
+
const path2 = this._file.absolutePath;
|
|
192
|
+
const cached = cache.get(path2);
|
|
193
|
+
if (cached) return cached;
|
|
194
|
+
const content = import_node_fs.default.readFileSync(path2).toString();
|
|
195
|
+
cache.set(path2, content);
|
|
196
|
+
return content;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
meta(files) {
|
|
202
|
+
return files.map((file) => {
|
|
203
|
+
return {
|
|
204
|
+
...file.data,
|
|
205
|
+
_file: file.info
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
docs(docs, metas) {
|
|
210
|
+
const parsedDocs = this.doc(docs);
|
|
211
|
+
const parsedMetas = this.meta(metas);
|
|
212
|
+
return {
|
|
213
|
+
docs: parsedDocs,
|
|
214
|
+
meta: parsedMetas,
|
|
215
|
+
toFumadocsSource() {
|
|
216
|
+
return createMDXSource(parsedDocs, parsedMetas);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
function createMDXSource(docs, meta = []) {
|
|
222
|
+
return {
|
|
223
|
+
files: () => resolveFiles({
|
|
224
|
+
docs,
|
|
225
|
+
meta
|
|
226
|
+
})
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function resolveFiles({ docs, meta }) {
|
|
230
|
+
const outputs = [];
|
|
231
|
+
for (const entry of docs) {
|
|
232
|
+
outputs.push({
|
|
233
|
+
type: "page",
|
|
234
|
+
absolutePath: entry._file.absolutePath,
|
|
235
|
+
path: entry._file.path,
|
|
236
|
+
data: entry
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
for (const entry of meta) {
|
|
240
|
+
outputs.push({
|
|
241
|
+
type: "meta",
|
|
242
|
+
absolutePath: entry._file.absolutePath,
|
|
243
|
+
path: entry._file.path,
|
|
244
|
+
data: entry
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return outputs;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/utils/build-mdx.ts
|
|
251
|
+
var import_mdx = require("@mdx-js/mdx");
|
|
169
252
|
|
|
170
253
|
// src/mdx-plugins/remark-include.ts
|
|
171
254
|
var import_unist_util_visit = require("unist-util-visit");
|
|
172
255
|
var path = __toESM(require("path"), 1);
|
|
173
|
-
var
|
|
256
|
+
var fs2 = __toESM(require("fs/promises"), 1);
|
|
174
257
|
|
|
175
258
|
// src/utils/fuma-matter.ts
|
|
176
259
|
var import_js_yaml = require("js-yaml");
|
|
@@ -181,9 +264,9 @@ function fumaMatter(input) {
|
|
|
181
264
|
if (!match) {
|
|
182
265
|
return output;
|
|
183
266
|
}
|
|
184
|
-
output.matter = match[
|
|
267
|
+
output.matter = match[0];
|
|
185
268
|
output.content = input.slice(match[0].length);
|
|
186
|
-
const loaded = (0, import_js_yaml.load)(
|
|
269
|
+
const loaded = (0, import_js_yaml.load)(match[1]);
|
|
187
270
|
output.data = loaded ?? {};
|
|
188
271
|
return output;
|
|
189
272
|
}
|
|
@@ -217,7 +300,7 @@ function extractSection(root, section) {
|
|
|
217
300
|
}
|
|
218
301
|
function remarkInclude() {
|
|
219
302
|
const TagName = "include";
|
|
220
|
-
async function update(tree, directory,
|
|
303
|
+
async function update(tree, directory, data) {
|
|
221
304
|
const queue = [];
|
|
222
305
|
(0, import_unist_util_visit.visit)(
|
|
223
306
|
tree,
|
|
@@ -244,8 +327,8 @@ function remarkInclude() {
|
|
|
244
327
|
);
|
|
245
328
|
const asCode = params.lang || !file.endsWith(".md") && !file.endsWith(".mdx");
|
|
246
329
|
queue.push(
|
|
247
|
-
|
|
248
|
-
|
|
330
|
+
fs2.readFile(targetPath).then((buffer) => buffer.toString()).then(async (content) => {
|
|
331
|
+
data._compiler?.addDependency(targetPath);
|
|
249
332
|
if (asCode) {
|
|
250
333
|
const lang = params.lang ?? path.extname(file).slice(1);
|
|
251
334
|
Object.assign(node, {
|
|
@@ -257,6 +340,9 @@ function remarkInclude() {
|
|
|
257
340
|
});
|
|
258
341
|
return;
|
|
259
342
|
}
|
|
343
|
+
const processor = data._processor ? data._processor.getProcessor(
|
|
344
|
+
targetPath.endsWith(".md") ? "md" : "mdx"
|
|
345
|
+
) : this;
|
|
260
346
|
let parsed = processor.parse(fumaMatter(content).content);
|
|
261
347
|
if (section) {
|
|
262
348
|
const extracted = extractSection(parsed, section);
|
|
@@ -266,11 +352,11 @@ function remarkInclude() {
|
|
|
266
352
|
);
|
|
267
353
|
parsed = extracted;
|
|
268
354
|
}
|
|
269
|
-
await update(
|
|
355
|
+
await update.call(
|
|
356
|
+
processor,
|
|
270
357
|
parsed,
|
|
271
358
|
path.dirname(targetPath),
|
|
272
|
-
|
|
273
|
-
compiler
|
|
359
|
+
data
|
|
274
360
|
);
|
|
275
361
|
Object.assign(
|
|
276
362
|
parent && parent.type === "paragraph" ? parent : node,
|
|
@@ -290,86 +376,48 @@ ${e instanceof Error ? e.message : String(e)}`,
|
|
|
290
376
|
await Promise.all(queue);
|
|
291
377
|
}
|
|
292
378
|
return async (tree, file) => {
|
|
293
|
-
await update(tree, path.dirname(file.path),
|
|
379
|
+
await update.call(this, tree, path.dirname(file.path), file.data);
|
|
294
380
|
};
|
|
295
381
|
}
|
|
296
382
|
|
|
297
|
-
// src/
|
|
298
|
-
var
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const path2 = this._file.absolutePath;
|
|
315
|
-
const cached = cache.get(path2);
|
|
316
|
-
if (cached) return cached;
|
|
317
|
-
const content = import_node_fs.default.readFileSync(path2).toString();
|
|
318
|
-
cache.set(path2, content);
|
|
319
|
-
return content;
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
});
|
|
323
|
-
},
|
|
324
|
-
meta(files) {
|
|
325
|
-
return files.map((file) => {
|
|
326
|
-
return {
|
|
327
|
-
...file.data,
|
|
328
|
-
_file: file.info
|
|
329
|
-
};
|
|
330
|
-
});
|
|
331
|
-
},
|
|
332
|
-
docs(docs, metas) {
|
|
333
|
-
const parsedDocs = this.doc(docs);
|
|
334
|
-
const parsedMetas = this.meta(metas);
|
|
335
|
-
return {
|
|
336
|
-
docs: parsedDocs,
|
|
337
|
-
meta: parsedMetas,
|
|
338
|
-
toFumadocsSource() {
|
|
339
|
-
return createMDXSource(parsedDocs, parsedMetas);
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
function createMDXSource(docs, meta = []) {
|
|
345
|
-
return {
|
|
346
|
-
files: () => resolveFiles({
|
|
347
|
-
docs,
|
|
348
|
-
meta
|
|
349
|
-
})
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
function resolveFiles({ docs, meta }) {
|
|
353
|
-
const outputs = [];
|
|
354
|
-
for (const entry of docs) {
|
|
355
|
-
outputs.push({
|
|
356
|
-
type: "page",
|
|
357
|
-
absolutePath: entry._file.absolutePath,
|
|
358
|
-
path: entry._file.path,
|
|
359
|
-
data: entry
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
for (const entry of meta) {
|
|
363
|
-
outputs.push({
|
|
364
|
-
type: "meta",
|
|
365
|
-
absolutePath: entry._file.absolutePath,
|
|
366
|
-
path: entry._file.path,
|
|
367
|
-
data: entry
|
|
368
|
-
});
|
|
383
|
+
// src/utils/build-mdx.ts
|
|
384
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
385
|
+
async function buildMDX(cacheKey, source, options) {
|
|
386
|
+
const { filePath, frontmatter, data, _compiler, ...rest } = options;
|
|
387
|
+
function getProcessor(format) {
|
|
388
|
+
const key = `${cacheKey}:${format}`;
|
|
389
|
+
let processor = cache2.get(key);
|
|
390
|
+
if (!processor) {
|
|
391
|
+
processor = (0, import_mdx.createProcessor)({
|
|
392
|
+
outputFormat: "program",
|
|
393
|
+
...rest,
|
|
394
|
+
remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
|
|
395
|
+
format
|
|
396
|
+
});
|
|
397
|
+
cache2.set(key, processor);
|
|
398
|
+
}
|
|
399
|
+
return processor;
|
|
369
400
|
}
|
|
370
|
-
return
|
|
401
|
+
return getProcessor(
|
|
402
|
+
options.format ?? filePath.endsWith(".mdx") ? "mdx" : "md"
|
|
403
|
+
).process({
|
|
404
|
+
value: source,
|
|
405
|
+
path: filePath,
|
|
406
|
+
data: {
|
|
407
|
+
...data,
|
|
408
|
+
frontmatter,
|
|
409
|
+
_compiler,
|
|
410
|
+
_processor: {
|
|
411
|
+
getProcessor
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
});
|
|
371
415
|
}
|
|
372
416
|
|
|
417
|
+
// src/runtime/async.ts
|
|
418
|
+
var import_client = require("@fumadocs/mdx-remote/client");
|
|
419
|
+
var import_node_url = require("url");
|
|
420
|
+
|
|
373
421
|
// src/config/build.ts
|
|
374
422
|
function buildConfig(config) {
|
|
375
423
|
const collections = /* @__PURE__ */ new Map();
|
|
@@ -396,75 +444,66 @@ function buildConfig(config) {
|
|
|
396
444
|
`Unknown export "${k}", you can only export collections from source configuration file.`
|
|
397
445
|
);
|
|
398
446
|
}
|
|
399
|
-
|
|
447
|
+
const mdxOptionsCache = /* @__PURE__ */ new Map();
|
|
400
448
|
return {
|
|
401
449
|
global: globalConfig,
|
|
402
450
|
collections,
|
|
403
|
-
async getDefaultMDXOptions() {
|
|
404
|
-
|
|
451
|
+
async getDefaultMDXOptions(mode = "default") {
|
|
452
|
+
const cached = mdxOptionsCache.get(mode);
|
|
453
|
+
if (cached) return cached;
|
|
405
454
|
const input = this.global.mdxOptions;
|
|
406
455
|
async function uncached() {
|
|
407
456
|
const options = typeof input === "function" ? await input() : input;
|
|
408
457
|
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
|
|
409
458
|
if (options?.preset === "minimal") return options;
|
|
410
|
-
return getDefaultMDXOptions2(
|
|
459
|
+
return getDefaultMDXOptions2({
|
|
460
|
+
...options,
|
|
461
|
+
_withoutBundler: mode === "remote"
|
|
462
|
+
});
|
|
411
463
|
}
|
|
412
|
-
|
|
464
|
+
const result = uncached();
|
|
465
|
+
mdxOptionsCache.set(mode, result);
|
|
466
|
+
return result;
|
|
413
467
|
}
|
|
414
468
|
};
|
|
415
469
|
}
|
|
416
470
|
|
|
417
471
|
// src/runtime/async.ts
|
|
418
|
-
async function
|
|
472
|
+
async function getOptions(config, collection) {
|
|
419
473
|
const col = config.collections.get(collection);
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
return (0, import_mdx_remote.createCompiler)({
|
|
424
|
-
preset: "minimal",
|
|
425
|
-
...col.mdxOptions
|
|
426
|
-
});
|
|
427
|
-
break;
|
|
428
|
-
case "docs":
|
|
429
|
-
if (col.docs.mdxOptions)
|
|
430
|
-
return (0, import_mdx_remote.createCompiler)({
|
|
431
|
-
preset: "minimal",
|
|
432
|
-
...col.docs.mdxOptions
|
|
433
|
-
});
|
|
434
|
-
break;
|
|
435
|
-
}
|
|
436
|
-
let defaultMdxOptions = config.global?.mdxOptions;
|
|
437
|
-
if (typeof defaultMdxOptions === "function")
|
|
438
|
-
defaultMdxOptions = await defaultMdxOptions();
|
|
439
|
-
if (defaultMdxOptions?.preset === "minimal") {
|
|
440
|
-
return (0, import_mdx_remote.createCompiler)(defaultMdxOptions);
|
|
441
|
-
}
|
|
442
|
-
const remarkPlugins = defaultMdxOptions?.remarkPlugins ?? [];
|
|
443
|
-
return (0, import_mdx_remote.createCompiler)({
|
|
444
|
-
...defaultMdxOptions,
|
|
445
|
-
remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), import_mdx_plugins.remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, import_mdx_plugins.remarkStructure]
|
|
446
|
-
});
|
|
474
|
+
if (col?.type === "doc" && col.mdxOptions) return col.mdxOptions;
|
|
475
|
+
if (col?.type === "docs" && col.docs.mdxOptions) return col.docs.mdxOptions;
|
|
476
|
+
return config.getDefaultMDXOptions("remote");
|
|
447
477
|
}
|
|
448
478
|
var _runtimeAsync = {
|
|
449
479
|
doc(files, collection, config) {
|
|
450
|
-
const
|
|
480
|
+
const initMdxOptions = getOptions(config, collection);
|
|
451
481
|
return files.map(({ info: file, data, content, lastModified }) => {
|
|
452
482
|
return {
|
|
453
483
|
...data,
|
|
454
484
|
_file: file,
|
|
455
|
-
content
|
|
485
|
+
get content() {
|
|
486
|
+
return `${content.matter}${content.body}`;
|
|
487
|
+
},
|
|
456
488
|
async load() {
|
|
457
|
-
const
|
|
458
|
-
const out = await
|
|
459
|
-
|
|
489
|
+
const mdxOptions = await initMdxOptions;
|
|
490
|
+
const out = await buildMDX(collection, content.body, {
|
|
491
|
+
...mdxOptions,
|
|
492
|
+
development: false,
|
|
493
|
+
frontmatter: data,
|
|
494
|
+
data: {
|
|
495
|
+
lastModified
|
|
496
|
+
},
|
|
460
497
|
filePath: file.absolutePath
|
|
461
498
|
});
|
|
499
|
+
const { default: body, ...rest } = await (0, import_client.executeMdx)(String(out), {
|
|
500
|
+
baseUrl: (0, import_node_url.pathToFileURL)(file.absolutePath)
|
|
501
|
+
});
|
|
462
502
|
return {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
_exports: out.exports ?? {}
|
|
503
|
+
structuredData: out.data.structuredData,
|
|
504
|
+
body,
|
|
505
|
+
...rest,
|
|
506
|
+
lastModified
|
|
468
507
|
};
|
|
469
508
|
}
|
|
470
509
|
};
|
package/dist/runtime/async.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { L as LoadedConfig, a as RuntimeAsync } from '../types-
|
|
1
|
+
import { L as LoadedConfig, a as RuntimeAsync } from '../types-BukvTPdG.cjs';
|
|
2
2
|
import '@standard-schema/spec';
|
|
3
3
|
import 'fumadocs-core/source';
|
|
4
|
-
import '../define-
|
|
5
|
-
import 'zod';
|
|
4
|
+
import '../define-DnJzAZrj.cjs';
|
|
6
5
|
import 'fumadocs-core/mdx-plugins';
|
|
7
6
|
import '@mdx-js/mdx';
|
|
8
7
|
import 'unified';
|
|
8
|
+
import 'zod';
|
|
9
9
|
import 'react';
|
|
10
10
|
import 'mdx/types';
|
|
11
11
|
import 'fumadocs-core/server';
|
package/dist/runtime/async.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { L as LoadedConfig, a as RuntimeAsync } from '../types-
|
|
1
|
+
import { L as LoadedConfig, a as RuntimeAsync } from '../types-B2ozVm_9.js';
|
|
2
2
|
import '@standard-schema/spec';
|
|
3
3
|
import 'fumadocs-core/source';
|
|
4
|
-
import '../define-
|
|
5
|
-
import 'zod';
|
|
4
|
+
import '../define-DnJzAZrj.js';
|
|
6
5
|
import 'fumadocs-core/mdx-plugins';
|
|
7
6
|
import '@mdx-js/mdx';
|
|
8
7
|
import 'unified';
|
|
8
|
+
import 'zod';
|
|
9
9
|
import 'react';
|
|
10
10
|
import 'mdx/types';
|
|
11
11
|
import 'fumadocs-core/server';
|
package/dist/runtime/async.js
CHANGED
|
@@ -3,68 +3,52 @@ import {
|
|
|
3
3
|
createMDXSource
|
|
4
4
|
} from "../chunk-NUDEC6C5.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "../chunk-
|
|
6
|
+
buildMDX
|
|
7
|
+
} from "../chunk-7JFPDRW7.js";
|
|
8
|
+
import "../chunk-IGXZS2W6.js";
|
|
8
9
|
import {
|
|
9
10
|
buildConfig
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
11
|
+
} from "../chunk-XVL4ZQFK.js";
|
|
12
|
+
import "../chunk-VWJKRQZR.js";
|
|
12
13
|
|
|
13
14
|
// src/runtime/async.ts
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
} from "fumadocs-core/mdx-plugins";
|
|
18
|
-
async function initCompiler(config, collection) {
|
|
15
|
+
import { executeMdx } from "@fumadocs/mdx-remote/client";
|
|
16
|
+
import { pathToFileURL } from "url";
|
|
17
|
+
async function getOptions(config, collection) {
|
|
19
18
|
const col = config.collections.get(collection);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return createCompiler({
|
|
24
|
-
preset: "minimal",
|
|
25
|
-
...col.mdxOptions
|
|
26
|
-
});
|
|
27
|
-
break;
|
|
28
|
-
case "docs":
|
|
29
|
-
if (col.docs.mdxOptions)
|
|
30
|
-
return createCompiler({
|
|
31
|
-
preset: "minimal",
|
|
32
|
-
...col.docs.mdxOptions
|
|
33
|
-
});
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
let defaultMdxOptions = config.global?.mdxOptions;
|
|
37
|
-
if (typeof defaultMdxOptions === "function")
|
|
38
|
-
defaultMdxOptions = await defaultMdxOptions();
|
|
39
|
-
if (defaultMdxOptions?.preset === "minimal") {
|
|
40
|
-
return createCompiler(defaultMdxOptions);
|
|
41
|
-
}
|
|
42
|
-
const remarkPlugins = defaultMdxOptions?.remarkPlugins ?? [];
|
|
43
|
-
return createCompiler({
|
|
44
|
-
...defaultMdxOptions,
|
|
45
|
-
remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, remarkStructure]
|
|
46
|
-
});
|
|
19
|
+
if (col?.type === "doc" && col.mdxOptions) return col.mdxOptions;
|
|
20
|
+
if (col?.type === "docs" && col.docs.mdxOptions) return col.docs.mdxOptions;
|
|
21
|
+
return config.getDefaultMDXOptions("remote");
|
|
47
22
|
}
|
|
48
23
|
var _runtimeAsync = {
|
|
49
24
|
doc(files, collection, config) {
|
|
50
|
-
const
|
|
25
|
+
const initMdxOptions = getOptions(config, collection);
|
|
51
26
|
return files.map(({ info: file, data, content, lastModified }) => {
|
|
52
27
|
return {
|
|
53
28
|
...data,
|
|
54
29
|
_file: file,
|
|
55
|
-
content
|
|
30
|
+
get content() {
|
|
31
|
+
return `${content.matter}${content.body}`;
|
|
32
|
+
},
|
|
56
33
|
async load() {
|
|
57
|
-
const
|
|
58
|
-
const out = await
|
|
59
|
-
|
|
34
|
+
const mdxOptions = await initMdxOptions;
|
|
35
|
+
const out = await buildMDX(collection, content.body, {
|
|
36
|
+
...mdxOptions,
|
|
37
|
+
development: false,
|
|
38
|
+
frontmatter: data,
|
|
39
|
+
data: {
|
|
40
|
+
lastModified
|
|
41
|
+
},
|
|
60
42
|
filePath: file.absolutePath
|
|
61
43
|
});
|
|
44
|
+
const { default: body, ...rest } = await executeMdx(String(out), {
|
|
45
|
+
baseUrl: pathToFileURL(file.absolutePath)
|
|
46
|
+
});
|
|
62
47
|
return {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
_exports: out.exports ?? {}
|
|
48
|
+
structuredData: out.data.structuredData,
|
|
49
|
+
body,
|
|
50
|
+
...rest,
|
|
51
|
+
lastModified
|
|
68
52
|
};
|
|
69
53
|
}
|
|
70
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
|
}
|