fumadocs-mdx 11.3.0 → 11.3.2
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/{build-mdx-C2hor32E.d.cts → build-mdx-TJcSpR7K.d.cts} +2 -1
- package/dist/{build-mdx-C2hor32E.d.ts → build-mdx-TJcSpR7K.d.ts} +2 -1
- package/dist/{chunk-6LEQ23AC.js → chunk-CQAAQB5I.js} +3 -0
- package/dist/{chunk-2ZPSMAUV.js → chunk-HPKXUFKR.js} +1 -1
- package/dist/chunk-PY2KKTR2.js +53 -0
- package/dist/config/index.cjs +26 -12
- package/dist/config/index.d.cts +2 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/loader-mdx.cjs +43 -20
- package/dist/loader-mdx.js +19 -10
- package/dist/{mdx-options-L5C3NQRY.js → mdx-options-2H42TB7P.js} +1 -1
- package/dist/next/index.cjs +2 -0
- package/dist/next/index.js +1 -1
- package/package.json +7 -7
- package/dist/chunk-GUHWD47S.js +0 -41
|
@@ -16,9 +16,10 @@ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | '
|
|
|
16
16
|
remarkStructureOptions?: StructureOptions | false;
|
|
17
17
|
remarkHeadingOptions?: RemarkHeadingOptions;
|
|
18
18
|
remarkImageOptions?: RemarkImageOptions | false;
|
|
19
|
+
remarkCodeTabOptions?: false;
|
|
19
20
|
rehypeCodeOptions?: Partial<RehypeCodeOptions> | false;
|
|
20
21
|
};
|
|
21
|
-
declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
|
|
22
|
+
declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
|
|
22
23
|
|
|
23
24
|
interface GlobalConfig {
|
|
24
25
|
/**
|
|
@@ -16,9 +16,10 @@ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | '
|
|
|
16
16
|
remarkStructureOptions?: StructureOptions | false;
|
|
17
17
|
remarkHeadingOptions?: RemarkHeadingOptions;
|
|
18
18
|
remarkImageOptions?: RemarkImageOptions | false;
|
|
19
|
+
remarkCodeTabOptions?: false;
|
|
19
20
|
rehypeCodeOptions?: Partial<RehypeCodeOptions> | false;
|
|
20
21
|
};
|
|
21
|
-
declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
|
|
22
|
+
declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
|
|
22
23
|
|
|
23
24
|
interface GlobalConfig {
|
|
24
25
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
rehypeCode,
|
|
4
4
|
rehypeToc,
|
|
5
|
+
remarkCodeTab,
|
|
5
6
|
remarkGfm,
|
|
6
7
|
remarkHeading,
|
|
7
8
|
remarkImage,
|
|
@@ -68,6 +69,7 @@ function getDefaultMDXOptions({
|
|
|
68
69
|
remarkImageOptions,
|
|
69
70
|
remarkHeadingOptions,
|
|
70
71
|
remarkStructureOptions,
|
|
72
|
+
remarkCodeTabOptions,
|
|
71
73
|
...mdxOptions
|
|
72
74
|
}) {
|
|
73
75
|
const mdxExports = [
|
|
@@ -87,6 +89,7 @@ function getDefaultMDXOptions({
|
|
|
87
89
|
}
|
|
88
90
|
],
|
|
89
91
|
remarkImageOptions !== false && [remarkImage, remarkImageOptions],
|
|
92
|
+
remarkCodeTabOptions !== false && remarkCodeTab,
|
|
90
93
|
...v,
|
|
91
94
|
remarkStructureOptions !== false && [
|
|
92
95
|
remarkStructure,
|
|
@@ -67,7 +67,7 @@ function buildConfig(config) {
|
|
|
67
67
|
collections,
|
|
68
68
|
async getDefaultMDXOptions() {
|
|
69
69
|
if (cachedMdxOptions) return cachedMdxOptions;
|
|
70
|
-
const { getDefaultMDXOptions } = await import("./mdx-options-
|
|
70
|
+
const { getDefaultMDXOptions } = await import("./mdx-options-2H42TB7P.js");
|
|
71
71
|
const mdxOptions = globalConfig?.mdxOptions ?? {};
|
|
72
72
|
if (typeof mdxOptions === "function") {
|
|
73
73
|
cachedMdxOptions = getDefaultMDXOptions(await mdxOptions());
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/mdx-plugins/remark-include.ts
|
|
2
|
+
import { visit } from "unist-util-visit";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import * as fs from "node:fs/promises";
|
|
5
|
+
import matter from "gray-matter";
|
|
6
|
+
function remarkInclude() {
|
|
7
|
+
const TagName = "include";
|
|
8
|
+
async function update(tree, file, processor, compiler) {
|
|
9
|
+
const queue = [];
|
|
10
|
+
visit(tree, ["mdxJsxFlowElement", "paragraph"], (node) => {
|
|
11
|
+
let specifier;
|
|
12
|
+
if (node.type === "paragraph" && node.children.length === 3) {
|
|
13
|
+
const [open, content, closure] = node.children;
|
|
14
|
+
if (open.type === "html" && open.value === `<${TagName}>` && content.type === "text" && closure.type === "html" && closure.value === `</${TagName}>`) {
|
|
15
|
+
specifier = content.value.trim();
|
|
16
|
+
}
|
|
17
|
+
} else if (node.type === "paragraph" && node.children.length === 1) {
|
|
18
|
+
const child = node.children[0];
|
|
19
|
+
if (child.type === "mdxJsxTextElement" && child.name === TagName) {
|
|
20
|
+
const text = child.children.at(0);
|
|
21
|
+
if (text && text.type === "text") {
|
|
22
|
+
specifier = text.value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (node.type === "mdxJsxFlowElement" && node.name === TagName) {
|
|
27
|
+
const child = node.children.at(0);
|
|
28
|
+
if (child && child.type === "text") {
|
|
29
|
+
specifier = child.value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (!specifier) return;
|
|
33
|
+
const targetPath = path.resolve(path.dirname(file), specifier);
|
|
34
|
+
queue.push(
|
|
35
|
+
fs.readFile(targetPath).then(async (content) => {
|
|
36
|
+
const parsed = processor.parse(matter(content).content);
|
|
37
|
+
compiler?.addDependency(targetPath);
|
|
38
|
+
await update(parsed, targetPath, processor, compiler);
|
|
39
|
+
Object.assign(node, parsed);
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
return "skip";
|
|
43
|
+
});
|
|
44
|
+
await Promise.all(queue);
|
|
45
|
+
}
|
|
46
|
+
return async (tree, file) => {
|
|
47
|
+
await update(tree, file.path, this, file.data._compiler);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
remarkInclude
|
|
53
|
+
};
|
package/dist/config/index.cjs
CHANGED
|
@@ -152,6 +152,7 @@ function getDefaultMDXOptions({
|
|
|
152
152
|
remarkImageOptions,
|
|
153
153
|
remarkHeadingOptions,
|
|
154
154
|
remarkStructureOptions,
|
|
155
|
+
remarkCodeTabOptions,
|
|
155
156
|
...mdxOptions
|
|
156
157
|
}) {
|
|
157
158
|
const mdxExports = [
|
|
@@ -171,6 +172,7 @@ function getDefaultMDXOptions({
|
|
|
171
172
|
}
|
|
172
173
|
],
|
|
173
174
|
remarkImageOptions !== false && [import_mdx_plugins.remarkImage, remarkImageOptions],
|
|
175
|
+
remarkCodeTabOptions !== false && import_mdx_plugins.remarkCodeTab,
|
|
174
176
|
...v,
|
|
175
177
|
remarkStructureOptions !== false && [
|
|
176
178
|
import_mdx_plugins.remarkStructure,
|
|
@@ -201,35 +203,47 @@ var path = __toESM(require("path"), 1);
|
|
|
201
203
|
var fs = __toESM(require("fs/promises"), 1);
|
|
202
204
|
var import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
203
205
|
function remarkInclude() {
|
|
204
|
-
|
|
206
|
+
const TagName = "include";
|
|
207
|
+
async function update(tree, file, processor, compiler) {
|
|
205
208
|
const queue = [];
|
|
206
209
|
(0, import_unist_util_visit.visit)(tree, ["mdxJsxFlowElement", "paragraph"], (node) => {
|
|
207
210
|
let specifier;
|
|
208
211
|
if (node.type === "paragraph" && node.children.length === 3) {
|
|
209
212
|
const [open, content, closure] = node.children;
|
|
210
|
-
if (open.type === "html" && open.value ===
|
|
213
|
+
if (open.type === "html" && open.value === `<${TagName}>` && content.type === "text" && closure.type === "html" && closure.value === `</${TagName}>`) {
|
|
211
214
|
specifier = content.value.trim();
|
|
212
215
|
}
|
|
216
|
+
} else if (node.type === "paragraph" && node.children.length === 1) {
|
|
217
|
+
const child = node.children[0];
|
|
218
|
+
if (child.type === "mdxJsxTextElement" && child.name === TagName) {
|
|
219
|
+
const text = child.children.at(0);
|
|
220
|
+
if (text && text.type === "text") {
|
|
221
|
+
specifier = text.value;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
213
224
|
}
|
|
214
|
-
if (node.type === "mdxJsxFlowElement" && node.name ===
|
|
225
|
+
if (node.type === "mdxJsxFlowElement" && node.name === TagName) {
|
|
215
226
|
const child = node.children.at(0);
|
|
216
|
-
if (
|
|
217
|
-
|
|
227
|
+
if (child && child.type === "text") {
|
|
228
|
+
specifier = child.value;
|
|
229
|
+
}
|
|
218
230
|
}
|
|
219
|
-
if (!specifier) return
|
|
220
|
-
const targetPath = path.resolve(path.dirname(file
|
|
231
|
+
if (!specifier) return;
|
|
232
|
+
const targetPath = path.resolve(path.dirname(file), specifier);
|
|
221
233
|
queue.push(
|
|
222
|
-
fs.readFile(targetPath).then((content) => {
|
|
223
|
-
const parsed =
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
234
|
+
fs.readFile(targetPath).then(async (content) => {
|
|
235
|
+
const parsed = processor.parse((0, import_gray_matter.default)(content).content);
|
|
236
|
+
compiler?.addDependency(targetPath);
|
|
237
|
+
await update(parsed, targetPath, processor, compiler);
|
|
227
238
|
Object.assign(node, parsed);
|
|
228
239
|
})
|
|
229
240
|
);
|
|
230
241
|
return "skip";
|
|
231
242
|
});
|
|
232
243
|
await Promise.all(queue);
|
|
244
|
+
}
|
|
245
|
+
return async (tree, file) => {
|
|
246
|
+
await update(tree, file.path, this, file.data._compiler);
|
|
233
247
|
};
|
|
234
248
|
}
|
|
235
249
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/config/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FileInfo, G as GlobalConfig, M as MarkdownProps, a as MDXOptions, B as BaseCollectionEntry } from '../build-mdx-
|
|
2
|
-
export { C as CollectionEntry, D as DefaultMDXOptions, c as GetOutput, I as InferSchema, b as InferSchemaType, g as getDefaultMDXOptions } from '../build-mdx-
|
|
1
|
+
import { F as FileInfo, G as GlobalConfig, M as MarkdownProps, a as MDXOptions, B as BaseCollectionEntry } from '../build-mdx-TJcSpR7K.cjs';
|
|
2
|
+
export { C as CollectionEntry, D as DefaultMDXOptions, c as GetOutput, I as InferSchema, b as InferSchemaType, g as getDefaultMDXOptions } from '../build-mdx-TJcSpR7K.cjs';
|
|
3
3
|
import { z, ZodTypeAny } from 'zod';
|
|
4
4
|
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
5
5
|
import { Processor, Transformer } from 'unified';
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FileInfo, G as GlobalConfig, M as MarkdownProps, a as MDXOptions, B as BaseCollectionEntry } from '../build-mdx-
|
|
2
|
-
export { C as CollectionEntry, D as DefaultMDXOptions, c as GetOutput, I as InferSchema, b as InferSchemaType, g as getDefaultMDXOptions } from '../build-mdx-
|
|
1
|
+
import { F as FileInfo, G as GlobalConfig, M as MarkdownProps, a as MDXOptions, B as BaseCollectionEntry } from '../build-mdx-TJcSpR7K.js';
|
|
2
|
+
export { C as CollectionEntry, D as DefaultMDXOptions, c as GetOutput, I as InferSchema, b as InferSchemaType, g as getDefaultMDXOptions } from '../build-mdx-TJcSpR7K.js';
|
|
3
3
|
import { z, ZodTypeAny } from 'zod';
|
|
4
4
|
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
5
5
|
import { Processor, Transformer } from 'unified';
|
package/dist/config/index.js
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
2
|
-
import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-
|
|
2
|
+
import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-TJcSpR7K.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import 'mdx/types';
|
|
5
5
|
import 'fumadocs-core/mdx-plugins';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
2
|
-
import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-
|
|
2
|
+
import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-TJcSpR7K.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import 'mdx/types';
|
|
5
5
|
import 'fumadocs-core/mdx-plugins';
|
package/dist/loader-mdx.cjs
CHANGED
|
@@ -100,6 +100,7 @@ function getDefaultMDXOptions({
|
|
|
100
100
|
remarkImageOptions,
|
|
101
101
|
remarkHeadingOptions,
|
|
102
102
|
remarkStructureOptions,
|
|
103
|
+
remarkCodeTabOptions,
|
|
103
104
|
...mdxOptions
|
|
104
105
|
}) {
|
|
105
106
|
const mdxExports = [
|
|
@@ -119,6 +120,7 @@ function getDefaultMDXOptions({
|
|
|
119
120
|
}
|
|
120
121
|
],
|
|
121
122
|
remarkImageOptions !== false && [import_mdx_plugins.remarkImage, remarkImageOptions],
|
|
123
|
+
remarkCodeTabOptions !== false && import_mdx_plugins.remarkCodeTab,
|
|
122
124
|
...v,
|
|
123
125
|
remarkStructureOptions !== false && [
|
|
124
126
|
import_mdx_plugins.remarkStructure,
|
|
@@ -272,35 +274,47 @@ var path2 = __toESM(require("path"), 1);
|
|
|
272
274
|
var fs2 = __toESM(require("fs/promises"), 1);
|
|
273
275
|
var import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
274
276
|
function remarkInclude() {
|
|
275
|
-
|
|
277
|
+
const TagName = "include";
|
|
278
|
+
async function update(tree, file, processor, compiler) {
|
|
276
279
|
const queue = [];
|
|
277
280
|
(0, import_unist_util_visit.visit)(tree, ["mdxJsxFlowElement", "paragraph"], (node) => {
|
|
278
281
|
let specifier;
|
|
279
282
|
if (node.type === "paragraph" && node.children.length === 3) {
|
|
280
283
|
const [open, content, closure] = node.children;
|
|
281
|
-
if (open.type === "html" && open.value ===
|
|
284
|
+
if (open.type === "html" && open.value === `<${TagName}>` && content.type === "text" && closure.type === "html" && closure.value === `</${TagName}>`) {
|
|
282
285
|
specifier = content.value.trim();
|
|
283
286
|
}
|
|
287
|
+
} else if (node.type === "paragraph" && node.children.length === 1) {
|
|
288
|
+
const child = node.children[0];
|
|
289
|
+
if (child.type === "mdxJsxTextElement" && child.name === TagName) {
|
|
290
|
+
const text = child.children.at(0);
|
|
291
|
+
if (text && text.type === "text") {
|
|
292
|
+
specifier = text.value;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
284
295
|
}
|
|
285
|
-
if (node.type === "mdxJsxFlowElement" && node.name ===
|
|
296
|
+
if (node.type === "mdxJsxFlowElement" && node.name === TagName) {
|
|
286
297
|
const child = node.children.at(0);
|
|
287
|
-
if (
|
|
288
|
-
|
|
298
|
+
if (child && child.type === "text") {
|
|
299
|
+
specifier = child.value;
|
|
300
|
+
}
|
|
289
301
|
}
|
|
290
|
-
if (!specifier) return
|
|
291
|
-
const targetPath = path2.resolve(path2.dirname(file
|
|
302
|
+
if (!specifier) return;
|
|
303
|
+
const targetPath = path2.resolve(path2.dirname(file), specifier);
|
|
292
304
|
queue.push(
|
|
293
|
-
fs2.readFile(targetPath).then((content) => {
|
|
294
|
-
const parsed =
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
305
|
+
fs2.readFile(targetPath).then(async (content) => {
|
|
306
|
+
const parsed = processor.parse((0, import_gray_matter.default)(content).content);
|
|
307
|
+
compiler?.addDependency(targetPath);
|
|
308
|
+
await update(parsed, targetPath, processor, compiler);
|
|
298
309
|
Object.assign(node, parsed);
|
|
299
310
|
})
|
|
300
311
|
);
|
|
301
312
|
return "skip";
|
|
302
313
|
});
|
|
303
314
|
await Promise.all(queue);
|
|
315
|
+
}
|
|
316
|
+
return async (tree, file) => {
|
|
317
|
+
await update(tree, file.path, this, file.data._compiler);
|
|
304
318
|
};
|
|
305
319
|
}
|
|
306
320
|
|
|
@@ -344,11 +358,11 @@ function buildMDX(group, configHash, source, options = {}) {
|
|
|
344
358
|
|
|
345
359
|
// src/utils/format-error.ts
|
|
346
360
|
function formatError(message, error) {
|
|
347
|
-
const
|
|
361
|
+
const lines2 = [];
|
|
348
362
|
function walk(key, { _errors, ...rest }, padStart = 0) {
|
|
349
363
|
if (key !== void 0 || _errors.length > 0) {
|
|
350
364
|
const text = key ? `${key}: ${_errors.join("\n ")}` : _errors.join("\n");
|
|
351
|
-
|
|
365
|
+
lines2.push(
|
|
352
366
|
text.split("\n").map((line) => `${" ".repeat(padStart)}${line}`).join("\n")
|
|
353
367
|
);
|
|
354
368
|
}
|
|
@@ -357,7 +371,7 @@ function formatError(message, error) {
|
|
|
357
371
|
}
|
|
358
372
|
}
|
|
359
373
|
walk(void 0, error.format());
|
|
360
|
-
return [message, ...
|
|
374
|
+
return [message, ...lines2].join("\n");
|
|
361
375
|
}
|
|
362
376
|
|
|
363
377
|
// src/utils/git-timestamp.ts
|
|
@@ -414,7 +428,6 @@ async function loader(source, callback) {
|
|
|
414
428
|
collection = void 0;
|
|
415
429
|
}
|
|
416
430
|
const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
|
|
417
|
-
let frontmatter = matter2.data;
|
|
418
431
|
if (collection?.schema) {
|
|
419
432
|
let schema = collection.schema;
|
|
420
433
|
if (typeof schema === "function") {
|
|
@@ -432,7 +445,7 @@ async function loader(source, callback) {
|
|
|
432
445
|
path: filePath
|
|
433
446
|
});
|
|
434
447
|
}
|
|
435
|
-
const result = await schema.safeParseAsync(
|
|
448
|
+
const result = await schema.safeParseAsync(matter2.data);
|
|
436
449
|
if (result.error) {
|
|
437
450
|
callback(
|
|
438
451
|
new Error(
|
|
@@ -441,21 +454,24 @@ async function loader(source, callback) {
|
|
|
441
454
|
);
|
|
442
455
|
return;
|
|
443
456
|
}
|
|
444
|
-
|
|
457
|
+
matter2.data = result.data;
|
|
445
458
|
}
|
|
446
459
|
let timestamp;
|
|
447
460
|
if (config.global?.lastModifiedTime === "git")
|
|
448
461
|
timestamp = (await getGitTimestamp(filePath))?.getTime();
|
|
449
462
|
try {
|
|
463
|
+
const lineOffset = "\n".repeat(
|
|
464
|
+
this.mode === "development" ? lines(source) - lines(matter2.content) : 0
|
|
465
|
+
);
|
|
450
466
|
const file = await buildMDX(
|
|
451
467
|
collectionId ?? "global",
|
|
452
468
|
configHash,
|
|
453
|
-
matter2.content,
|
|
469
|
+
lineOffset + matter2.content,
|
|
454
470
|
{
|
|
455
471
|
development: this.mode === "development",
|
|
456
472
|
...mdxOptions,
|
|
457
473
|
filePath,
|
|
458
|
-
frontmatter,
|
|
474
|
+
frontmatter: matter2.data,
|
|
459
475
|
data: {
|
|
460
476
|
lastModified: timestamp
|
|
461
477
|
},
|
|
@@ -470,3 +486,10 @@ async function loader(source, callback) {
|
|
|
470
486
|
callback(error);
|
|
471
487
|
}
|
|
472
488
|
}
|
|
489
|
+
function lines(s) {
|
|
490
|
+
let num = 0;
|
|
491
|
+
for (const c of s) {
|
|
492
|
+
if (c === "\n") num++;
|
|
493
|
+
}
|
|
494
|
+
return num;
|
|
495
|
+
}
|
package/dist/loader-mdx.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
remarkInclude
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PY2KKTR2.js";
|
|
4
4
|
import {
|
|
5
5
|
getConfigHash,
|
|
6
6
|
loadConfigCached
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HPKXUFKR.js";
|
|
8
8
|
|
|
9
9
|
// src/loader-mdx.ts
|
|
10
10
|
import * as path2 from "node:path";
|
|
@@ -52,11 +52,11 @@ function buildMDX(group, configHash, source, options = {}) {
|
|
|
52
52
|
|
|
53
53
|
// src/utils/format-error.ts
|
|
54
54
|
function formatError(message, error) {
|
|
55
|
-
const
|
|
55
|
+
const lines2 = [];
|
|
56
56
|
function walk(key, { _errors, ...rest }, padStart = 0) {
|
|
57
57
|
if (key !== void 0 || _errors.length > 0) {
|
|
58
58
|
const text = key ? `${key}: ${_errors.join("\n ")}` : _errors.join("\n");
|
|
59
|
-
|
|
59
|
+
lines2.push(
|
|
60
60
|
text.split("\n").map((line) => `${" ".repeat(padStart)}${line}`).join("\n")
|
|
61
61
|
);
|
|
62
62
|
}
|
|
@@ -65,7 +65,7 @@ function formatError(message, error) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
walk(void 0, error.format());
|
|
68
|
-
return [message, ...
|
|
68
|
+
return [message, ...lines2].join("\n");
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// src/utils/git-timestamp.ts
|
|
@@ -122,7 +122,6 @@ async function loader(source, callback) {
|
|
|
122
122
|
collection = void 0;
|
|
123
123
|
}
|
|
124
124
|
const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
|
|
125
|
-
let frontmatter = matter.data;
|
|
126
125
|
if (collection?.schema) {
|
|
127
126
|
let schema = collection.schema;
|
|
128
127
|
if (typeof schema === "function") {
|
|
@@ -140,7 +139,7 @@ async function loader(source, callback) {
|
|
|
140
139
|
path: filePath
|
|
141
140
|
});
|
|
142
141
|
}
|
|
143
|
-
const result = await schema.safeParseAsync(
|
|
142
|
+
const result = await schema.safeParseAsync(matter.data);
|
|
144
143
|
if (result.error) {
|
|
145
144
|
callback(
|
|
146
145
|
new Error(
|
|
@@ -149,21 +148,24 @@ async function loader(source, callback) {
|
|
|
149
148
|
);
|
|
150
149
|
return;
|
|
151
150
|
}
|
|
152
|
-
|
|
151
|
+
matter.data = result.data;
|
|
153
152
|
}
|
|
154
153
|
let timestamp;
|
|
155
154
|
if (config.global?.lastModifiedTime === "git")
|
|
156
155
|
timestamp = (await getGitTimestamp(filePath))?.getTime();
|
|
157
156
|
try {
|
|
157
|
+
const lineOffset = "\n".repeat(
|
|
158
|
+
this.mode === "development" ? lines(source) - lines(matter.content) : 0
|
|
159
|
+
);
|
|
158
160
|
const file = await buildMDX(
|
|
159
161
|
collectionId ?? "global",
|
|
160
162
|
configHash,
|
|
161
|
-
matter.content,
|
|
163
|
+
lineOffset + matter.content,
|
|
162
164
|
{
|
|
163
165
|
development: this.mode === "development",
|
|
164
166
|
...mdxOptions,
|
|
165
167
|
filePath,
|
|
166
|
-
frontmatter,
|
|
168
|
+
frontmatter: matter.data,
|
|
167
169
|
data: {
|
|
168
170
|
lastModified: timestamp
|
|
169
171
|
},
|
|
@@ -178,6 +180,13 @@ async function loader(source, callback) {
|
|
|
178
180
|
callback(error);
|
|
179
181
|
}
|
|
180
182
|
}
|
|
183
|
+
function lines(s) {
|
|
184
|
+
let num = 0;
|
|
185
|
+
for (const c of s) {
|
|
186
|
+
if (c === "\n") num++;
|
|
187
|
+
}
|
|
188
|
+
return num;
|
|
189
|
+
}
|
|
181
190
|
export {
|
|
182
191
|
loader as default
|
|
183
192
|
};
|
package/dist/next/index.cjs
CHANGED
|
@@ -100,6 +100,7 @@ function getDefaultMDXOptions({
|
|
|
100
100
|
remarkImageOptions,
|
|
101
101
|
remarkHeadingOptions,
|
|
102
102
|
remarkStructureOptions,
|
|
103
|
+
remarkCodeTabOptions,
|
|
103
104
|
...mdxOptions
|
|
104
105
|
}) {
|
|
105
106
|
const mdxExports = [
|
|
@@ -119,6 +120,7 @@ function getDefaultMDXOptions({
|
|
|
119
120
|
}
|
|
120
121
|
],
|
|
121
122
|
remarkImageOptions !== false && [import_mdx_plugins.remarkImage, remarkImageOptions],
|
|
123
|
+
remarkCodeTabOptions !== false && import_mdx_plugins.remarkCodeTab,
|
|
122
124
|
...v,
|
|
123
125
|
remarkStructureOptions !== false && [
|
|
124
126
|
import_mdx_plugins.remarkStructure,
|
package/dist/next/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "11.3.
|
|
3
|
+
"version": "11.3.2",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
"@types/mdast": "^4.0.3",
|
|
55
55
|
"@types/mdx": "^2.0.13",
|
|
56
56
|
"@types/micromatch": "^4.0.9",
|
|
57
|
-
"@types/react": "^19.0.
|
|
58
|
-
"mdast-util-mdx-jsx": "^3.
|
|
59
|
-
"next": "^15.1.
|
|
57
|
+
"@types/react": "^19.0.7",
|
|
58
|
+
"mdast-util-mdx-jsx": "^3.2.0",
|
|
59
|
+
"next": "^15.1.6",
|
|
60
60
|
"unified": "^11.0.5",
|
|
61
61
|
"vfile": "^6.0.3",
|
|
62
62
|
"webpack": "^5.97.1",
|
|
63
63
|
"eslint-config-custom": "0.0.0",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
64
|
+
"fumadocs-core": "15.0.0",
|
|
65
|
+
"tsconfig": "0.0.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"fumadocs-core": "^14.0.0",
|
|
68
|
+
"fumadocs-core": "^14.0.0 || ^15.0.0",
|
|
69
69
|
"next": "14.x.x || 15.x.x"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
package/dist/chunk-GUHWD47S.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// src/mdx-plugins/remark-include.ts
|
|
2
|
-
import { visit } from "unist-util-visit";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import * as fs from "node:fs/promises";
|
|
5
|
-
import matter from "gray-matter";
|
|
6
|
-
function remarkInclude() {
|
|
7
|
-
return async (tree, file) => {
|
|
8
|
-
const queue = [];
|
|
9
|
-
visit(tree, ["mdxJsxFlowElement", "paragraph"], (node) => {
|
|
10
|
-
let specifier;
|
|
11
|
-
if (node.type === "paragraph" && node.children.length === 3) {
|
|
12
|
-
const [open, content, closure] = node.children;
|
|
13
|
-
if (open.type === "html" && open.value === "<include>" && content.type === "text" && closure.type === "html" && closure.value === "</include>") {
|
|
14
|
-
specifier = content.value.trim();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if (node.type === "mdxJsxFlowElement" && node.name === "include") {
|
|
18
|
-
const child = node.children.at(0);
|
|
19
|
-
if (!child || child.type !== "text") return;
|
|
20
|
-
specifier = child.value;
|
|
21
|
-
}
|
|
22
|
-
if (!specifier) return "skip";
|
|
23
|
-
const targetPath = path.resolve(path.dirname(file.path), specifier);
|
|
24
|
-
queue.push(
|
|
25
|
-
fs.readFile(targetPath).then((content) => {
|
|
26
|
-
const parsed = this.parse(matter(content).content);
|
|
27
|
-
if (file.data._compiler) {
|
|
28
|
-
file.data._compiler.addDependency(targetPath);
|
|
29
|
-
}
|
|
30
|
-
Object.assign(node, parsed);
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
return "skip";
|
|
34
|
-
});
|
|
35
|
-
await Promise.all(queue);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
remarkInclude
|
|
41
|
-
};
|