fumadocs-mdx 8.0.2 → 8.0.3

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/config.d.mts CHANGED
@@ -15,8 +15,8 @@ type MDXOptions = Omit<NonNullable<Options>, 'rehypePlugins' | 'remarkPlugins'>
15
15
  * Properties to export from `vfile.data`
16
16
  */
17
17
  valueToExport?: string[];
18
- remarkImageOptions?: RemarkImageOptions;
19
- rehypeCodeOptions?: RehypeCodeOptions;
18
+ remarkImageOptions?: RemarkImageOptions | false;
19
+ rehypeCodeOptions?: RehypeCodeOptions | false;
20
20
  };
21
21
  type ResolvePlugins = PluggableList | ((v: PluggableList) => PluggableList);
22
22
  interface CreateMDXOptions {
package/dist/config.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ __objRest,
2
3
  __spreadProps,
3
4
  __spreadValues
4
5
  } from "./chunk-P26LYDRL.mjs";
@@ -93,39 +94,59 @@ function pluginOption(def, options = []) {
93
94
  }
94
95
  return list;
95
96
  }
96
- var createMDX = ({
97
- mdxOptions = {},
98
- cwd = process.cwd(),
99
- rootMapPath = "./.map.ts",
100
- rootContentPath = "./content"
101
- } = {}) => (nextConfig = {}) => {
102
- var _a;
103
- const valueToExport = [
97
+ function getMDXLoaderOptions(_a) {
98
+ var _b = _a, {
99
+ valueToExport = [],
100
+ rehypeCodeOptions,
101
+ remarkImageOptions
102
+ } = _b, mdxOptions = __objRest(_b, [
103
+ "valueToExport",
104
+ "rehypeCodeOptions",
105
+ "remarkImageOptions"
106
+ ]);
107
+ const mdxExports = [
104
108
  "structuredData",
105
109
  "toc",
106
110
  "frontmatter",
107
111
  "lastModified",
108
- ...(_a = mdxOptions.valueToExport) != null ? _a : []
112
+ ...valueToExport
109
113
  ];
110
- const _mapPath = path.resolve(cwd, rootMapPath);
111
114
  const remarkPlugins = pluginOption(
112
115
  (v) => [
113
116
  remarkGfm,
114
117
  remarkHeading,
115
- [remarkImage, mdxOptions.remarkImageOptions],
118
+ ...remarkImageOptions === false ? [] : [[remarkImage, remarkImageOptions]],
116
119
  ...v,
117
120
  remarkStructure,
118
- [remarkMdxExport, { values: valueToExport }]
121
+ [remarkMdxExport, { values: mdxExports }]
119
122
  ],
120
123
  mdxOptions.remarkPlugins
121
124
  );
122
125
  const rehypePlugins = pluginOption(
123
- (v) => [[rehypeCode, mdxOptions.rehypeCodeOptions], ...v],
126
+ (v) => [
127
+ ...rehypeCodeOptions === false ? [] : [[rehypeCode, rehypeCodeOptions]],
128
+ ...v
129
+ ],
124
130
  mdxOptions.rehypePlugins
125
131
  );
132
+ return __spreadProps(__spreadValues({
133
+ providerImportSource: "next-mdx-import-source-file"
134
+ }, mdxOptions), {
135
+ remarkPlugins,
136
+ rehypePlugins
137
+ });
138
+ }
139
+ var createMDX = ({
140
+ mdxOptions = {},
141
+ cwd = process.cwd(),
142
+ rootMapPath = "./.map.ts",
143
+ rootContentPath = "./content"
144
+ } = {}) => (nextConfig = {}) => {
145
+ const _mapPath = path.resolve(cwd, rootMapPath);
146
+ const mdxLoaderOptions = getMDXLoaderOptions(mdxOptions);
126
147
  return __spreadValues(__spreadValues({}, nextConfig), {
127
148
  webpack: (config, options) => {
128
- var _a2, _b, _c;
149
+ var _a, _b, _c;
129
150
  config.resolve || (config.resolve = {});
130
151
  const alias = config.resolve.alias;
131
152
  alias["next-mdx-import-source-file"] = [
@@ -134,7 +155,7 @@ var createMDX = ({
134
155
  "@mdx-js/react"
135
156
  ];
136
157
  config.module || (config.module = {});
137
- (_a2 = config.module).rules || (_a2.rules = []);
158
+ (_a = config.module).rules || (_a.rules = []);
138
159
  config.module.rules.push(
139
160
  {
140
161
  test: /\.mdx?$/,
@@ -142,12 +163,7 @@ var createMDX = ({
142
163
  options.defaultLoaders.babel,
143
164
  {
144
165
  loader: "fumadocs-mdx/loader-mdx",
145
- options: __spreadProps(__spreadValues({
146
- providerImportSource: "next-mdx-import-source-file"
147
- }, mdxOptions), {
148
- remarkPlugins,
149
- rehypePlugins
150
- })
166
+ options: mdxLoaderOptions
151
167
  }
152
168
  ]
153
169
  },
package/dist/loader.mjs CHANGED
@@ -15,16 +15,20 @@ function buildMap({ cwd, rootContentPath, mapPath }) {
15
15
  const files = fg.sync("./**/*.{md,mdx,json}", {
16
16
  cwd: absoluteContentPath
17
17
  });
18
- const entries = files.map((file) => {
19
- let importPath = path.relative(mapDir, path.join(absoluteContentPath, file)).replace(path.sep, "/");
18
+ const imports = [];
19
+ const entries = [];
20
+ files.forEach((file, i) => {
21
+ let importPath = path.relative(mapDir, path.join(absoluteContentPath, file)).replaceAll(path.sep, "/");
20
22
  if (!importPath.startsWith(".")) {
21
23
  importPath = `./${importPath}`;
22
24
  }
23
- return `${JSON.stringify(file)}: await import(${JSON.stringify(
24
- importPath
25
- )})`;
25
+ const name = `file_${i}`;
26
+ imports.push(`import * as ${name} from ${JSON.stringify(importPath)};`);
27
+ entries.push(`${JSON.stringify(file)}: ${name}`);
26
28
  });
27
- return `export const map = {${entries.join(",")}}`;
29
+ return [imports.join("\n"), `export const map = {${entries.join(",")}}`].join(
30
+ "\n"
31
+ );
28
32
  }
29
33
  export {
30
34
  loader as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "8.0.2",
3
+ "version": "8.0.3",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -43,7 +43,7 @@
43
43
  "fast-glob": "^3.3.1",
44
44
  "gray-matter": "^4.0.3",
45
45
  "zod": "^3.22.4",
46
- "fumadocs-core": "8.1.1"
46
+ "fumadocs-core": "8.2.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/cross-spawn": "^6.0.4",