fumadocs-mdx 11.6.8 → 11.6.10
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-VC3Y6FLZ.js → chunk-64MMPGML.js} +12 -2
- package/dist/chunk-6PDS7MUA.js +49 -0
- package/dist/{chunk-KTLWF7GN.js → chunk-AVMO2SRO.js} +1 -1
- package/dist/chunk-KVWX6THC.js +19 -0
- package/dist/config/index.cjs +19 -30
- package/dist/config/index.d.cts +3 -2
- package/dist/config/index.d.ts +3 -2
- package/dist/config/index.js +6 -6
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/loader-mdx.cjs +145 -183
- package/dist/loader-mdx.js +9 -56
- package/dist/next/index.cjs +33 -40
- package/dist/next/index.js +28 -14
- package/dist/runtime/async.cjs +9 -30
- package/dist/runtime/async.d.cts +5 -5
- package/dist/runtime/async.d.ts +5 -5
- package/dist/runtime/async.js +2 -2
- package/dist/{types-BYJBKH4G.d.ts → types-Dk7DhSKZ.d.ts} +2 -15
- package/dist/{define-uoePrCQ_.d.ts → types-DvTNxAvo.d.cts} +67 -54
- package/dist/{define-uoePrCQ_.d.cts → types-DvTNxAvo.d.ts} +67 -54
- package/dist/{types-BsJd_P5O.d.cts → types-ZwLebhOl.d.cts} +2 -15
- package/dist/vite/index.cjs +384 -0
- package/dist/vite/index.d.cts +8 -0
- package/dist/vite/index.d.ts +8 -0
- package/dist/vite/index.js +71 -0
- package/package.json +19 -6
- package/dist/chunk-MXACIHNJ.js +0 -40
- package/dist/mdx-options-YGL3EP3M.js +0 -6
|
@@ -62,6 +62,7 @@ function getDefaultMDXOptions({
|
|
|
62
62
|
remarkHeadingOptions,
|
|
63
63
|
remarkStructureOptions,
|
|
64
64
|
remarkCodeTabOptions,
|
|
65
|
+
remarkNpmOptions,
|
|
65
66
|
...mdxOptions
|
|
66
67
|
}) {
|
|
67
68
|
const mdxExports = [
|
|
@@ -81,11 +82,11 @@ function getDefaultMDXOptions({
|
|
|
81
82
|
}
|
|
82
83
|
],
|
|
83
84
|
remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
|
|
84
|
-
// Fumadocs 14 compatibility
|
|
85
85
|
"remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
|
|
86
86
|
plugins.remarkCodeTab,
|
|
87
87
|
remarkCodeTabOptions
|
|
88
88
|
],
|
|
89
|
+
"remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
|
|
89
90
|
...v,
|
|
90
91
|
remarkStructureOptions !== false && [
|
|
91
92
|
plugins.remarkStructure,
|
|
@@ -109,7 +110,16 @@ function getDefaultMDXOptions({
|
|
|
109
110
|
rehypePlugins
|
|
110
111
|
};
|
|
111
112
|
}
|
|
113
|
+
async function loadDefaultOptions(config) {
|
|
114
|
+
const input = config.global?.mdxOptions;
|
|
115
|
+
config._mdx_loader ??= {};
|
|
116
|
+
const mdxLoader = config._mdx_loader;
|
|
117
|
+
if (!mdxLoader.cachedOptions) {
|
|
118
|
+
mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions(await input()) : getDefaultMDXOptions(input ?? {});
|
|
119
|
+
}
|
|
120
|
+
return mdxLoader.cachedOptions;
|
|
121
|
+
}
|
|
112
122
|
|
|
113
123
|
export {
|
|
114
|
-
|
|
124
|
+
loadDefaultOptions
|
|
115
125
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
remarkInclude
|
|
3
|
+
} from "./chunk-AVMO2SRO.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, ...rest } = options;
|
|
10
|
+
let format = options.format;
|
|
11
|
+
if (!format && filePath) {
|
|
12
|
+
format = filePath.endsWith(".mdx") ? "mdx" : "md";
|
|
13
|
+
}
|
|
14
|
+
format ??= "mdx";
|
|
15
|
+
const key = `${cacheKey}:${format}`;
|
|
16
|
+
let cached = cache.get(key);
|
|
17
|
+
if (!cached) {
|
|
18
|
+
cached = createProcessor({
|
|
19
|
+
outputFormat: "program",
|
|
20
|
+
...rest,
|
|
21
|
+
remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
|
|
22
|
+
format
|
|
23
|
+
});
|
|
24
|
+
cache.set(key, cached);
|
|
25
|
+
}
|
|
26
|
+
return cached.process({
|
|
27
|
+
value: source,
|
|
28
|
+
path: filePath,
|
|
29
|
+
data: {
|
|
30
|
+
...data,
|
|
31
|
+
frontmatter,
|
|
32
|
+
_compiler: options._compiler
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/utils/count-lines.ts
|
|
38
|
+
function countLines(s) {
|
|
39
|
+
let num = 0;
|
|
40
|
+
for (const c of s) {
|
|
41
|
+
if (c === "\n") num++;
|
|
42
|
+
}
|
|
43
|
+
return num;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
buildMDX,
|
|
48
|
+
countLines
|
|
49
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/utils/fuma-matter.ts
|
|
2
|
+
import { load } from "js-yaml";
|
|
3
|
+
var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
|
|
4
|
+
function fumaMatter(input) {
|
|
5
|
+
const output = { matter: "", data: {}, content: input };
|
|
6
|
+
const match = regex.exec(input);
|
|
7
|
+
if (!match) {
|
|
8
|
+
return output;
|
|
9
|
+
}
|
|
10
|
+
output.matter = match[1];
|
|
11
|
+
output.content = input.slice(match[0].length);
|
|
12
|
+
const loaded = load(output.matter);
|
|
13
|
+
output.data = loaded ?? {};
|
|
14
|
+
return output;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
fumaMatter
|
|
19
|
+
};
|
package/dist/config/index.cjs
CHANGED
|
@@ -34,7 +34,7 @@ __export(config_exports, {
|
|
|
34
34
|
defineConfig: () => defineConfig,
|
|
35
35
|
defineDocs: () => defineDocs,
|
|
36
36
|
frontmatterSchema: () => frontmatterSchema,
|
|
37
|
-
|
|
37
|
+
loadDefaultOptions: () => loadDefaultOptions,
|
|
38
38
|
metaSchema: () => metaSchema,
|
|
39
39
|
remarkInclude: () => remarkInclude
|
|
40
40
|
});
|
|
@@ -161,6 +161,7 @@ function getDefaultMDXOptions({
|
|
|
161
161
|
remarkHeadingOptions,
|
|
162
162
|
remarkStructureOptions,
|
|
163
163
|
remarkCodeTabOptions,
|
|
164
|
+
remarkNpmOptions,
|
|
164
165
|
...mdxOptions
|
|
165
166
|
}) {
|
|
166
167
|
const mdxExports = [
|
|
@@ -180,11 +181,11 @@ function getDefaultMDXOptions({
|
|
|
180
181
|
}
|
|
181
182
|
],
|
|
182
183
|
remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
|
|
183
|
-
// Fumadocs 14 compatibility
|
|
184
184
|
"remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
|
|
185
185
|
plugins.remarkCodeTab,
|
|
186
186
|
remarkCodeTabOptions
|
|
187
187
|
],
|
|
188
|
+
"remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
|
|
188
189
|
...v,
|
|
189
190
|
remarkStructureOptions !== false && [
|
|
190
191
|
plugins.remarkStructure,
|
|
@@ -208,6 +209,15 @@ function getDefaultMDXOptions({
|
|
|
208
209
|
rehypePlugins
|
|
209
210
|
};
|
|
210
211
|
}
|
|
212
|
+
async function loadDefaultOptions(config) {
|
|
213
|
+
const input = config.global?.mdxOptions;
|
|
214
|
+
config._mdx_loader ??= {};
|
|
215
|
+
const mdxLoader = config._mdx_loader;
|
|
216
|
+
if (!mdxLoader.cachedOptions) {
|
|
217
|
+
mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions(await input()) : getDefaultMDXOptions(input ?? {});
|
|
218
|
+
}
|
|
219
|
+
return mdxLoader.cachedOptions;
|
|
220
|
+
}
|
|
211
221
|
|
|
212
222
|
// src/mdx-plugins/remark-include.ts
|
|
213
223
|
var import_unist_util_visit = require("unist-util-visit");
|
|
@@ -215,37 +225,16 @@ var path = __toESM(require("path"), 1);
|
|
|
215
225
|
var fs = __toESM(require("fs/promises"), 1);
|
|
216
226
|
|
|
217
227
|
// src/utils/fuma-matter.ts
|
|
218
|
-
var import_lru_cache = require("lru-cache");
|
|
219
228
|
var import_js_yaml = require("js-yaml");
|
|
220
|
-
var
|
|
221
|
-
max: 200
|
|
222
|
-
});
|
|
229
|
+
var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
|
|
223
230
|
function fumaMatter(input) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const cached = cache.get(input);
|
|
228
|
-
if (cached) return cached;
|
|
229
|
-
const result = parseMatter(input);
|
|
230
|
-
cache.set(input, result);
|
|
231
|
-
return structuredClone(result);
|
|
232
|
-
}
|
|
233
|
-
var delimiter = "---";
|
|
234
|
-
function parseMatter(str) {
|
|
235
|
-
const output = { matter: "", data: {}, content: str };
|
|
236
|
-
const open = delimiter + "\n";
|
|
237
|
-
const close = "\n" + delimiter;
|
|
238
|
-
if (!str.startsWith(open)) {
|
|
231
|
+
const output = { matter: "", data: {}, content: input };
|
|
232
|
+
const match = regex.exec(input);
|
|
233
|
+
if (!match) {
|
|
239
234
|
return output;
|
|
240
235
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
let closeIdx = str.indexOf(close);
|
|
244
|
-
if (closeIdx === -1) {
|
|
245
|
-
closeIdx = len;
|
|
246
|
-
}
|
|
247
|
-
output.matter = str.slice(0, closeIdx);
|
|
248
|
-
output.content = str.slice(closeIdx + close.length);
|
|
236
|
+
output.matter = match[1];
|
|
237
|
+
output.content = input.slice(match[0].length);
|
|
249
238
|
const loaded = (0, import_js_yaml.load)(output.matter);
|
|
250
239
|
output.data = loaded ?? {};
|
|
251
240
|
return output;
|
|
@@ -327,7 +316,7 @@ ${e instanceof Error ? e.message : String(e)}`
|
|
|
327
316
|
defineConfig,
|
|
328
317
|
defineDocs,
|
|
329
318
|
frontmatterSchema,
|
|
330
|
-
|
|
319
|
+
loadDefaultOptions,
|
|
331
320
|
metaSchema,
|
|
332
321
|
remarkInclude
|
|
333
322
|
});
|
package/dist/config/index.d.cts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export { a as BaseCollection, B as BaseCollectionEntry, C as CollectionSchema,
|
|
1
|
+
export { a as BaseCollection, B as BaseCollectionEntry, C as CollectionSchema, D as DefaultMDXOptions, c as DocCollection, d as DocsCollection, F as FileInfo, G as GlobalConfig, M as MarkdownProps, b as MetaCollection, e as defineCollections, h as defineConfig, g as defineDocs, f as frontmatterSchema, l as loadDefaultOptions, m as metaSchema } from '../types-DvTNxAvo.cjs';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
|
-
import '@mdx-js/mdx';
|
|
5
4
|
import 'mdx/types';
|
|
6
5
|
import 'fumadocs-core/mdx-plugins';
|
|
7
6
|
import 'fumadocs-core/server';
|
|
7
|
+
import '@mdx-js/mdx';
|
|
8
8
|
import 'react';
|
|
9
9
|
import 'zod';
|
|
10
10
|
import '@standard-schema/spec';
|
|
11
|
+
import '@fumadocs/mdx-remote';
|
|
11
12
|
|
|
12
13
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
13
14
|
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export { a as BaseCollection, B as BaseCollectionEntry, C as CollectionSchema,
|
|
1
|
+
export { a as BaseCollection, B as BaseCollectionEntry, C as CollectionSchema, D as DefaultMDXOptions, c as DocCollection, d as DocsCollection, F as FileInfo, G as GlobalConfig, M as MarkdownProps, b as MetaCollection, e as defineCollections, h as defineConfig, g as defineDocs, f as frontmatterSchema, l as loadDefaultOptions, m as metaSchema } from '../types-DvTNxAvo.js';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
|
-
import '@mdx-js/mdx';
|
|
5
4
|
import 'mdx/types';
|
|
6
5
|
import 'fumadocs-core/mdx-plugins';
|
|
7
6
|
import 'fumadocs-core/server';
|
|
7
|
+
import '@mdx-js/mdx';
|
|
8
8
|
import 'react';
|
|
9
9
|
import 'zod';
|
|
10
10
|
import '@standard-schema/spec';
|
|
11
|
+
import '@fumadocs/mdx-remote';
|
|
11
12
|
|
|
12
13
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
13
14
|
|
package/dist/config/index.js
CHANGED
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
metaSchema
|
|
4
4
|
} from "../chunk-OTM6WYMS.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-MXACIHNJ.js";
|
|
6
|
+
loadDefaultOptions
|
|
7
|
+
} from "../chunk-64MMPGML.js";
|
|
9
8
|
import {
|
|
10
|
-
|
|
11
|
-
} from "../chunk-
|
|
9
|
+
remarkInclude
|
|
10
|
+
} from "../chunk-AVMO2SRO.js";
|
|
11
|
+
import "../chunk-KVWX6THC.js";
|
|
12
12
|
|
|
13
13
|
// src/config/define.ts
|
|
14
14
|
function defineCollections(options) {
|
|
@@ -51,7 +51,7 @@ export {
|
|
|
51
51
|
defineConfig,
|
|
52
52
|
defineDocs,
|
|
53
53
|
frontmatterSchema,
|
|
54
|
-
|
|
54
|
+
loadDefaultOptions,
|
|
55
55
|
metaSchema,
|
|
56
56
|
remarkInclude
|
|
57
57
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
-
import { B as BaseCollectionEntry } from './
|
|
3
|
-
import { R as Runtime } from './types-
|
|
4
|
-
import '@mdx-js/mdx';
|
|
2
|
+
import { B as BaseCollectionEntry } from './types-DvTNxAvo.cjs';
|
|
3
|
+
import { R as Runtime } from './types-ZwLebhOl.cjs';
|
|
5
4
|
import 'mdx/types';
|
|
6
5
|
import 'fumadocs-core/mdx-plugins';
|
|
7
6
|
import 'fumadocs-core/server';
|
|
7
|
+
import '@mdx-js/mdx';
|
|
8
8
|
import 'unified';
|
|
9
9
|
import 'react';
|
|
10
10
|
import 'zod';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
-
import { B as BaseCollectionEntry } from './
|
|
3
|
-
import { R as Runtime } from './types-
|
|
4
|
-
import '@mdx-js/mdx';
|
|
2
|
+
import { B as BaseCollectionEntry } from './types-DvTNxAvo.js';
|
|
3
|
+
import { R as Runtime } from './types-Dk7DhSKZ.js';
|
|
5
4
|
import 'mdx/types';
|
|
6
5
|
import 'fumadocs-core/mdx-plugins';
|
|
7
6
|
import 'fumadocs-core/server';
|
|
7
|
+
import '@mdx-js/mdx';
|
|
8
8
|
import 'unified';
|
|
9
9
|
import 'react';
|
|
10
10
|
import 'zod';
|