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.
Files changed (44) hide show
  1. package/dist/{chunk-OWZSTKKX.js → chunk-6Y5JDZHD.js} +8 -1
  2. package/dist/chunk-7JFPDRW7.js +42 -0
  3. package/dist/chunk-GBMFGEC7.js +57 -0
  4. package/dist/{chunk-ZOWJF3OH.js → chunk-GX3THK2Q.js} +25 -20
  5. package/dist/{chunk-2CSSQTP6.js → chunk-GYWPPGFD.js} +9 -1
  6. package/dist/{chunk-PQCNPAD3.js → chunk-IGXZS2W6.js} +10 -7
  7. package/dist/chunk-UCY7OBZG.js +12 -0
  8. package/dist/{chunk-KVWX6THC.js → chunk-VWJKRQZR.js} +2 -2
  9. package/dist/{chunk-JFNBRKRV.js → chunk-XVL4ZQFK.js} +12 -6
  10. package/dist/{chunk-4CGSOZUZ.js → chunk-XZR5QXVY.js} +32 -2
  11. package/dist/config/index.cjs +21 -11
  12. package/dist/config/index.d.cts +2 -2
  13. package/dist/config/index.d.ts +2 -2
  14. package/dist/config/index.js +9 -37
  15. package/dist/config/zod-3.cjs +371 -0
  16. package/dist/config/zod-3.d.cts +53 -0
  17. package/dist/config/zod-3.d.ts +53 -0
  18. package/dist/config/zod-3.js +40 -0
  19. package/dist/{define-E6TRBwBQ.d.cts → define-DnJzAZrj.d.cts} +3 -2
  20. package/dist/{define-E6TRBwBQ.d.ts → define-DnJzAZrj.d.ts} +3 -2
  21. package/dist/index.d.cts +3 -3
  22. package/dist/index.d.ts +3 -3
  23. package/dist/loader-mdx.cjs +83 -50
  24. package/dist/loader-mdx.js +10 -10
  25. package/dist/{mdx-options-UDV5WEFU.js → mdx-options-3NB74EMB.js} +1 -1
  26. package/dist/next/index.cjs +63 -29
  27. package/dist/next/index.js +7 -9
  28. package/dist/runtime/async.cjs +167 -128
  29. package/dist/runtime/async.d.cts +3 -3
  30. package/dist/runtime/async.d.ts +3 -3
  31. package/dist/runtime/async.js +30 -46
  32. package/dist/runtime/vite.cjs +49 -41
  33. package/dist/runtime/vite.d.cts +26 -18
  34. package/dist/runtime/vite.d.ts +26 -18
  35. package/dist/runtime/vite.js +49 -41
  36. package/dist/{types-Lh_-Uuix.d.cts → types-B2ozVm_9.d.ts} +11 -5
  37. package/dist/{types-DiL328cG.d.ts → types-BukvTPdG.d.cts} +11 -5
  38. package/dist/vite/index.cjs +125 -99
  39. package/dist/vite/index.d.cts +6 -1
  40. package/dist/vite/index.d.ts +6 -1
  41. package/dist/vite/index.js +54 -38
  42. package/package.json +17 -12
  43. package/dist/chunk-2K55VKP6.js +0 -49
  44. package/dist/chunk-VUEZTR2H.js +0 -26
@@ -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 && [plugins.remarkImage, remarkImageOptions],
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
  };
@@ -191,20 +199,26 @@ function buildConfig(config) {
191
199
  `Unknown export "${k}", you can only export collections from source configuration file.`
192
200
  );
193
201
  }
194
- let cachedMdxOptions;
202
+ const mdxOptionsCache = /* @__PURE__ */ new Map();
195
203
  return {
196
204
  global: globalConfig,
197
205
  collections,
198
- async getDefaultMDXOptions() {
199
- if (cachedMdxOptions) return cachedMdxOptions;
206
+ async getDefaultMDXOptions(mode = "default") {
207
+ const cached = mdxOptionsCache.get(mode);
208
+ if (cached) return cached;
200
209
  const input = this.global.mdxOptions;
201
210
  async function uncached() {
202
211
  const options = typeof input === "function" ? await input() : input;
203
212
  const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
204
213
  if (options?.preset === "minimal") return options;
205
- return getDefaultMDXOptions2(options ?? {});
214
+ return getDefaultMDXOptions2({
215
+ ...options,
216
+ _withoutBundler: mode === "remote"
217
+ });
206
218
  }
207
- return cachedMdxOptions = uncached();
219
+ const result = uncached();
220
+ mdxOptionsCache.set(mode, result);
221
+ return result;
208
222
  }
209
223
  };
210
224
  }
@@ -226,9 +240,9 @@ function fumaMatter(input) {
226
240
  if (!match) {
227
241
  return output;
228
242
  }
229
- output.matter = match[1];
243
+ output.matter = match[0];
230
244
  output.content = input.slice(match[0].length);
231
- const loaded = (0, import_js_yaml.load)(output.matter);
245
+ const loaded = (0, import_js_yaml.load)(match[1]);
232
246
  output.data = loaded ?? {};
233
247
  return output;
234
248
  }
@@ -262,7 +276,7 @@ function extractSection(root, section) {
262
276
  }
263
277
  function remarkInclude() {
264
278
  const TagName = "include";
265
- async function update(tree, directory, processor, compiler) {
279
+ async function update(tree, directory, data) {
266
280
  const queue = [];
267
281
  (0, import_unist_util_visit.visit)(
268
282
  tree,
@@ -290,7 +304,7 @@ function remarkInclude() {
290
304
  const asCode = params.lang || !file.endsWith(".md") && !file.endsWith(".mdx");
291
305
  queue.push(
292
306
  fs.readFile(targetPath).then((buffer) => buffer.toString()).then(async (content) => {
293
- compiler?.addDependency(targetPath);
307
+ data._compiler?.addDependency(targetPath);
294
308
  if (asCode) {
295
309
  const lang = params.lang ?? path.extname(file).slice(1);
296
310
  Object.assign(node, {
@@ -302,6 +316,9 @@ function remarkInclude() {
302
316
  });
303
317
  return;
304
318
  }
319
+ const processor = data._processor ? data._processor.getProcessor(
320
+ targetPath.endsWith(".md") ? "md" : "mdx"
321
+ ) : this;
305
322
  let parsed = processor.parse(fumaMatter(content).content);
306
323
  if (section) {
307
324
  const extracted = extractSection(parsed, section);
@@ -311,11 +328,11 @@ function remarkInclude() {
311
328
  );
312
329
  parsed = extracted;
313
330
  }
314
- await update(
331
+ await update.call(
332
+ processor,
315
333
  parsed,
316
334
  path.dirname(targetPath),
317
- processor,
318
- compiler
335
+ data
319
336
  );
320
337
  Object.assign(
321
338
  parent && parent.type === "paragraph" ? parent : node,
@@ -335,7 +352,7 @@ ${e instanceof Error ? e.message : String(e)}`,
335
352
  await Promise.all(queue);
336
353
  }
337
354
  return async (tree, file) => {
338
- await update(tree, path.dirname(file.path), this, file.data._compiler);
355
+ await update.call(this, tree, path.dirname(file.path), file.data);
339
356
  };
340
357
  }
341
358
 
@@ -343,29 +360,32 @@ ${e instanceof Error ? e.message : String(e)}`,
343
360
  var cache = /* @__PURE__ */ new Map();
344
361
  async function buildMDX(cacheKey, source, options) {
345
362
  const { filePath, frontmatter, data, _compiler, ...rest } = options;
346
- let format = options.format;
347
- if (filePath) {
348
- format ??= filePath.endsWith(".mdx") ? "mdx" : "md";
349
- }
350
- format ??= "mdx";
351
- const key = `${cacheKey}:${format}`;
352
- let cached = cache.get(key);
353
- if (!cached) {
354
- cached = (0, import_mdx.createProcessor)({
355
- outputFormat: "program",
356
- ...rest,
357
- remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
358
- format
359
- });
360
- cache.set(key, cached);
363
+ function getProcessor(format) {
364
+ const key = `${cacheKey}:${format}`;
365
+ let processor = cache.get(key);
366
+ if (!processor) {
367
+ processor = (0, import_mdx.createProcessor)({
368
+ outputFormat: "program",
369
+ ...rest,
370
+ remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
371
+ format
372
+ });
373
+ cache.set(key, processor);
374
+ }
375
+ return processor;
361
376
  }
362
- return cached.process({
377
+ return getProcessor(
378
+ options.format ?? filePath.endsWith(".mdx") ? "mdx" : "md"
379
+ ).process({
363
380
  value: source,
364
381
  path: filePath,
365
382
  data: {
366
383
  ...data,
367
384
  frontmatter,
368
- _compiler
385
+ _compiler,
386
+ _processor: {
387
+ getProcessor
388
+ }
369
389
  }
370
390
  });
371
391
  }
@@ -382,25 +402,8 @@ function countLines(s) {
382
402
  return num;
383
403
  }
384
404
 
385
- // src/utils/schema.ts
386
- var import_zod = require("zod");
405
+ // src/utils/validation.ts
387
406
  var import_picocolors = __toESM(require("picocolors"), 1);
388
- var metaSchema = import_zod.z.object({
389
- title: import_zod.z.string().optional(),
390
- pages: import_zod.z.array(import_zod.z.string()).optional(),
391
- description: import_zod.z.string().optional(),
392
- root: import_zod.z.boolean().optional(),
393
- defaultOpen: import_zod.z.boolean().optional(),
394
- icon: import_zod.z.string().optional()
395
- });
396
- var frontmatterSchema = import_zod.z.object({
397
- title: import_zod.z.string(),
398
- description: import_zod.z.string().optional(),
399
- icon: import_zod.z.string().optional(),
400
- full: import_zod.z.boolean().optional(),
401
- // Fumadocs OpenAPI generated
402
- _openapi: import_zod.z.looseObject({}).optional()
403
- });
404
407
  var ValidationError = class extends Error {
405
408
  constructor(message, issues) {
406
409
  super(
@@ -438,13 +441,20 @@ async function validate(schema, data, context, errorMessage) {
438
441
  }
439
442
 
440
443
  // src/vite/index.ts
441
- var import_zod2 = require("zod");
444
+ var import_zod = require("zod");
442
445
 
443
446
  // src/utils/import-formatter.ts
444
447
  var import_node_path = __toESM(require("path"), 1);
445
448
  function toImportPath(file, config) {
446
449
  const ext = import_node_path.default.extname(file);
447
- const filename = ext === ".ts" ? file.substring(0, file.length - ext.length) : file;
450
+ let filename;
451
+ if (ext === ".ts" && config.jsExtension) {
452
+ filename = file.substring(0, file.length - ext.length) + ".js";
453
+ } else if (ext === ".ts") {
454
+ filename = file.substring(0, file.length - ext.length);
455
+ } else {
456
+ filename = file;
457
+ }
448
458
  let importPath;
449
459
  if ("relativeTo" in config) {
450
460
  importPath = import_node_path.default.relative(config.relativeTo, filename);
@@ -465,6 +475,29 @@ var fs2 = __toESM(require("fs/promises"), 1);
465
475
  var path4 = __toESM(require("path"), 1);
466
476
  var import_js_yaml2 = require("js-yaml");
467
477
 
478
+ // src/utils/git-timestamp.ts
479
+ var import_node_path2 = __toESM(require("path"), 1);
480
+ var import_tinyexec = require("tinyexec");
481
+ var cache2 = /* @__PURE__ */ new Map();
482
+ async function getGitTimestamp(file) {
483
+ const cached = cache2.get(file);
484
+ if (cached) return cached;
485
+ try {
486
+ const out = await (0, import_tinyexec.x)(
487
+ "git",
488
+ ["log", "-1", '--pretty="%ai"', import_node_path2.default.relative(process.cwd(), file)],
489
+ {
490
+ throwOnError: true
491
+ }
492
+ );
493
+ const time = new Date(out.stdout);
494
+ cache2.set(file, time);
495
+ return time;
496
+ } catch {
497
+ return;
498
+ }
499
+ }
500
+
468
501
  // src/utils/collections.ts
469
502
  function getSupportedFormats(collection) {
470
503
  return {
@@ -478,17 +511,16 @@ function getGlobPatterns(collection) {
478
511
  }
479
512
 
480
513
  // src/vite/generate-glob.ts
481
- function generateGlob(name, collection) {
514
+ function generateGlob(name, collection, globOptions) {
482
515
  const patterns = mapGlobPatterns(getGlobPatterns(collection));
483
516
  const options = {
517
+ ...globOptions,
484
518
  query: {
519
+ ...globOptions?.query,
485
520
  collection: name
486
521
  },
487
522
  base: getGlobBase(collection)
488
523
  };
489
- if (collection.type === "meta") {
490
- options.import = "default";
491
- }
492
524
  return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(options, null, 2)})`;
493
525
  }
494
526
  function mapGlobPatterns(patterns) {
@@ -513,31 +545,38 @@ function getGlobBase(collection) {
513
545
  return dir;
514
546
  }
515
547
 
516
- // src/utils/git-timestamp.ts
517
- var import_node_path2 = __toESM(require("path"), 1);
518
- var import_tinyexec = require("tinyexec");
519
- var cache2 = /* @__PURE__ */ new Map();
520
- async function getGitTimestamp(file) {
521
- const cached = cache2.get(file);
522
- if (cached) return cached;
523
- try {
524
- const out = await (0, import_tinyexec.x)(
525
- "git",
526
- ["log", "-1", '--pretty="%ai"', import_node_path2.default.relative(process.cwd(), file)],
527
- {
528
- throwOnError: true
529
- }
530
- );
531
- const time = new Date(out.stdout);
532
- cache2.set(file, time);
533
- return time;
534
- } catch {
535
- return;
548
+ // src/vite/generate.ts
549
+ function docs(name, collection) {
550
+ const obj = [
551
+ ident(`doc: ${doc(name, collection.docs)}`),
552
+ ident(`meta: ${meta(name, collection.meta)}`)
553
+ ].join(",\n");
554
+ return `{
555
+ ${obj}
556
+ }`;
557
+ }
558
+ function doc(name, collection) {
559
+ if (collection.async) {
560
+ return `create.docLazy("${name}", ${generateGlob(name, collection, {
561
+ query: {
562
+ only: "frontmatter"
563
+ },
564
+ import: "frontmatter"
565
+ })}, ${generateGlob(name, collection)})`;
536
566
  }
567
+ return `create.doc("${name}", ${generateGlob(name, collection)})`;
568
+ }
569
+ function meta(name, collection) {
570
+ return `create.meta("${name}", ${generateGlob(name, collection, {
571
+ import: "default"
572
+ })})`;
537
573
  }
538
574
 
539
575
  // src/vite/index.ts
540
- var onlySchema = import_zod2.z.literal(["frontmatter", "all"]);
576
+ var querySchema = import_zod.z.object({
577
+ only: import_zod.z.literal(["frontmatter", "all"]).default("all"),
578
+ collection: import_zod.z.string().optional()
579
+ }).loose();
541
580
  function mdx(config, options = {}) {
542
581
  const { generateIndexFile = true, configPath = "source.config.ts" } = options;
543
582
  const loaded = buildConfig(config);
@@ -576,9 +615,8 @@ function mdx(config, options = {}) {
576
615
  async function transformContent(file, query, value) {
577
616
  const matter = fumaMatter(value);
578
617
  const isDevelopment = this.environment.mode === "dev";
579
- const parsed = (0, import_node_querystring.parse)(query);
618
+ const parsed = querySchema.parse((0, import_node_querystring.parse)(query));
580
619
  const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
581
- const only = parsed.only ? onlySchema.parse(parsed.only) : "all";
582
620
  let schema;
583
621
  let mdxOptions;
584
622
  switch (collection?.type) {
@@ -602,7 +640,7 @@ function mdx(config, options = {}) {
602
640
  `invalid frontmatter in ${file}`
603
641
  );
604
642
  }
605
- if (only === "frontmatter") {
643
+ if (parsed.only === "frontmatter") {
606
644
  return {
607
645
  code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
608
646
  map: null
@@ -648,35 +686,23 @@ function mdx(config, options = {}) {
648
686
  '/// <reference types="vite/client" />',
649
687
  `import { fromConfig } from 'fumadocs-mdx/runtime/vite';`,
650
688
  `import type * as Config from '${toImportPath(configPath, {
651
- relativeTo: outdir
689
+ relativeTo: outdir,
690
+ jsExtension: typeof generateIndexFile === "object" ? generateIndexFile.addJsExtension : void 0
652
691
  })}';`,
653
692
  "",
654
693
  `export const create = fromConfig<typeof Config>();`
655
694
  ];
656
- function docs(name, collection) {
657
- const args = [
658
- ident(`doc: ${generateGlob(name, collection.docs)}`),
659
- ident(`meta: ${generateGlob(name, collection.meta)}`)
660
- ].join(",\n");
661
- return `export const ${name} = create.docs("${name}", {
662
- ${args}
663
- });`;
664
- }
665
- function doc(name, collection) {
666
- return `export const ${name} = create.doc("${name}", ${generateGlob(name, collection)});`;
667
- }
668
- function meta(name, collection) {
669
- return `export const ${name} = create.meta("${name}", ${generateGlob(name, collection)});`;
670
- }
671
695
  for (const [name, collection] of loaded.collections.entries()) {
672
- lines.push("");
696
+ let body;
673
697
  if (collection.type === "docs") {
674
- lines.push(docs(name, collection));
698
+ body = docs(name, collection);
675
699
  } else if (collection.type === "meta") {
676
- lines.push(meta(name, collection));
700
+ body = meta(name, collection);
677
701
  } else {
678
- lines.push(doc(name, collection));
702
+ body = doc(name, collection);
679
703
  }
704
+ lines.push("");
705
+ lines.push(`export const ${name} = ${body};`);
680
706
  }
681
707
  await fs2.writeFile(path4.join(outdir, outFile), lines.join("\n"));
682
708
  },
@@ -6,7 +6,12 @@ interface PluginOptions {
6
6
  *
7
7
  * @defaultValue true
8
8
  */
9
- generateIndexFile?: boolean;
9
+ generateIndexFile?: boolean | {
10
+ /**
11
+ * add `.js` extensions to imports, needed for ESM without bundler resolution
12
+ */
13
+ addJsExtension?: boolean;
14
+ };
10
15
  /**
11
16
  * @defaultValue source.config.ts
12
17
  */
@@ -6,7 +6,12 @@ interface PluginOptions {
6
6
  *
7
7
  * @defaultValue true
8
8
  */
9
- generateIndexFile?: boolean;
9
+ generateIndexFile?: boolean | {
10
+ /**
11
+ * add `.js` extensions to imports, needed for ESM without bundler resolution
12
+ */
13
+ addJsExtension?: boolean;
14
+ };
10
15
  /**
11
16
  * @defaultValue source.config.ts
12
17
  */
@@ -1,26 +1,26 @@
1
1
  import {
2
- buildMDX,
3
2
  countLines
4
- } from "../chunk-2K55VKP6.js";
3
+ } from "../chunk-UCY7OBZG.js";
5
4
  import {
6
5
  getGlobPatterns,
7
6
  ident,
8
7
  toImportPath
9
- } from "../chunk-OWZSTKKX.js";
10
- import {
11
- getGitTimestamp
12
- } from "../chunk-VUEZTR2H.js";
8
+ } from "../chunk-6Y5JDZHD.js";
13
9
  import {
14
10
  ValidationError,
11
+ getGitTimestamp,
15
12
  validate
16
- } from "../chunk-ZOWJF3OH.js";
17
- import "../chunk-PQCNPAD3.js";
13
+ } from "../chunk-GX3THK2Q.js";
14
+ import {
15
+ buildMDX
16
+ } from "../chunk-7JFPDRW7.js";
17
+ import "../chunk-IGXZS2W6.js";
18
18
  import {
19
19
  buildConfig
20
- } from "../chunk-JFNBRKRV.js";
20
+ } from "../chunk-XVL4ZQFK.js";
21
21
  import {
22
22
  fumaMatter
23
- } from "../chunk-KVWX6THC.js";
23
+ } from "../chunk-VWJKRQZR.js";
24
24
 
25
25
  // src/vite/index.ts
26
26
  import { parse } from "querystring";
@@ -30,17 +30,16 @@ import * as path from "path";
30
30
  import { load } from "js-yaml";
31
31
 
32
32
  // src/vite/generate-glob.ts
33
- function generateGlob(name, collection) {
33
+ function generateGlob(name, collection, globOptions) {
34
34
  const patterns = mapGlobPatterns(getGlobPatterns(collection));
35
35
  const options = {
36
+ ...globOptions,
36
37
  query: {
38
+ ...globOptions?.query,
37
39
  collection: name
38
40
  },
39
41
  base: getGlobBase(collection)
40
42
  };
41
- if (collection.type === "meta") {
42
- options.import = "default";
43
- }
44
43
  return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(options, null, 2)})`;
45
44
  }
46
45
  function mapGlobPatterns(patterns) {
@@ -65,8 +64,38 @@ function getGlobBase(collection) {
65
64
  return dir;
66
65
  }
67
66
 
67
+ // src/vite/generate.ts
68
+ function docs(name, collection) {
69
+ const obj = [
70
+ ident(`doc: ${doc(name, collection.docs)}`),
71
+ ident(`meta: ${meta(name, collection.meta)}`)
72
+ ].join(",\n");
73
+ return `{
74
+ ${obj}
75
+ }`;
76
+ }
77
+ function doc(name, collection) {
78
+ if (collection.async) {
79
+ return `create.docLazy("${name}", ${generateGlob(name, collection, {
80
+ query: {
81
+ only: "frontmatter"
82
+ },
83
+ import: "frontmatter"
84
+ })}, ${generateGlob(name, collection)})`;
85
+ }
86
+ return `create.doc("${name}", ${generateGlob(name, collection)})`;
87
+ }
88
+ function meta(name, collection) {
89
+ return `create.meta("${name}", ${generateGlob(name, collection, {
90
+ import: "default"
91
+ })})`;
92
+ }
93
+
68
94
  // src/vite/index.ts
69
- var onlySchema = z.literal(["frontmatter", "all"]);
95
+ var querySchema = z.object({
96
+ only: z.literal(["frontmatter", "all"]).default("all"),
97
+ collection: z.string().optional()
98
+ }).loose();
70
99
  function mdx(config, options = {}) {
71
100
  const { generateIndexFile = true, configPath = "source.config.ts" } = options;
72
101
  const loaded = buildConfig(config);
@@ -105,9 +134,8 @@ function mdx(config, options = {}) {
105
134
  async function transformContent(file, query, value) {
106
135
  const matter = fumaMatter(value);
107
136
  const isDevelopment = this.environment.mode === "dev";
108
- const parsed = parse(query);
137
+ const parsed = querySchema.parse(parse(query));
109
138
  const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
110
- const only = parsed.only ? onlySchema.parse(parsed.only) : "all";
111
139
  let schema;
112
140
  let mdxOptions;
113
141
  switch (collection?.type) {
@@ -131,7 +159,7 @@ function mdx(config, options = {}) {
131
159
  `invalid frontmatter in ${file}`
132
160
  );
133
161
  }
134
- if (only === "frontmatter") {
162
+ if (parsed.only === "frontmatter") {
135
163
  return {
136
164
  code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
137
165
  map: null
@@ -177,35 +205,23 @@ function mdx(config, options = {}) {
177
205
  '/// <reference types="vite/client" />',
178
206
  `import { fromConfig } from 'fumadocs-mdx/runtime/vite';`,
179
207
  `import type * as Config from '${toImportPath(configPath, {
180
- relativeTo: outdir
208
+ relativeTo: outdir,
209
+ jsExtension: typeof generateIndexFile === "object" ? generateIndexFile.addJsExtension : void 0
181
210
  })}';`,
182
211
  "",
183
212
  `export const create = fromConfig<typeof Config>();`
184
213
  ];
185
- function docs(name, collection) {
186
- const args = [
187
- ident(`doc: ${generateGlob(name, collection.docs)}`),
188
- ident(`meta: ${generateGlob(name, collection.meta)}`)
189
- ].join(",\n");
190
- return `export const ${name} = create.docs("${name}", {
191
- ${args}
192
- });`;
193
- }
194
- function doc(name, collection) {
195
- return `export const ${name} = create.doc("${name}", ${generateGlob(name, collection)});`;
196
- }
197
- function meta(name, collection) {
198
- return `export const ${name} = create.meta("${name}", ${generateGlob(name, collection)});`;
199
- }
200
214
  for (const [name, collection] of loaded.collections.entries()) {
201
- lines.push("");
215
+ let body;
202
216
  if (collection.type === "docs") {
203
- lines.push(docs(name, collection));
217
+ body = docs(name, collection);
204
218
  } else if (collection.type === "meta") {
205
- lines.push(meta(name, collection));
219
+ body = meta(name, collection);
206
220
  } else {
207
- lines.push(doc(name, collection));
221
+ body = doc(name, collection);
208
222
  }
223
+ lines.push("");
224
+ lines.push(`export const ${name} = ${body};`);
209
225
  }
210
226
  await fs.writeFile(path.join(outdir, outFile), lines.join("\n"));
211
227
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "11.7.4",
3
+ "version": "11.8.0",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -18,6 +18,11 @@
18
18
  "types": "./dist/config/index.d.ts",
19
19
  "require": "./dist/config/index.cjs"
20
20
  },
21
+ "./config/zod-3": {
22
+ "import": "./dist/config/zod-3.js",
23
+ "types": "./dist/config/zod-3.d.ts",
24
+ "require": "./dist/config/zod-3.cjs"
25
+ },
21
26
  "./next": {
22
27
  "import": "./dist/next/index.js",
23
28
  "types": "./dist/next/index.d.ts",
@@ -54,7 +59,7 @@
54
59
  "@mdx-js/mdx": "^3.1.0",
55
60
  "@standard-schema/spec": "^1.0.0",
56
61
  "chokidar": "^4.0.3",
57
- "esbuild": "^0.25.8",
62
+ "esbuild": "^0.25.9",
58
63
  "estree-util-value-to-estree": "^3.4.0",
59
64
  "js-yaml": "^4.1.0",
60
65
  "lru-cache": "^11.1.0",
@@ -62,26 +67,26 @@
62
67
  "tinyexec": "^1.0.1",
63
68
  "tinyglobby": "^0.2.14",
64
69
  "unist-util-visit": "^5.0.0",
65
- "zod": "^4.0.15"
70
+ "zod": "^4.0.17"
66
71
  },
67
72
  "devDependencies": {
68
73
  "@types/js-yaml": "^4.0.9",
69
74
  "@types/mdast": "^4.0.3",
70
75
  "@types/mdx": "^2.0.13",
71
- "@types/node": "^24.2.0",
72
- "@types/react": "^19.1.9",
76
+ "@types/node": "^24.3.0",
77
+ "@types/react": "^19.1.10",
73
78
  "mdast-util-mdx-jsx": "^3.2.0",
74
- "next": "^15.4.6",
79
+ "next": "^15.5.0",
75
80
  "react": "^19.1.1",
76
- "rollup": "^4.46.2",
81
+ "rollup": "^4.46.3",
77
82
  "unified": "^11.0.5",
78
83
  "vfile": "^6.0.3",
79
- "vite": "^7.1.0",
80
- "webpack": "^5.101.0",
81
- "fumadocs-core": "15.6.9",
84
+ "vite": "^7.1.3",
85
+ "webpack": "^5.101.3",
86
+ "@fumadocs/mdx-remote": "1.4.0",
82
87
  "eslint-config-custom": "0.0.0",
83
- "tsconfig": "0.0.0",
84
- "@fumadocs/mdx-remote": "1.4.0"
88
+ "fumadocs-core": "15.7.0",
89
+ "tsconfig": "0.0.0"
85
90
  },
86
91
  "peerDependencies": {
87
92
  "@fumadocs/mdx-remote": "^1.4.0",