fumadocs-mdx 11.6.11 → 11.7.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 (34) hide show
  1. package/dist/{chunk-64MMPGML.js → chunk-2CSSQTP6.js} +1 -10
  2. package/dist/{chunk-SXOJYWZ3.js → chunk-2KBRPMAM.js} +1 -1
  3. package/dist/{chunk-6PDS7MUA.js → chunk-C5INPAZJ.js} +4 -4
  4. package/dist/{chunk-DRVUBK5B.js → chunk-GWR7KMRU.js} +13 -1
  5. package/dist/chunk-JPPCALFT.js +34 -0
  6. package/dist/{chunk-22SBT5SQ.js → chunk-ZOWJF3OH.js} +6 -6
  7. package/dist/config/index.cjs +5 -18
  8. package/dist/config/index.d.cts +3 -7
  9. package/dist/config/index.d.ts +3 -7
  10. package/dist/config/index.js +8 -12
  11. package/dist/{types-DVeuYiq5.d.cts → define-CCrinVBZ.d.cts} +37 -119
  12. package/dist/{types-DVeuYiq5.d.ts → define-CCrinVBZ.d.ts} +37 -119
  13. package/dist/index.d.cts +6 -7
  14. package/dist/index.d.ts +6 -7
  15. package/dist/loader-mdx.cjs +155 -134
  16. package/dist/loader-mdx.js +7 -10
  17. package/dist/mdx-options-UDV5WEFU.js +6 -0
  18. package/dist/next/index.cjs +196 -53
  19. package/dist/next/index.js +7 -30
  20. package/dist/runtime/async.cjs +167 -15
  21. package/dist/runtime/async.d.cts +5 -6
  22. package/dist/runtime/async.d.ts +5 -6
  23. package/dist/runtime/async.js +24 -15
  24. package/dist/runtime/vite.cjs +116 -0
  25. package/dist/runtime/vite.d.cts +47 -0
  26. package/dist/runtime/vite.d.ts +47 -0
  27. package/dist/runtime/vite.js +90 -0
  28. package/dist/{types-HIdjlLo0.d.ts → types-C0bKwtAx.d.ts} +38 -50
  29. package/dist/{types-BcUhOIxN.d.cts → types-CnslxmoO.d.cts} +38 -50
  30. package/dist/vite/index.cjs +384 -137
  31. package/dist/vite/index.d.cts +12 -3
  32. package/dist/vite/index.d.ts +12 -3
  33. package/dist/vite/index.js +176 -20
  34. package/package.json +19 -9
@@ -1,41 +1,25 @@
1
- import { MDXProps } from 'mdx/types';
1
+ import { z } from 'zod';
2
+ import { StandardSchemaV1 } from '@standard-schema/spec';
2
3
  import * as plugins from 'fumadocs-core/mdx-plugins';
3
- import { StructuredData } from 'fumadocs-core/mdx-plugins';
4
- import { TableOfContents } from 'fumadocs-core/server';
5
4
  import { ProcessorOptions } from '@mdx-js/mdx';
6
5
  import { Pluggable } from 'unified';
7
- import { FC } from 'react';
8
- import { z } from 'zod';
9
- import { StandardSchemaV1 } from '@standard-schema/spec';
10
- import { MDXOptions as MDXOptions$1 } from '@fumadocs/mdx-remote';
11
6
 
12
- interface MDXOptions extends ProcessorOptions {
13
- /**
14
- * Name of collection
15
- */
16
- collection?: string;
17
- /**
18
- * Specify a file path for source
19
- */
20
- filePath?: string;
21
- frontmatter?: Record<string, unknown>;
7
+ type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
8
+ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
9
+ rehypePlugins?: ResolvePlugins;
10
+ remarkPlugins?: ResolvePlugins;
22
11
  /**
23
- * Custom Vfile data
12
+ * Properties to export from `vfile.data`
24
13
  */
25
- data?: Record<string, unknown>;
26
- _compiler?: CompilerOptions;
27
- }
28
- interface CompilerOptions {
29
- addDependency: (file: string) => void;
30
- }
31
- declare module 'vfile' {
32
- interface DataMap {
33
- /**
34
- * The compiler object from loader
35
- */
36
- _compiler?: CompilerOptions;
37
- }
38
- }
14
+ valueToExport?: string[];
15
+ remarkStructureOptions?: plugins.StructureOptions | false;
16
+ remarkHeadingOptions?: plugins.RemarkHeadingOptions;
17
+ remarkImageOptions?: plugins.RemarkImageOptions | false;
18
+ remarkCodeTabOptions?: plugins.RemarkCodeTabOptions | false;
19
+ remarkNpmOptions?: plugins.RemarkNpmOptions | false;
20
+ rehypeCodeOptions?: plugins.RehypeCodeOptions | false;
21
+ };
22
+ declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, remarkNpmOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
39
23
 
40
24
  declare const metaSchema: z.ZodObject<{
41
25
  title: z.ZodOptional<z.ZodString>;
@@ -54,6 +38,7 @@ declare const frontmatterSchema: z.ZodObject<{
54
38
  }, z.core.$strip>;
55
39
 
56
40
  type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
41
+ type AnyCollection = DocsCollection | DocCollection | MetaCollection;
57
42
  interface BaseCollection {
58
43
  /**
59
44
  * Directories to scan
@@ -75,7 +60,7 @@ interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> ext
75
60
  }
76
61
  interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection {
77
62
  type: 'doc';
78
- mdxOptions?: MDXOptions;
63
+ mdxOptions?: ProcessorOptions;
79
64
  /**
80
65
  * Load files with async
81
66
  */
@@ -87,105 +72,38 @@ interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Asyn
87
72
  }
88
73
  interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> {
89
74
  type: 'docs';
90
- dir: string | string[];
75
+ dir: string;
91
76
  docs: DocCollection<DocSchema, Async>;
92
77
  meta: MetaCollection<MetaSchema>;
93
78
  }
94
- declare function defineCollections<T extends 'doc' | 'meta', Schema extends StandardSchemaV1 = StandardSchemaV1<unknown, any>, Async extends boolean = false>(options: {
95
- type: T;
96
- } & (T extends 'doc' ? DocCollection<Schema, Async> : MetaCollection<Schema>)): {
97
- type: T;
98
- _type: {
99
- async: Async;
100
- schema: Schema;
101
- };
102
- };
103
- declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema, Async extends boolean = false>(options?: {
104
- /**
105
- * The directory to scan files
106
- *
107
- * @defaultValue 'content/docs'
108
- */
109
- dir?: string | string[];
110
- docs?: Omit<DocCollection<DocSchema, Async>, 'dir' | 'type'>;
111
- meta?: Omit<MetaCollection<MetaSchema>, 'dir' | 'type'>;
112
- }): {
113
- type: 'docs';
114
- docs: {
115
- type: 'doc';
116
- _type: {
117
- schema: DocSchema;
118
- async: Async;
119
- };
120
- };
121
- meta: {
122
- type: 'meta';
123
- _type: {
124
- schema: MetaSchema;
125
- async: false;
126
- };
127
- };
128
- };
129
- declare function defineConfig(config?: GlobalConfig): GlobalConfig;
130
-
131
- interface LoadedConfig {
132
- collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
133
- global?: GlobalConfig;
134
- _mdx_loader?: {
135
- cachedOptions?: ProcessorOptions;
136
- };
137
- _mdx_async?: {
138
- cachedMdxOptions?: MDXOptions$1;
139
- };
140
- }
141
-
142
- type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
143
- type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
144
- rehypePlugins?: ResolvePlugins;
145
- remarkPlugins?: ResolvePlugins;
146
- /**
147
- * Properties to export from `vfile.data`
148
- */
149
- valueToExport?: string[];
150
- remarkStructureOptions?: plugins.StructureOptions | false;
151
- remarkHeadingOptions?: plugins.RemarkHeadingOptions;
152
- remarkImageOptions?: plugins.RemarkImageOptions | false;
153
- remarkCodeTabOptions?: plugins.RemarkCodeTabOptions | false;
154
- remarkNpmOptions?: plugins.RemarkNpmOptions | false;
155
- rehypeCodeOptions?: plugins.RehypeCodeOptions | false;
156
- };
157
- declare function loadDefaultOptions(config: LoadedConfig): Promise<ProcessorOptions>;
158
-
79
+ type GlobalConfigMDXOptions = ({
80
+ preset?: 'fumadocs';
81
+ } & DefaultMDXOptions) | ({
82
+ preset: 'minimal';
83
+ } & ProcessorOptions);
159
84
  interface GlobalConfig {
160
85
  /**
161
86
  * Configure global MDX options
162
87
  */
163
- mdxOptions?: DefaultMDXOptions | (() => DefaultMDXOptions | Promise<DefaultMDXOptions>);
88
+ mdxOptions?: GlobalConfigMDXOptions | (() => Promise<GlobalConfigMDXOptions>);
164
89
  /**
165
90
  * Fetch last modified time with specified version control
166
91
  * @defaultValue 'none'
167
92
  */
168
93
  lastModifiedTime?: 'git' | 'none';
169
94
  }
170
- interface FileInfo {
171
- path: string;
172
- absolutePath: string;
173
- }
174
- interface MarkdownProps {
175
- body: FC<MDXProps>;
176
- structuredData: StructuredData;
177
- toc: TableOfContents;
178
- _exports: Record<string, unknown>;
179
- /**
180
- * Only available when `lastModifiedTime` is enabled on MDX loader
181
- */
182
- lastModified?: Date;
183
- }
184
- interface BaseCollectionEntry {
95
+ declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = false>(options: DocCollection<Schema, Async>): DocCollection<Schema, Async>;
96
+ declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(options: MetaCollection<Schema>): MetaCollection<Schema>;
97
+ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema, Async extends boolean = false>(options?: {
185
98
  /**
186
- * Raw file path of collection entry, including absolute path (not normalized).
99
+ * The directory to scan files
100
+ *
101
+ * @defaultValue 'content/docs'
187
102
  */
188
- _file: FileInfo;
189
- }
103
+ dir?: string;
104
+ docs?: Omit<DocCollection<DocSchema, Async>, 'dir' | 'type'>;
105
+ meta?: Omit<MetaCollection<MetaSchema>, 'dir' | 'type'>;
106
+ }): DocsCollection<DocSchema, MetaSchema, Async>;
107
+ declare function defineConfig(config?: GlobalConfig): GlobalConfig;
190
108
 
191
- export { type BaseCollectionEntry as B, type CollectionSchema as C, type DefaultMDXOptions as D, type FileInfo as F, type GlobalConfig as G, type LoadedConfig as L, type MarkdownProps as M, type BaseCollection as a, type MetaCollection as b, type DocCollection as c, type DocsCollection as d, defineCollections as e, frontmatterSchema as f, defineDocs as g, defineConfig as h, loadDefaultOptions as l, metaSchema as m };
109
+ export { type AnyCollection as A, type BaseCollection as B, type CollectionSchema as C, type DocCollection as D, type GlobalConfig as G, type MetaCollection as M, type DocsCollection as a, type DefaultMDXOptions as b, defineDocs as c, defineCollections as d, defineConfig as e, frontmatterSchema as f, getDefaultMDXOptions as g, metaSchema as m };
package/dist/index.d.cts CHANGED
@@ -1,15 +1,14 @@
1
1
  import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
- import { B as BaseCollectionEntry } from './types-DVeuYiq5.cjs';
3
- import { R as Runtime } from './types-BcUhOIxN.cjs';
4
- import 'mdx/types';
2
+ import { R as Runtime, B as BaseCollectionEntry } from './types-CnslxmoO.cjs';
3
+ import '@standard-schema/spec';
4
+ import './define-CCrinVBZ.cjs';
5
+ import 'zod';
5
6
  import 'fumadocs-core/mdx-plugins';
6
- import 'fumadocs-core/server';
7
7
  import '@mdx-js/mdx';
8
8
  import 'unified';
9
9
  import 'react';
10
- import 'zod';
11
- import '@standard-schema/spec';
12
- import '@fumadocs/mdx-remote';
10
+ import 'mdx/types';
11
+ import 'fumadocs-core/server';
13
12
 
14
13
  declare const _runtime: Runtime;
15
14
  declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
package/dist/index.d.ts CHANGED
@@ -1,15 +1,14 @@
1
1
  import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
- import { B as BaseCollectionEntry } from './types-DVeuYiq5.js';
3
- import { R as Runtime } from './types-HIdjlLo0.js';
4
- import 'mdx/types';
2
+ import { R as Runtime, B as BaseCollectionEntry } from './types-C0bKwtAx.js';
3
+ import '@standard-schema/spec';
4
+ import './define-CCrinVBZ.js';
5
+ import 'zod';
5
6
  import 'fumadocs-core/mdx-plugins';
6
- import 'fumadocs-core/server';
7
7
  import '@mdx-js/mdx';
8
8
  import 'unified';
9
9
  import 'react';
10
- import 'zod';
11
- import '@standard-schema/spec';
12
- import '@fumadocs/mdx-remote';
10
+ import 'mdx/types';
11
+ import 'fumadocs-core/server';
13
12
 
14
13
  declare const _runtime: Runtime;
15
14
  declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,6 +30,134 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // src/mdx-plugins/remark-exports.ts
34
+ function remarkMdxExport({ values }) {
35
+ return (tree, vfile) => {
36
+ for (const name of values) {
37
+ if (!(name in vfile.data)) return;
38
+ tree.children.unshift(getMdastExport(name, vfile.data[name]));
39
+ }
40
+ };
41
+ }
42
+ function getMdastExport(name, value) {
43
+ return {
44
+ type: "mdxjsEsm",
45
+ value: "",
46
+ data: {
47
+ estree: {
48
+ type: "Program",
49
+ sourceType: "module",
50
+ body: [
51
+ {
52
+ type: "ExportNamedDeclaration",
53
+ specifiers: [],
54
+ source: null,
55
+ declaration: {
56
+ type: "VariableDeclaration",
57
+ kind: "let",
58
+ declarations: [
59
+ {
60
+ type: "VariableDeclarator",
61
+ id: {
62
+ type: "Identifier",
63
+ name
64
+ },
65
+ init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
66
+ }
67
+ ]
68
+ }
69
+ }
70
+ ]
71
+ }
72
+ }
73
+ };
74
+ }
75
+ var import_estree_util_value_to_estree;
76
+ var init_remark_exports = __esm({
77
+ "src/mdx-plugins/remark-exports.ts"() {
78
+ "use strict";
79
+ import_estree_util_value_to_estree = require("estree-util-value-to-estree");
80
+ }
81
+ });
82
+
83
+ // src/utils/mdx-options.ts
84
+ var mdx_options_exports = {};
85
+ __export(mdx_options_exports, {
86
+ getDefaultMDXOptions: () => getDefaultMDXOptions
87
+ });
88
+ function pluginOption(def, options = []) {
89
+ const list = def(Array.isArray(options) ? options : []).filter(
90
+ Boolean
91
+ );
92
+ if (typeof options === "function") {
93
+ return options(list);
94
+ }
95
+ return list;
96
+ }
97
+ function getDefaultMDXOptions({
98
+ valueToExport = [],
99
+ rehypeCodeOptions,
100
+ remarkImageOptions,
101
+ remarkHeadingOptions,
102
+ remarkStructureOptions,
103
+ remarkCodeTabOptions,
104
+ remarkNpmOptions,
105
+ ...mdxOptions
106
+ }) {
107
+ const mdxExports = [
108
+ "structuredData",
109
+ "frontmatter",
110
+ "lastModified",
111
+ ...valueToExport
112
+ ];
113
+ const remarkPlugins = pluginOption(
114
+ (v) => [
115
+ plugins.remarkGfm,
116
+ [
117
+ plugins.remarkHeading,
118
+ {
119
+ generateToc: false,
120
+ ...remarkHeadingOptions
121
+ }
122
+ ],
123
+ remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
124
+ "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
125
+ plugins.remarkCodeTab,
126
+ remarkCodeTabOptions
127
+ ],
128
+ "remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
129
+ ...v,
130
+ remarkStructureOptions !== false && [
131
+ plugins.remarkStructure,
132
+ remarkStructureOptions
133
+ ],
134
+ [remarkMdxExport, { values: mdxExports }]
135
+ ],
136
+ mdxOptions.remarkPlugins
137
+ );
138
+ const rehypePlugins = pluginOption(
139
+ (v) => [
140
+ rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
141
+ ...v,
142
+ plugins.rehypeToc
143
+ ],
144
+ mdxOptions.rehypePlugins
145
+ );
146
+ return {
147
+ ...mdxOptions,
148
+ remarkPlugins,
149
+ rehypePlugins
150
+ };
151
+ }
152
+ var plugins;
153
+ var init_mdx_options = __esm({
154
+ "src/utils/mdx-options.ts"() {
155
+ "use strict";
156
+ plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
157
+ init_remark_exports();
158
+ }
159
+ });
160
+
30
161
  // src/loader-mdx.ts
31
162
  var loader_mdx_exports = {};
32
163
  __export(loader_mdx_exports, {
@@ -68,11 +199,23 @@ function buildConfig(config) {
68
199
  null
69
200
  ];
70
201
  }
202
+ let cachedMdxOptions;
71
203
  return [
72
204
  null,
73
205
  {
74
206
  global: globalConfig,
75
- collections
207
+ collections,
208
+ async getDefaultMDXOptions() {
209
+ if (cachedMdxOptions) return cachedMdxOptions;
210
+ const input = this.global?.mdxOptions;
211
+ async function uncached() {
212
+ const options = typeof input === "function" ? await input() : input;
213
+ const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
214
+ if (options?.preset === "minimal") return options;
215
+ return getDefaultMDXOptions2(options ?? {});
216
+ }
217
+ return cachedMdxOptions = uncached();
218
+ }
76
219
  }
77
220
  ];
78
221
  }
@@ -222,10 +365,10 @@ ${e instanceof Error ? e.message : String(e)}`
222
365
  // src/utils/build-mdx.ts
223
366
  var cache2 = /* @__PURE__ */ new Map();
224
367
  async function buildMDX(cacheKey, source, options) {
225
- const { filePath, frontmatter, data, ...rest } = options;
368
+ const { filePath, frontmatter, data, _compiler, ...rest } = options;
226
369
  let format = options.format;
227
- if (!format && filePath) {
228
- format = filePath.endsWith(".mdx") ? "mdx" : "md";
370
+ if (filePath) {
371
+ format ??= filePath.endsWith(".mdx") ? "mdx" : "md";
229
372
  }
230
373
  format ??= "mdx";
231
374
  const key = `${cacheKey}:${format}`;
@@ -245,7 +388,7 @@ async function buildMDX(cacheKey, source, options) {
245
388
  data: {
246
389
  ...data,
247
390
  frontmatter,
248
- _compiler: options._compiler
391
+ _compiler
249
392
  }
250
393
  });
251
394
  }
@@ -294,16 +437,16 @@ var frontmatterSchema = import_zod.z.object({
294
437
  });
295
438
  var ValidationError = class extends Error {
296
439
  constructor(message, issues) {
297
- super(message);
440
+ super(
441
+ `${message}:
442
+ ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`
443
+ );
444
+ this.title = message;
298
445
  this.issues = issues;
299
446
  }
300
- toString() {
301
- return `${this.message}:
302
- ${this.issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
303
- }
304
447
  toStringFormatted() {
305
448
  return [
306
- import_picocolors.default.bold(`[MDX] ${this.message}:`),
449
+ import_picocolors.default.bold(`[MDX] ${this.title}:`),
307
450
  ...this.issues.map(
308
451
  (issue) => import_picocolors.default.redBright(
309
452
  `- ${import_picocolors.default.bold(issue.path?.join(".") ?? "*")}: ${issue.message}`
@@ -337,128 +480,6 @@ function countLines(s) {
337
480
  return num;
338
481
  }
339
482
 
340
- // src/utils/mdx-options.ts
341
- var plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
342
-
343
- // src/mdx-plugins/remark-exports.ts
344
- var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
345
- function remarkMdxExport({ values }) {
346
- return (tree, vfile) => {
347
- for (const name of values) {
348
- if (!(name in vfile.data)) return;
349
- tree.children.unshift(getMdastExport(name, vfile.data[name]));
350
- }
351
- };
352
- }
353
- function getMdastExport(name, value) {
354
- return {
355
- type: "mdxjsEsm",
356
- value: "",
357
- data: {
358
- estree: {
359
- type: "Program",
360
- sourceType: "module",
361
- body: [
362
- {
363
- type: "ExportNamedDeclaration",
364
- specifiers: [],
365
- source: null,
366
- declaration: {
367
- type: "VariableDeclaration",
368
- kind: "let",
369
- declarations: [
370
- {
371
- type: "VariableDeclarator",
372
- id: {
373
- type: "Identifier",
374
- name
375
- },
376
- init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
377
- }
378
- ]
379
- }
380
- }
381
- ]
382
- }
383
- }
384
- };
385
- }
386
-
387
- // src/utils/mdx-options.ts
388
- function pluginOption(def, options = []) {
389
- const list = def(Array.isArray(options) ? options : []).filter(
390
- Boolean
391
- );
392
- if (typeof options === "function") {
393
- return options(list);
394
- }
395
- return list;
396
- }
397
- function getDefaultMDXOptions({
398
- valueToExport = [],
399
- rehypeCodeOptions,
400
- remarkImageOptions,
401
- remarkHeadingOptions,
402
- remarkStructureOptions,
403
- remarkCodeTabOptions,
404
- remarkNpmOptions,
405
- ...mdxOptions
406
- }) {
407
- const mdxExports = [
408
- "structuredData",
409
- "frontmatter",
410
- "lastModified",
411
- ...valueToExport
412
- ];
413
- const remarkPlugins = pluginOption(
414
- (v) => [
415
- plugins.remarkGfm,
416
- [
417
- plugins.remarkHeading,
418
- {
419
- generateToc: false,
420
- ...remarkHeadingOptions
421
- }
422
- ],
423
- remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
424
- "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
425
- plugins.remarkCodeTab,
426
- remarkCodeTabOptions
427
- ],
428
- "remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
429
- ...v,
430
- remarkStructureOptions !== false && [
431
- plugins.remarkStructure,
432
- remarkStructureOptions
433
- ],
434
- [remarkMdxExport, { values: mdxExports }]
435
- ],
436
- mdxOptions.remarkPlugins
437
- );
438
- const rehypePlugins = pluginOption(
439
- (v) => [
440
- rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
441
- ...v,
442
- plugins.rehypeToc
443
- ],
444
- mdxOptions.rehypePlugins
445
- );
446
- return {
447
- ...mdxOptions,
448
- remarkPlugins,
449
- rehypePlugins
450
- };
451
- }
452
- async function loadDefaultOptions(config) {
453
- const input = config.global?.mdxOptions;
454
- config._mdx_loader ??= {};
455
- const mdxLoader = config._mdx_loader;
456
- if (!mdxLoader.cachedOptions) {
457
- mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions(await input()) : getDefaultMDXOptions(input ?? {});
458
- }
459
- return mdxLoader.cachedOptions;
460
- }
461
-
462
483
  // src/loader-mdx.ts
463
484
  async function loader(source, callback) {
464
485
  this.cacheable(true);
@@ -477,7 +498,7 @@ async function loader(source, callback) {
477
498
  collection = void 0;
478
499
  }
479
500
  let data = matter.data;
480
- const mdxOptions = collection?.mdxOptions ?? await loadDefaultOptions(config);
501
+ const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
481
502
  if (collection?.schema) {
482
503
  try {
483
504
  data = await validate(
@@ -2,19 +2,16 @@ import {
2
2
  getConfigHash,
3
3
  getGitTimestamp,
4
4
  loadConfig
5
- } from "./chunk-SXOJYWZ3.js";
6
- import {
7
- ValidationError,
8
- validate
9
- } from "./chunk-22SBT5SQ.js";
5
+ } from "./chunk-2KBRPMAM.js";
10
6
  import {
11
7
  buildMDX,
12
8
  countLines
13
- } from "./chunk-6PDS7MUA.js";
14
- import "./chunk-DRVUBK5B.js";
9
+ } from "./chunk-C5INPAZJ.js";
10
+ import "./chunk-GWR7KMRU.js";
15
11
  import {
16
- loadDefaultOptions
17
- } from "./chunk-64MMPGML.js";
12
+ ValidationError,
13
+ validate
14
+ } from "./chunk-ZOWJF3OH.js";
18
15
  import "./chunk-AVMO2SRO.js";
19
16
  import {
20
17
  fumaMatter
@@ -40,7 +37,7 @@ async function loader(source, callback) {
40
37
  collection = void 0;
41
38
  }
42
39
  let data = matter.data;
43
- const mdxOptions = collection?.mdxOptions ?? await loadDefaultOptions(config);
40
+ const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
44
41
  if (collection?.schema) {
45
42
  try {
46
43
  data = await validate(
@@ -0,0 +1,6 @@
1
+ import {
2
+ getDefaultMDXOptions
3
+ } from "./chunk-2CSSQTP6.js";
4
+ export {
5
+ getDefaultMDXOptions
6
+ };