fumadocs-mdx 11.10.0 → 12.0.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 (71) hide show
  1. package/dist/bin.cjs +953 -0
  2. package/dist/bin.d.cts +1 -0
  3. package/dist/bin.d.ts +1 -0
  4. package/dist/bin.js +16 -0
  5. package/dist/{browser-B2G8uAF2.d.cts → browser-D5lvL8vv.d.ts} +51 -4
  6. package/dist/{browser-DrH7tKRi.d.ts → browser-DjWADqp8.d.cts} +51 -4
  7. package/dist/bun/index.cjs +129 -109
  8. package/dist/bun/index.js +9 -6
  9. package/dist/chunk-3M4SHY6K.js +80 -0
  10. package/dist/chunk-6Y5JDZHD.js +65 -0
  11. package/dist/{chunk-NUDEC6C5.js → chunk-AUOOMFAI.js} +28 -22
  12. package/dist/chunk-IQAEAI4P.js +66 -0
  13. package/dist/{chunk-5XJM5RPV.js → chunk-KGUBBRL6.js} +13 -13
  14. package/dist/{chunk-SVTXMVLQ.js → chunk-KTDVTBMH.js} +1 -1
  15. package/dist/chunk-POXTQZ4D.js +60 -0
  16. package/dist/chunk-SWNOXPYJ.js +142 -0
  17. package/dist/{chunk-COQ4VMK2.js → chunk-TLD6JMT6.js} +28 -61
  18. package/dist/{chunk-NVX3U5YE.js → chunk-VXEBLM4X.js} +2 -2
  19. package/dist/{chunk-QVZ7JH4H.js → chunk-YC25YEBF.js} +1 -1
  20. package/dist/chunk-ZLCSVXCD.js +10 -0
  21. package/dist/config/index.cjs +18 -97
  22. package/dist/config/index.d.cts +1 -1
  23. package/dist/config/index.d.ts +1 -1
  24. package/dist/config/index.js +48 -9
  25. package/dist/{define-BH4bnHQl.d.cts → define--6HQ1ehX.d.cts} +18 -3
  26. package/dist/{define-BH4bnHQl.d.ts → define--6HQ1ehX.d.ts} +18 -3
  27. package/dist/loader-mdx.cjs +127 -139
  28. package/dist/loader-mdx.js +7 -6
  29. package/dist/next/index.cjs +44 -269
  30. package/dist/next/index.js +30 -46
  31. package/dist/node/loader.cjs +131 -143
  32. package/dist/node/loader.js +7 -6
  33. package/dist/postinstall-U7VROOY7.js +9 -0
  34. package/dist/{mdx-options-T73E4LQB.js → preset-WFEORCAB.js} +1 -1
  35. package/dist/runtime/{async.cjs → next/async.cjs} +202 -154
  36. package/dist/runtime/{async.d.cts → next/async.d.cts} +3 -3
  37. package/dist/runtime/{async.d.ts → next/async.d.ts} +3 -3
  38. package/dist/runtime/next/async.js +92 -0
  39. package/dist/{index.cjs → runtime/next/index.cjs} +35 -26
  40. package/dist/runtime/next/index.d.cts +30 -0
  41. package/dist/runtime/next/index.d.ts +30 -0
  42. package/dist/{index.js → runtime/next/index.js} +2 -1
  43. package/dist/runtime/vite/browser.d.cts +2 -3
  44. package/dist/runtime/vite/browser.d.ts +2 -3
  45. package/dist/runtime/vite/server.cjs +67 -21
  46. package/dist/runtime/vite/server.d.cts +14 -28
  47. package/dist/runtime/vite/server.d.ts +14 -28
  48. package/dist/runtime/vite/server.js +61 -21
  49. package/dist/shared-0QIuV0XZ.d.ts +70 -0
  50. package/dist/shared-CqgMnt9h.d.cts +70 -0
  51. package/dist/{types-DN9KrG7R.d.ts → types-DLIAvrgC.d.ts} +6 -32
  52. package/dist/{types-DT83Ijs6.d.cts → types-Dl8HLbm5.d.cts} +6 -32
  53. package/dist/vite/index.cjs +201 -123
  54. package/dist/vite/index.d.cts +4 -1
  55. package/dist/vite/index.d.ts +4 -1
  56. package/dist/vite/index.js +13 -9
  57. package/package.json +11 -17
  58. package/bin.js +0 -5
  59. package/dist/build-mdx-DnC1jKvn.d.cts +0 -46
  60. package/dist/build-mdx-DnC1jKvn.d.ts +0 -46
  61. package/dist/chunk-2HKRTQYP.js +0 -154
  62. package/dist/chunk-GBMFGEC7.js +0 -57
  63. package/dist/chunk-QQWCBFFE.js +0 -40
  64. package/dist/chunk-SMSNZ6N5.js +0 -155
  65. package/dist/config/zod-3.cjs +0 -422
  66. package/dist/config/zod-3.d.cts +0 -53
  67. package/dist/config/zod-3.d.ts +0 -53
  68. package/dist/config/zod-3.js +0 -40
  69. package/dist/index.d.cts +0 -26
  70. package/dist/index.d.ts +0 -26
  71. package/dist/runtime/async.js +0 -72
@@ -1,5 +1,7 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
+ declare function postInstall(configPath?: string, outDir?: string, addJsExtension?: boolean): Promise<void>;
4
+
3
5
  interface PluginOptions {
4
6
  /**
5
7
  * Automatically generate index files for accessing files with `import.meta.glob`.
@@ -17,6 +19,7 @@ interface PluginOptions {
17
19
  */
18
20
  configPath?: string;
19
21
  }
22
+
20
23
  declare function mdx(config: Record<string, unknown>, options?: PluginOptions): Plugin;
21
24
 
22
- export { type PluginOptions, mdx as default };
25
+ export { type PluginOptions, mdx as default, postInstall };
@@ -1,5 +1,7 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
+ declare function postInstall(configPath?: string, outDir?: string, addJsExtension?: boolean): Promise<void>;
4
+
3
5
  interface PluginOptions {
4
6
  /**
5
7
  * Automatically generate index files for accessing files with `import.meta.glob`.
@@ -17,6 +19,7 @@ interface PluginOptions {
17
19
  */
18
20
  configPath?: string;
19
21
  }
22
+
20
23
  declare function mdx(config: Record<string, unknown>, options?: PluginOptions): Plugin;
21
24
 
22
- export { type PluginOptions, mdx as default };
25
+ export { type PluginOptions, mdx as default, postInstall };
@@ -1,22 +1,25 @@
1
1
  import {
2
- entry
3
- } from "../chunk-COQ4VMK2.js";
2
+ entry,
3
+ postInstall
4
+ } from "../chunk-TLD6JMT6.js";
5
+ import "../chunk-6Y5JDZHD.js";
4
6
  import {
5
7
  toVite
6
- } from "../chunk-NVX3U5YE.js";
8
+ } from "../chunk-VXEBLM4X.js";
7
9
  import {
8
10
  createMdxLoader,
9
11
  resolvedConfig
10
- } from "../chunk-5XJM5RPV.js";
12
+ } from "../chunk-KGUBBRL6.js";
11
13
  import {
12
14
  ValidationError,
13
15
  validate
14
- } from "../chunk-2HKRTQYP.js";
15
- import "../chunk-QQWCBFFE.js";
16
- import "../chunk-SVTXMVLQ.js";
16
+ } from "../chunk-IQAEAI4P.js";
17
+ import "../chunk-POXTQZ4D.js";
18
+ import "../chunk-SWNOXPYJ.js";
19
+ import "../chunk-KTDVTBMH.js";
17
20
  import {
18
21
  buildConfig
19
- } from "../chunk-QVZ7JH4H.js";
22
+ } from "../chunk-YC25YEBF.js";
20
23
  import "../chunk-VWJKRQZR.js";
21
24
 
22
25
  // src/vite/index.ts
@@ -112,5 +115,6 @@ function mdx(config, options = {}) {
112
115
  };
113
116
  }
114
117
  export {
115
- mdx as default
118
+ mdx as default,
119
+ postInstall
116
120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "11.10.0",
3
+ "version": "12.0.0",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -18,11 +18,6 @@
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
- },
26
21
  "./next": {
27
22
  "import": "./dist/next/index.js",
28
23
  "types": "./dist/next/index.d.ts",
@@ -33,9 +28,13 @@
33
28
  "types": "./dist/vite/index.d.ts",
34
29
  "require": "./dist/vite/index.cjs"
35
30
  },
31
+ ".": {
32
+ "import": "./dist/runtime/next/index.js",
33
+ "types": "./dist/runtime/next/index.d.ts"
34
+ },
36
35
  "./runtime/async": {
37
- "import": "./dist/runtime/async.js",
38
- "types": "./dist/runtime/async.d.ts"
36
+ "import": "./dist/runtime/next/async.js",
37
+ "types": "./dist/runtime/next/async.d.ts"
39
38
  },
40
39
  "./runtime/vite": {
41
40
  "browser": "./dist/runtime/vite/browser.js",
@@ -49,20 +48,14 @@
49
48
  "./bun": {
50
49
  "import": "./dist/bun/index.js",
51
50
  "types": "./dist/bun/index.d.ts"
52
- },
53
- ".": {
54
- "import": "./dist/index.js",
55
- "types": "./dist/index.d.ts",
56
- "require": "./dist/index.cjs"
57
51
  }
58
52
  },
59
53
  "main": "./dist/index.js",
60
54
  "types": "./dist/index.d.ts",
61
- "bin": "./bin.js",
55
+ "bin": "./dist/bin.js",
62
56
  "files": [
63
57
  "dist/*",
64
- "loader-mdx.cjs",
65
- "bin.js"
58
+ "loader-mdx.cjs"
66
59
  ],
67
60
  "dependencies": {
68
61
  "@mdx-js/mdx": "^3.1.1",
@@ -72,6 +65,7 @@
72
65
  "estree-util-value-to-estree": "^3.4.0",
73
66
  "js-yaml": "^4.1.0",
74
67
  "lru-cache": "^11.2.1",
68
+ "mdast-util-to-markdown": "^2.1.2",
75
69
  "picocolors": "^1.1.1",
76
70
  "remark-mdx": "^3.1.1",
77
71
  "remark-parse": "^11.0.0",
@@ -97,7 +91,7 @@
97
91
  "webpack": "^5.101.3",
98
92
  "@fumadocs/mdx-remote": "1.4.0",
99
93
  "eslint-config-custom": "0.0.0",
100
- "fumadocs-core": "15.7.12",
94
+ "fumadocs-core": "15.7.13",
101
95
  "tsconfig": "0.0.0"
102
96
  },
103
97
  "peerDependencies": {
package/bin.js DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { postInstall } from './dist/next/index.js';
4
-
5
- void postInstall(process.argv[2], process.argv[3]);
@@ -1,46 +0,0 @@
1
- import { createProcessor } from '@mdx-js/mdx';
2
- import { StructuredData } from 'fumadocs-core/mdx-plugins';
3
- import { TableOfContents } from 'fumadocs-core/server';
4
- import { FC } from 'react';
5
- import { MDXProps } from 'mdx/types';
6
-
7
- declare module 'vfile' {
8
- interface DataMap {
9
- extractedReferences: ExtractedReference[];
10
- }
11
- }
12
- interface ExtractedReference {
13
- href: string;
14
- }
15
-
16
- type Processor = ReturnType<typeof createProcessor>;
17
- interface CompilerOptions {
18
- addDependency: (file: string) => void;
19
- }
20
- interface CompiledMDXProperties<Frontmatter = Record<string, unknown>> {
21
- frontmatter: Frontmatter;
22
- structuredData: StructuredData;
23
- toc: TableOfContents;
24
- default: FC<MDXProps>;
25
- /**
26
- * Only available when `lastModifiedTime` is enabled on MDX loader
27
- */
28
- lastModified?: Date;
29
- extractedReferences?: ExtractedReference[];
30
- }
31
-
32
- declare module 'vfile' {
33
- interface DataMap {
34
- /**
35
- * [Fumadocs MDX] raw frontmatter, you can modify it
36
- */
37
- frontmatter?: Record<string, unknown>;
38
- /**
39
- * [Fumadocs MDX] The compiler object from loader
40
- */
41
- _compiler?: CompilerOptions;
42
- _getProcessor?: (format: 'md' | 'mdx') => Processor;
43
- }
44
- }
45
-
46
- export type { CompiledMDXProperties as C };
@@ -1,46 +0,0 @@
1
- import { createProcessor } from '@mdx-js/mdx';
2
- import { StructuredData } from 'fumadocs-core/mdx-plugins';
3
- import { TableOfContents } from 'fumadocs-core/server';
4
- import { FC } from 'react';
5
- import { MDXProps } from 'mdx/types';
6
-
7
- declare module 'vfile' {
8
- interface DataMap {
9
- extractedReferences: ExtractedReference[];
10
- }
11
- }
12
- interface ExtractedReference {
13
- href: string;
14
- }
15
-
16
- type Processor = ReturnType<typeof createProcessor>;
17
- interface CompilerOptions {
18
- addDependency: (file: string) => void;
19
- }
20
- interface CompiledMDXProperties<Frontmatter = Record<string, unknown>> {
21
- frontmatter: Frontmatter;
22
- structuredData: StructuredData;
23
- toc: TableOfContents;
24
- default: FC<MDXProps>;
25
- /**
26
- * Only available when `lastModifiedTime` is enabled on MDX loader
27
- */
28
- lastModified?: Date;
29
- extractedReferences?: ExtractedReference[];
30
- }
31
-
32
- declare module 'vfile' {
33
- interface DataMap {
34
- /**
35
- * [Fumadocs MDX] raw frontmatter, you can modify it
36
- */
37
- frontmatter?: Record<string, unknown>;
38
- /**
39
- * [Fumadocs MDX] The compiler object from loader
40
- */
41
- _compiler?: CompilerOptions;
42
- _getProcessor?: (format: 'md' | 'mdx') => Processor;
43
- }
44
- }
45
-
46
- export type { CompiledMDXProperties as C };
@@ -1,154 +0,0 @@
1
- import {
2
- buildConfig
3
- } from "./chunk-QVZ7JH4H.js";
4
-
5
- // src/utils/validation.ts
6
- import picocolors from "picocolors";
7
- var ValidationError = class extends Error {
8
- constructor(message, issues) {
9
- super(
10
- `${message}:
11
- ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`
12
- );
13
- this.title = message;
14
- this.issues = issues;
15
- }
16
- toStringFormatted() {
17
- return [
18
- picocolors.bold(`[MDX] ${this.title}:`),
19
- ...this.issues.map(
20
- (issue) => picocolors.redBright(
21
- `- ${picocolors.bold(issue.path?.join(".") ?? "*")}: ${issue.message}`
22
- )
23
- )
24
- ].join("\n");
25
- }
26
- };
27
- async function validate(schema, data, context, errorMessage) {
28
- if (typeof schema === "function" && !("~standard" in schema)) {
29
- schema = schema(context);
30
- }
31
- if ("~standard" in schema) {
32
- const result = await schema["~standard"].validate(
33
- data
34
- );
35
- if (result.issues) {
36
- throw new ValidationError(errorMessage, result.issues);
37
- }
38
- return result.value;
39
- }
40
- return data;
41
- }
42
-
43
- // src/utils/config.ts
44
- import * as fs from "fs/promises";
45
- import * as path from "path";
46
- import { pathToFileURL } from "url";
47
- function findConfigFile() {
48
- return path.resolve("source.config.ts");
49
- }
50
- var cache = null;
51
- async function isZod3() {
52
- try {
53
- const content = JSON.parse(
54
- (await fs.readFile("node_modules/zod/package.json")).toString()
55
- );
56
- const version = content.version;
57
- return typeof version === "string" && version.startsWith("3.");
58
- } catch {
59
- return false;
60
- }
61
- }
62
- function createCompatZodPlugin() {
63
- return {
64
- name: "replace-zod-import",
65
- async setup(build) {
66
- const usingZod3 = await isZod3();
67
- if (!usingZod3) return;
68
- console.warn(
69
- "[Fumadocs MDX] Noticed Zod v3 in your node_modules, we recommend upgrading to Zod v4 for better compatibility."
70
- );
71
- build.onResolve({ filter: /^fumadocs-mdx\/config$/ }, () => {
72
- return {
73
- path: "fumadocs-mdx/config/zod-3",
74
- external: true
75
- };
76
- });
77
- }
78
- };
79
- }
80
- async function compileConfig(configPath, outDir) {
81
- const { build } = await import("esbuild");
82
- const transformed = await build({
83
- entryPoints: [{ in: configPath, out: "source.config" }],
84
- bundle: true,
85
- outdir: outDir,
86
- target: "node20",
87
- write: true,
88
- platform: "node",
89
- format: "esm",
90
- packages: "external",
91
- plugins: [createCompatZodPlugin()],
92
- outExtension: {
93
- ".js": ".mjs"
94
- },
95
- allowOverwrite: true
96
- });
97
- if (transformed.errors.length > 0) {
98
- throw new Error("failed to compile configuration file");
99
- }
100
- }
101
- async function loadConfig(configPath, outDir, hash, build = false) {
102
- if (cache && cache.hash === hash) {
103
- return await cache.config;
104
- }
105
- if (build) await compileConfig(configPath, outDir);
106
- const url = pathToFileURL(path.resolve(outDir, "source.config.mjs"));
107
- const config = import(`${url.href}?hash=${hash}`).then((loaded) => {
108
- return buildConfig(
109
- // every call to `loadConfig` will cause the previous cache to be ignored
110
- loaded
111
- );
112
- });
113
- if (hash) cache = { config, hash };
114
- return await config;
115
- }
116
- async function getConfigHash(configPath) {
117
- const stats = await fs.stat(configPath).catch(() => void 0);
118
- if (stats) {
119
- return stats.mtime.getTime().toString();
120
- }
121
- throw new Error("Cannot find config file");
122
- }
123
-
124
- // src/utils/git-timestamp.ts
125
- import path2 from "path";
126
- import { x } from "tinyexec";
127
- var cache2 = /* @__PURE__ */ new Map();
128
- async function getGitTimestamp(file) {
129
- const cached = cache2.get(file);
130
- if (cached) return cached;
131
- try {
132
- const out = await x(
133
- "git",
134
- ["log", "-1", '--pretty="%ai"', path2.relative(process.cwd(), file)],
135
- {
136
- throwOnError: true
137
- }
138
- );
139
- const time = new Date(out.stdout);
140
- cache2.set(file, time);
141
- return time;
142
- } catch {
143
- return;
144
- }
145
- }
146
-
147
- export {
148
- ValidationError,
149
- validate,
150
- getGitTimestamp,
151
- findConfigFile,
152
- loadConfig,
153
- getConfigHash
154
- };
@@ -1,57 +0,0 @@
1
- // src/config/zod-4.ts
2
- import { z } from "zod";
3
- var metaSchema = z.object({
4
- title: z.string().optional(),
5
- pages: z.array(z.string()).optional(),
6
- description: z.string().optional(),
7
- root: z.boolean().optional(),
8
- defaultOpen: z.boolean().optional(),
9
- icon: z.string().optional()
10
- });
11
- var frontmatterSchema = z.object({
12
- title: z.string(),
13
- description: z.string().optional(),
14
- icon: z.string().optional(),
15
- full: z.boolean().optional(),
16
- // Fumadocs OpenAPI generated
17
- _openapi: z.looseObject({}).optional()
18
- });
19
-
20
- // src/config/define.ts
21
- function defineCollections(options) {
22
- return options;
23
- }
24
- function defineDocs(options) {
25
- if (!options)
26
- console.warn(
27
- "[`source.config.ts`] Deprecated: please pass options to `defineDocs()` and specify a `dir`."
28
- );
29
- const dir = options?.dir ?? "content/docs";
30
- return {
31
- type: "docs",
32
- dir,
33
- docs: defineCollections({
34
- type: "doc",
35
- dir,
36
- schema: frontmatterSchema,
37
- ...options?.docs
38
- }),
39
- meta: defineCollections({
40
- type: "meta",
41
- dir,
42
- schema: metaSchema,
43
- ...options?.meta
44
- })
45
- };
46
- }
47
- function defineConfig(config = {}) {
48
- return config;
49
- }
50
-
51
- export {
52
- metaSchema,
53
- frontmatterSchema,
54
- defineCollections,
55
- defineDocs,
56
- defineConfig
57
- };
@@ -1,40 +0,0 @@
1
- import {
2
- remarkInclude
3
- } from "./chunk-SVTXMVLQ.js";
4
-
5
- // src/utils/build-mdx.ts
6
- import { createProcessor } from "@mdx-js/mdx";
7
- var cache = /* @__PURE__ */ new Map();
8
- async function buildMDX(cacheKey, source, options) {
9
- const { filePath, frontmatter, data, _compiler, ...rest } = options;
10
- function getProcessor(format) {
11
- const key = `${cacheKey}:${format}`;
12
- let processor = cache.get(key);
13
- if (!processor) {
14
- processor = createProcessor({
15
- outputFormat: "program",
16
- ...rest,
17
- remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
18
- format
19
- });
20
- cache.set(key, processor);
21
- }
22
- return processor;
23
- }
24
- return getProcessor(
25
- options.format ?? filePath.endsWith(".mdx") ? "mdx" : "md"
26
- ).process({
27
- value: source,
28
- path: filePath,
29
- data: {
30
- ...data,
31
- frontmatter,
32
- _compiler,
33
- _getProcessor: getProcessor
34
- }
35
- });
36
- }
37
-
38
- export {
39
- buildMDX
40
- };
@@ -1,155 +0,0 @@
1
- // src/utils/mdx-options.ts
2
- import * as plugins from "fumadocs-core/mdx-plugins";
3
-
4
- // src/mdx-plugins/remark-postprocess.ts
5
- import { visit } from "unist-util-visit";
6
- import { valueToEstree } from "estree-util-value-to-estree";
7
- function remarkPostprocess({
8
- injectExports
9
- }) {
10
- return (tree, file) => {
11
- let title;
12
- const urls = [];
13
- visit(tree, ["heading", "link"], (node) => {
14
- if (node.type === "heading" && node.depth === 1) {
15
- title = flattenNode(node);
16
- }
17
- if (node.type !== "link") return;
18
- urls.push({
19
- href: node.url
20
- });
21
- return "skip";
22
- });
23
- if (title) {
24
- file.data.frontmatter ??= {};
25
- if (!file.data.frontmatter.title) file.data.frontmatter.title = title;
26
- }
27
- file.data.extractedReferences = urls;
28
- for (const name of injectExports) {
29
- if (!(name in file.data)) continue;
30
- tree.children.unshift(getMdastExport(name, file.data[name]));
31
- }
32
- };
33
- }
34
- function flattenNode(node) {
35
- if ("children" in node)
36
- return node.children.map((child) => flattenNode(child)).join("");
37
- if ("value" in node) return node.value;
38
- return "";
39
- }
40
- function getMdastExport(name, value) {
41
- return {
42
- type: "mdxjsEsm",
43
- value: "",
44
- data: {
45
- estree: {
46
- type: "Program",
47
- sourceType: "module",
48
- body: [
49
- {
50
- type: "ExportNamedDeclaration",
51
- attributes: [],
52
- specifiers: [],
53
- source: null,
54
- declaration: {
55
- type: "VariableDeclaration",
56
- kind: "let",
57
- declarations: [
58
- {
59
- type: "VariableDeclarator",
60
- id: {
61
- type: "Identifier",
62
- name
63
- },
64
- init: valueToEstree(value)
65
- }
66
- ]
67
- }
68
- }
69
- ]
70
- }
71
- }
72
- };
73
- }
74
-
75
- // src/utils/mdx-options.ts
76
- function pluginOption(def, options = []) {
77
- const list = def(Array.isArray(options) ? options : []).filter(
78
- Boolean
79
- );
80
- if (typeof options === "function") {
81
- return options(list);
82
- }
83
- return list;
84
- }
85
- function getDefaultMDXOptions({
86
- valueToExport = [],
87
- rehypeCodeOptions,
88
- remarkImageOptions,
89
- remarkHeadingOptions,
90
- remarkStructureOptions,
91
- remarkCodeTabOptions,
92
- remarkNpmOptions,
93
- _withoutBundler = false,
94
- ...mdxOptions
95
- }) {
96
- const mdxExports = [
97
- "structuredData",
98
- "extractedReferences",
99
- "frontmatter",
100
- "lastModified",
101
- ...valueToExport
102
- ];
103
- const remarkPlugins = pluginOption(
104
- (v) => [
105
- plugins.remarkGfm,
106
- [
107
- plugins.remarkHeading,
108
- {
109
- generateToc: false,
110
- ...remarkHeadingOptions
111
- }
112
- ],
113
- remarkImageOptions !== false && [
114
- plugins.remarkImage,
115
- {
116
- ...remarkImageOptions,
117
- useImport: _withoutBundler ? false : remarkImageOptions?.useImport
118
- }
119
- ],
120
- "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
121
- plugins.remarkCodeTab,
122
- remarkCodeTabOptions
123
- ],
124
- "remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
125
- ...v,
126
- remarkStructureOptions !== false && [
127
- plugins.remarkStructure,
128
- remarkStructureOptions
129
- ],
130
- [
131
- remarkPostprocess,
132
- { injectExports: mdxExports }
133
- ]
134
- ],
135
- mdxOptions.remarkPlugins
136
- );
137
- const rehypePlugins = pluginOption(
138
- (v) => [
139
- rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
140
- ...v,
141
- plugins.rehypeToc
142
- ],
143
- mdxOptions.rehypePlugins
144
- );
145
- return {
146
- ...mdxOptions,
147
- outputFormat: _withoutBundler ? "function-body" : mdxOptions.outputFormat,
148
- remarkPlugins,
149
- rehypePlugins
150
- };
151
- }
152
-
153
- export {
154
- getDefaultMDXOptions
155
- };