fumadocs-mdx 11.6.7 → 11.6.9
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-6PDS7MUA.js +49 -0
- package/dist/{chunk-2Z6EJ3GA.js → chunk-AVMO2SRO.js} +6 -3
- package/dist/chunk-KVWX6THC.js +19 -0
- package/dist/{chunk-7SSA5RCV.js → chunk-NUDEC6C5.js} +12 -6
- package/dist/{chunk-VC3Y6FLZ.js → chunk-YRT4TZBA.js} +10 -1
- package/dist/config/index.cjs +31 -5
- package/dist/config/index.d.cts +3 -2
- package/dist/config/index.d.ts +3 -2
- package/dist/config/index.js +6 -5
- package/dist/index.cjs +12 -6
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/loader-mdx.cjs +158 -159
- package/dist/loader-mdx.js +15 -59
- package/dist/next/index.cjs +49 -19
- package/dist/next/index.js +34 -17
- package/dist/runtime/async.cjs +32 -9
- package/dist/runtime/async.d.cts +5 -5
- package/dist/runtime/async.d.ts +5 -5
- package/dist/runtime/async.js +3 -2
- package/dist/{define-uoePrCQ_.d.ts → types-CDl6YYjj.d.cts} +66 -54
- package/dist/{define-uoePrCQ_.d.cts → types-CDl6YYjj.d.ts} +66 -54
- package/dist/{types-BYJBKH4G.d.ts → types-DVyGNyFh.d.ts} +2 -15
- package/dist/{types-BsJd_P5O.d.cts → types-DZW0R4_d.d.cts} +2 -15
- package/dist/vite/index.cjs +383 -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 -7
- package/dist/mdx-options-YGL3EP3M.js +0 -6
|
@@ -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
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fumaMatter
|
|
3
|
+
} from "./chunk-KVWX6THC.js";
|
|
4
|
+
|
|
1
5
|
// src/mdx-plugins/remark-include.ts
|
|
2
6
|
import { visit } from "unist-util-visit";
|
|
3
7
|
import * as path from "path";
|
|
4
8
|
import * as fs from "fs/promises";
|
|
5
|
-
import matter from "gray-matter";
|
|
6
9
|
function flattenNode(node) {
|
|
7
10
|
if ("children" in node)
|
|
8
11
|
return node.children.map((child) => flattenNode(child)).join("");
|
|
@@ -37,7 +40,7 @@ function remarkInclude() {
|
|
|
37
40
|
);
|
|
38
41
|
const asCode = params.lang || !specifier.endsWith(".md") && !specifier.endsWith(".mdx");
|
|
39
42
|
queue.push(
|
|
40
|
-
fs.readFile(targetPath).then(async (content) => {
|
|
43
|
+
fs.readFile(targetPath).then((buffer) => buffer.toString()).then(async (content) => {
|
|
41
44
|
compiler?.addDependency(targetPath);
|
|
42
45
|
if (asCode) {
|
|
43
46
|
const lang = params.lang ?? path.extname(specifier).slice(1);
|
|
@@ -50,7 +53,7 @@ function remarkInclude() {
|
|
|
50
53
|
});
|
|
51
54
|
return;
|
|
52
55
|
}
|
|
53
|
-
const parsed = processor.parse(
|
|
56
|
+
const parsed = processor.parse(fumaMatter(content).content);
|
|
54
57
|
await update(parsed, targetPath, processor, compiler);
|
|
55
58
|
Object.assign(
|
|
56
59
|
parent && parent.type === "paragraph" ? parent : node,
|
|
@@ -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
|
+
};
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
// src/runtime/index.ts
|
|
2
2
|
import fs from "fs";
|
|
3
|
+
var cache = /* @__PURE__ */ new Map();
|
|
3
4
|
var _runtime = {
|
|
4
5
|
doc(files) {
|
|
5
6
|
return files.map((file) => {
|
|
6
7
|
const { default: body, frontmatter, ...exports } = file.data;
|
|
7
|
-
let cachedContent;
|
|
8
8
|
return {
|
|
9
9
|
body,
|
|
10
10
|
...exports,
|
|
11
11
|
...frontmatter,
|
|
12
|
-
|
|
13
|
-
cachedContent ??= fs.readFileSync(file.info.absolutePath).toString();
|
|
14
|
-
return cachedContent;
|
|
15
|
-
},
|
|
12
|
+
_file: file.info,
|
|
16
13
|
_exports: file.data,
|
|
17
|
-
|
|
14
|
+
get content() {
|
|
15
|
+
const path = this._file.absolutePath;
|
|
16
|
+
const cached = cache.get(path);
|
|
17
|
+
if (cached) return cached;
|
|
18
|
+
const content = fs.readFileSync(path).toString();
|
|
19
|
+
cache.set(path, content);
|
|
20
|
+
return content;
|
|
21
|
+
}
|
|
18
22
|
};
|
|
19
23
|
});
|
|
20
24
|
},
|
|
@@ -51,6 +55,7 @@ function resolveFiles({ docs, meta }) {
|
|
|
51
55
|
for (const entry of docs) {
|
|
52
56
|
outputs.push({
|
|
53
57
|
type: "page",
|
|
58
|
+
absolutePath: entry._file.absolutePath,
|
|
54
59
|
path: entry._file.path,
|
|
55
60
|
data: entry
|
|
56
61
|
});
|
|
@@ -58,6 +63,7 @@ function resolveFiles({ docs, meta }) {
|
|
|
58
63
|
for (const entry of meta) {
|
|
59
64
|
outputs.push({
|
|
60
65
|
type: "meta",
|
|
66
|
+
absolutePath: entry._file.absolutePath,
|
|
61
67
|
path: entry._file.path,
|
|
62
68
|
data: entry
|
|
63
69
|
});
|
|
@@ -109,7 +109,16 @@ function getDefaultMDXOptions({
|
|
|
109
109
|
rehypePlugins
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
+
async function loadDefaultOptions(config) {
|
|
113
|
+
const input = config.global?.mdxOptions;
|
|
114
|
+
config._mdx_loader ??= {};
|
|
115
|
+
const mdxLoader = config._mdx_loader;
|
|
116
|
+
if (!mdxLoader.cachedOptions) {
|
|
117
|
+
mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions(await input()) : getDefaultMDXOptions(input ?? {});
|
|
118
|
+
}
|
|
119
|
+
return mdxLoader.cachedOptions;
|
|
120
|
+
}
|
|
112
121
|
|
|
113
122
|
export {
|
|
114
|
-
|
|
123
|
+
loadDefaultOptions
|
|
115
124
|
};
|
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
|
});
|
|
@@ -208,12 +208,38 @@ function getDefaultMDXOptions({
|
|
|
208
208
|
rehypePlugins
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
+
async function loadDefaultOptions(config) {
|
|
212
|
+
const input = config.global?.mdxOptions;
|
|
213
|
+
config._mdx_loader ??= {};
|
|
214
|
+
const mdxLoader = config._mdx_loader;
|
|
215
|
+
if (!mdxLoader.cachedOptions) {
|
|
216
|
+
mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions(await input()) : getDefaultMDXOptions(input ?? {});
|
|
217
|
+
}
|
|
218
|
+
return mdxLoader.cachedOptions;
|
|
219
|
+
}
|
|
211
220
|
|
|
212
221
|
// src/mdx-plugins/remark-include.ts
|
|
213
222
|
var import_unist_util_visit = require("unist-util-visit");
|
|
214
223
|
var path = __toESM(require("path"), 1);
|
|
215
224
|
var fs = __toESM(require("fs/promises"), 1);
|
|
216
|
-
|
|
225
|
+
|
|
226
|
+
// src/utils/fuma-matter.ts
|
|
227
|
+
var import_js_yaml = require("js-yaml");
|
|
228
|
+
var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
|
|
229
|
+
function fumaMatter(input) {
|
|
230
|
+
const output = { matter: "", data: {}, content: input };
|
|
231
|
+
const match = regex.exec(input);
|
|
232
|
+
if (!match) {
|
|
233
|
+
return output;
|
|
234
|
+
}
|
|
235
|
+
output.matter = match[1];
|
|
236
|
+
output.content = input.slice(match[0].length);
|
|
237
|
+
const loaded = (0, import_js_yaml.load)(output.matter);
|
|
238
|
+
output.data = loaded ?? {};
|
|
239
|
+
return output;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// src/mdx-plugins/remark-include.ts
|
|
217
243
|
function flattenNode(node) {
|
|
218
244
|
if ("children" in node)
|
|
219
245
|
return node.children.map((child) => flattenNode(child)).join("");
|
|
@@ -248,7 +274,7 @@ function remarkInclude() {
|
|
|
248
274
|
);
|
|
249
275
|
const asCode = params.lang || !specifier.endsWith(".md") && !specifier.endsWith(".mdx");
|
|
250
276
|
queue.push(
|
|
251
|
-
fs.readFile(targetPath).then(async (content) => {
|
|
277
|
+
fs.readFile(targetPath).then((buffer) => buffer.toString()).then(async (content) => {
|
|
252
278
|
compiler?.addDependency(targetPath);
|
|
253
279
|
if (asCode) {
|
|
254
280
|
const lang = params.lang ?? path.extname(specifier).slice(1);
|
|
@@ -261,7 +287,7 @@ function remarkInclude() {
|
|
|
261
287
|
});
|
|
262
288
|
return;
|
|
263
289
|
}
|
|
264
|
-
const parsed = processor.parse((
|
|
290
|
+
const parsed = processor.parse(fumaMatter(content).content);
|
|
265
291
|
await update(parsed, targetPath, processor, compiler);
|
|
266
292
|
Object.assign(
|
|
267
293
|
parent && parent.type === "paragraph" ? parent : node,
|
|
@@ -289,7 +315,7 @@ ${e instanceof Error ? e.message : String(e)}`
|
|
|
289
315
|
defineConfig,
|
|
290
316
|
defineDocs,
|
|
291
317
|
frontmatterSchema,
|
|
292
|
-
|
|
318
|
+
loadDefaultOptions,
|
|
293
319
|
metaSchema,
|
|
294
320
|
remarkInclude
|
|
295
321
|
});
|
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-CDl6YYjj.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-CDl6YYjj.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,11 +3,12 @@ import {
|
|
|
3
3
|
metaSchema
|
|
4
4
|
} from "../chunk-OTM6WYMS.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "../chunk-
|
|
6
|
+
loadDefaultOptions
|
|
7
|
+
} from "../chunk-YRT4TZBA.js";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
} from "../chunk-
|
|
9
|
+
remarkInclude
|
|
10
|
+
} from "../chunk-AVMO2SRO.js";
|
|
11
|
+
import "../chunk-KVWX6THC.js";
|
|
11
12
|
|
|
12
13
|
// src/config/define.ts
|
|
13
14
|
function defineCollections(options) {
|
|
@@ -50,7 +51,7 @@ export {
|
|
|
50
51
|
defineConfig,
|
|
51
52
|
defineDocs,
|
|
52
53
|
frontmatterSchema,
|
|
53
|
-
|
|
54
|
+
loadDefaultOptions,
|
|
54
55
|
metaSchema,
|
|
55
56
|
remarkInclude
|
|
56
57
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -38,21 +38,25 @@ module.exports = __toCommonJS(index_exports);
|
|
|
38
38
|
|
|
39
39
|
// src/runtime/index.ts
|
|
40
40
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
41
|
+
var cache = /* @__PURE__ */ new Map();
|
|
41
42
|
var _runtime = {
|
|
42
43
|
doc(files) {
|
|
43
44
|
return files.map((file) => {
|
|
44
45
|
const { default: body, frontmatter, ...exports2 } = file.data;
|
|
45
|
-
let cachedContent;
|
|
46
46
|
return {
|
|
47
47
|
body,
|
|
48
48
|
...exports2,
|
|
49
49
|
...frontmatter,
|
|
50
|
-
|
|
51
|
-
cachedContent ??= import_node_fs.default.readFileSync(file.info.absolutePath).toString();
|
|
52
|
-
return cachedContent;
|
|
53
|
-
},
|
|
50
|
+
_file: file.info,
|
|
54
51
|
_exports: file.data,
|
|
55
|
-
|
|
52
|
+
get content() {
|
|
53
|
+
const path = this._file.absolutePath;
|
|
54
|
+
const cached = cache.get(path);
|
|
55
|
+
if (cached) return cached;
|
|
56
|
+
const content = import_node_fs.default.readFileSync(path).toString();
|
|
57
|
+
cache.set(path, content);
|
|
58
|
+
return content;
|
|
59
|
+
}
|
|
56
60
|
};
|
|
57
61
|
});
|
|
58
62
|
},
|
|
@@ -89,6 +93,7 @@ function resolveFiles({ docs, meta }) {
|
|
|
89
93
|
for (const entry of docs) {
|
|
90
94
|
outputs.push({
|
|
91
95
|
type: "page",
|
|
96
|
+
absolutePath: entry._file.absolutePath,
|
|
92
97
|
path: entry._file.path,
|
|
93
98
|
data: entry
|
|
94
99
|
});
|
|
@@ -96,6 +101,7 @@ function resolveFiles({ docs, meta }) {
|
|
|
96
101
|
for (const entry of meta) {
|
|
97
102
|
outputs.push({
|
|
98
103
|
type: "meta",
|
|
104
|
+
absolutePath: entry._file.absolutePath,
|
|
99
105
|
path: entry._file.path,
|
|
100
106
|
data: entry
|
|
101
107
|
});
|
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-CDl6YYjj.cjs';
|
|
3
|
+
import { R as Runtime } from './types-DZW0R4_d.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-CDl6YYjj.js';
|
|
3
|
+
import { R as Runtime } from './types-DVyGNyFh.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';
|