fumadocs-mdx 11.6.8 → 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-KTLWF7GN.js → chunk-AVMO2SRO.js} +1 -1
- package/dist/chunk-KVWX6THC.js +19 -0
- package/dist/{chunk-VC3Y6FLZ.js → chunk-YRT4TZBA.js} +10 -1
- package/dist/config/index.cjs +17 -29
- 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 +144 -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/{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 +16 -3
- package/dist/chunk-MXACIHNJ.js +0 -40
- 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
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -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,6 +208,15 @@ 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");
|
|
@@ -215,37 +224,16 @@ var path = __toESM(require("path"), 1);
|
|
|
215
224
|
var fs = __toESM(require("fs/promises"), 1);
|
|
216
225
|
|
|
217
226
|
// src/utils/fuma-matter.ts
|
|
218
|
-
var import_lru_cache = require("lru-cache");
|
|
219
227
|
var import_js_yaml = require("js-yaml");
|
|
220
|
-
var
|
|
221
|
-
max: 200
|
|
222
|
-
});
|
|
228
|
+
var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
|
|
223
229
|
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)) {
|
|
230
|
+
const output = { matter: "", data: {}, content: input };
|
|
231
|
+
const match = regex.exec(input);
|
|
232
|
+
if (!match) {
|
|
239
233
|
return output;
|
|
240
234
|
}
|
|
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);
|
|
235
|
+
output.matter = match[1];
|
|
236
|
+
output.content = input.slice(match[0].length);
|
|
249
237
|
const loaded = (0, import_js_yaml.load)(output.matter);
|
|
250
238
|
output.data = loaded ?? {};
|
|
251
239
|
return output;
|
|
@@ -327,7 +315,7 @@ ${e instanceof Error ? e.message : String(e)}`
|
|
|
327
315
|
defineConfig,
|
|
328
316
|
defineDocs,
|
|
329
317
|
frontmatterSchema,
|
|
330
|
-
|
|
318
|
+
loadDefaultOptions,
|
|
331
319
|
metaSchema,
|
|
332
320
|
remarkInclude
|
|
333
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,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-YRT4TZBA.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-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';
|
package/dist/loader-mdx.cjs
CHANGED
|
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
8
|
var __export = (target, all) => {
|
|
12
9
|
for (var name in all)
|
|
13
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,133 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
27
|
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
29
|
|
|
33
|
-
// src/mdx-plugins/remark-exports.ts
|
|
34
|
-
function remarkMdxExport({ values }) {
|
|
35
|
-
return (tree, vfile) => {
|
|
36
|
-
for (const name of values) {
|
|
37
|
-
if (!(name in vfile.data)) return;
|
|
38
|
-
tree.children.unshift(getMdastExport(name, vfile.data[name]));
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function getMdastExport(name, value) {
|
|
43
|
-
return {
|
|
44
|
-
type: "mdxjsEsm",
|
|
45
|
-
value: "",
|
|
46
|
-
data: {
|
|
47
|
-
estree: {
|
|
48
|
-
type: "Program",
|
|
49
|
-
sourceType: "module",
|
|
50
|
-
body: [
|
|
51
|
-
{
|
|
52
|
-
type: "ExportNamedDeclaration",
|
|
53
|
-
specifiers: [],
|
|
54
|
-
source: null,
|
|
55
|
-
declaration: {
|
|
56
|
-
type: "VariableDeclaration",
|
|
57
|
-
kind: "let",
|
|
58
|
-
declarations: [
|
|
59
|
-
{
|
|
60
|
-
type: "VariableDeclarator",
|
|
61
|
-
id: {
|
|
62
|
-
type: "Identifier",
|
|
63
|
-
name
|
|
64
|
-
},
|
|
65
|
-
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
var import_estree_util_value_to_estree;
|
|
76
|
-
var init_remark_exports = __esm({
|
|
77
|
-
"src/mdx-plugins/remark-exports.ts"() {
|
|
78
|
-
"use strict";
|
|
79
|
-
import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// src/utils/mdx-options.ts
|
|
84
|
-
var mdx_options_exports = {};
|
|
85
|
-
__export(mdx_options_exports, {
|
|
86
|
-
getDefaultMDXOptions: () => getDefaultMDXOptions
|
|
87
|
-
});
|
|
88
|
-
function pluginOption(def, options = []) {
|
|
89
|
-
const list = def(Array.isArray(options) ? options : []).filter(
|
|
90
|
-
Boolean
|
|
91
|
-
);
|
|
92
|
-
if (typeof options === "function") {
|
|
93
|
-
return options(list);
|
|
94
|
-
}
|
|
95
|
-
return list;
|
|
96
|
-
}
|
|
97
|
-
function getDefaultMDXOptions({
|
|
98
|
-
valueToExport = [],
|
|
99
|
-
rehypeCodeOptions,
|
|
100
|
-
remarkImageOptions,
|
|
101
|
-
remarkHeadingOptions,
|
|
102
|
-
remarkStructureOptions,
|
|
103
|
-
remarkCodeTabOptions,
|
|
104
|
-
...mdxOptions
|
|
105
|
-
}) {
|
|
106
|
-
const mdxExports = [
|
|
107
|
-
"structuredData",
|
|
108
|
-
"frontmatter",
|
|
109
|
-
"lastModified",
|
|
110
|
-
...valueToExport
|
|
111
|
-
];
|
|
112
|
-
const remarkPlugins = pluginOption(
|
|
113
|
-
(v) => [
|
|
114
|
-
plugins.remarkGfm,
|
|
115
|
-
[
|
|
116
|
-
plugins.remarkHeading,
|
|
117
|
-
{
|
|
118
|
-
generateToc: false,
|
|
119
|
-
...remarkHeadingOptions
|
|
120
|
-
}
|
|
121
|
-
],
|
|
122
|
-
remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
|
|
123
|
-
// Fumadocs 14 compatibility
|
|
124
|
-
"remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
|
|
125
|
-
plugins.remarkCodeTab,
|
|
126
|
-
remarkCodeTabOptions
|
|
127
|
-
],
|
|
128
|
-
...v,
|
|
129
|
-
remarkStructureOptions !== false && [
|
|
130
|
-
plugins.remarkStructure,
|
|
131
|
-
remarkStructureOptions
|
|
132
|
-
],
|
|
133
|
-
[remarkMdxExport, { values: mdxExports }]
|
|
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
|
-
remarkPlugins,
|
|
148
|
-
rehypePlugins
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
var plugins;
|
|
152
|
-
var init_mdx_options = __esm({
|
|
153
|
-
"src/utils/mdx-options.ts"() {
|
|
154
|
-
"use strict";
|
|
155
|
-
plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
156
|
-
init_remark_exports();
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
|
|
160
30
|
// src/loader-mdx.ts
|
|
161
31
|
var loader_mdx_exports = {};
|
|
162
32
|
__export(loader_mdx_exports, {
|
|
@@ -263,37 +133,16 @@ var path2 = __toESM(require("path"), 1);
|
|
|
263
133
|
var fs2 = __toESM(require("fs/promises"), 1);
|
|
264
134
|
|
|
265
135
|
// src/utils/fuma-matter.ts
|
|
266
|
-
var import_lru_cache = require("lru-cache");
|
|
267
136
|
var import_js_yaml = require("js-yaml");
|
|
268
|
-
var
|
|
269
|
-
max: 200
|
|
270
|
-
});
|
|
137
|
+
var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
|
|
271
138
|
function fumaMatter(input) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const cached = cache2.get(input);
|
|
276
|
-
if (cached) return cached;
|
|
277
|
-
const result = parseMatter(input);
|
|
278
|
-
cache2.set(input, result);
|
|
279
|
-
return structuredClone(result);
|
|
280
|
-
}
|
|
281
|
-
var delimiter = "---";
|
|
282
|
-
function parseMatter(str) {
|
|
283
|
-
const output = { matter: "", data: {}, content: str };
|
|
284
|
-
const open = delimiter + "\n";
|
|
285
|
-
const close = "\n" + delimiter;
|
|
286
|
-
if (!str.startsWith(open)) {
|
|
139
|
+
const output = { matter: "", data: {}, content: input };
|
|
140
|
+
const match = regex.exec(input);
|
|
141
|
+
if (!match) {
|
|
287
142
|
return output;
|
|
288
143
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
let closeIdx = str.indexOf(close);
|
|
292
|
-
if (closeIdx === -1) {
|
|
293
|
-
closeIdx = len;
|
|
294
|
-
}
|
|
295
|
-
output.matter = str.slice(0, closeIdx);
|
|
296
|
-
output.content = str.slice(closeIdx + close.length);
|
|
144
|
+
output.matter = match[1];
|
|
145
|
+
output.content = input.slice(match[0].length);
|
|
297
146
|
const loaded = (0, import_js_yaml.load)(output.matter);
|
|
298
147
|
output.data = loaded ?? {};
|
|
299
148
|
return output;
|
|
@@ -371,7 +220,7 @@ ${e instanceof Error ? e.message : String(e)}`
|
|
|
371
220
|
}
|
|
372
221
|
|
|
373
222
|
// src/utils/build-mdx.ts
|
|
374
|
-
var
|
|
223
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
375
224
|
async function buildMDX(cacheKey, source, options) {
|
|
376
225
|
const { filePath, frontmatter, data, ...rest } = options;
|
|
377
226
|
let format = options.format;
|
|
@@ -380,16 +229,15 @@ async function buildMDX(cacheKey, source, options) {
|
|
|
380
229
|
}
|
|
381
230
|
format ??= "mdx";
|
|
382
231
|
const key = `${cacheKey}:${format}`;
|
|
383
|
-
let cached =
|
|
384
|
-
if (cached
|
|
232
|
+
let cached = cache2.get(key);
|
|
233
|
+
if (!cached) {
|
|
385
234
|
cached = (0, import_mdx.createProcessor)({
|
|
386
235
|
outputFormat: "program",
|
|
387
|
-
development: process.env.NODE_ENV === "development",
|
|
388
236
|
...rest,
|
|
389
237
|
remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
|
|
390
238
|
format
|
|
391
239
|
});
|
|
392
|
-
|
|
240
|
+
cache2.set(key, cached);
|
|
393
241
|
}
|
|
394
242
|
return cached.process({
|
|
395
243
|
value: source,
|
|
@@ -405,9 +253,9 @@ async function buildMDX(cacheKey, source, options) {
|
|
|
405
253
|
// src/utils/git-timestamp.ts
|
|
406
254
|
var import_node_path = __toESM(require("path"), 1);
|
|
407
255
|
var import_tinyexec = require("tinyexec");
|
|
408
|
-
var
|
|
256
|
+
var cache3 = /* @__PURE__ */ new Map();
|
|
409
257
|
async function getGitTimestamp(file) {
|
|
410
|
-
const cached =
|
|
258
|
+
const cached = cache3.get(file);
|
|
411
259
|
if (cached) return cached;
|
|
412
260
|
try {
|
|
413
261
|
const out = await (0, import_tinyexec.x)(
|
|
@@ -418,7 +266,7 @@ async function getGitTimestamp(file) {
|
|
|
418
266
|
}
|
|
419
267
|
);
|
|
420
268
|
const time = new Date(out.stdout);
|
|
421
|
-
|
|
269
|
+
cache3.set(file, time);
|
|
422
270
|
return time;
|
|
423
271
|
} catch {
|
|
424
272
|
return;
|
|
@@ -480,6 +328,136 @@ async function validate(schema, data, context, errorMessage) {
|
|
|
480
328
|
return data;
|
|
481
329
|
}
|
|
482
330
|
|
|
331
|
+
// src/utils/count-lines.ts
|
|
332
|
+
function countLines(s) {
|
|
333
|
+
let num = 0;
|
|
334
|
+
for (const c of s) {
|
|
335
|
+
if (c === "\n") num++;
|
|
336
|
+
}
|
|
337
|
+
return num;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/utils/mdx-options.ts
|
|
341
|
+
var plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
342
|
+
|
|
343
|
+
// src/mdx-plugins/remark-exports.ts
|
|
344
|
+
var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
345
|
+
function remarkMdxExport({ values }) {
|
|
346
|
+
return (tree, vfile) => {
|
|
347
|
+
for (const name of values) {
|
|
348
|
+
if (!(name in vfile.data)) return;
|
|
349
|
+
tree.children.unshift(getMdastExport(name, vfile.data[name]));
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
function getMdastExport(name, value) {
|
|
354
|
+
return {
|
|
355
|
+
type: "mdxjsEsm",
|
|
356
|
+
value: "",
|
|
357
|
+
data: {
|
|
358
|
+
estree: {
|
|
359
|
+
type: "Program",
|
|
360
|
+
sourceType: "module",
|
|
361
|
+
body: [
|
|
362
|
+
{
|
|
363
|
+
type: "ExportNamedDeclaration",
|
|
364
|
+
specifiers: [],
|
|
365
|
+
source: null,
|
|
366
|
+
declaration: {
|
|
367
|
+
type: "VariableDeclaration",
|
|
368
|
+
kind: "let",
|
|
369
|
+
declarations: [
|
|
370
|
+
{
|
|
371
|
+
type: "VariableDeclarator",
|
|
372
|
+
id: {
|
|
373
|
+
type: "Identifier",
|
|
374
|
+
name
|
|
375
|
+
},
|
|
376
|
+
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
377
|
+
}
|
|
378
|
+
]
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
]
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// src/utils/mdx-options.ts
|
|
388
|
+
function pluginOption(def, options = []) {
|
|
389
|
+
const list = def(Array.isArray(options) ? options : []).filter(
|
|
390
|
+
Boolean
|
|
391
|
+
);
|
|
392
|
+
if (typeof options === "function") {
|
|
393
|
+
return options(list);
|
|
394
|
+
}
|
|
395
|
+
return list;
|
|
396
|
+
}
|
|
397
|
+
function getDefaultMDXOptions({
|
|
398
|
+
valueToExport = [],
|
|
399
|
+
rehypeCodeOptions,
|
|
400
|
+
remarkImageOptions,
|
|
401
|
+
remarkHeadingOptions,
|
|
402
|
+
remarkStructureOptions,
|
|
403
|
+
remarkCodeTabOptions,
|
|
404
|
+
...mdxOptions
|
|
405
|
+
}) {
|
|
406
|
+
const mdxExports = [
|
|
407
|
+
"structuredData",
|
|
408
|
+
"frontmatter",
|
|
409
|
+
"lastModified",
|
|
410
|
+
...valueToExport
|
|
411
|
+
];
|
|
412
|
+
const remarkPlugins = pluginOption(
|
|
413
|
+
(v) => [
|
|
414
|
+
plugins.remarkGfm,
|
|
415
|
+
[
|
|
416
|
+
plugins.remarkHeading,
|
|
417
|
+
{
|
|
418
|
+
generateToc: false,
|
|
419
|
+
...remarkHeadingOptions
|
|
420
|
+
}
|
|
421
|
+
],
|
|
422
|
+
remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
|
|
423
|
+
// Fumadocs 14 compatibility
|
|
424
|
+
"remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
|
|
425
|
+
plugins.remarkCodeTab,
|
|
426
|
+
remarkCodeTabOptions
|
|
427
|
+
],
|
|
428
|
+
...v,
|
|
429
|
+
remarkStructureOptions !== false && [
|
|
430
|
+
plugins.remarkStructure,
|
|
431
|
+
remarkStructureOptions
|
|
432
|
+
],
|
|
433
|
+
[remarkMdxExport, { values: mdxExports }]
|
|
434
|
+
],
|
|
435
|
+
mdxOptions.remarkPlugins
|
|
436
|
+
);
|
|
437
|
+
const rehypePlugins = pluginOption(
|
|
438
|
+
(v) => [
|
|
439
|
+
rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
|
|
440
|
+
...v,
|
|
441
|
+
plugins.rehypeToc
|
|
442
|
+
],
|
|
443
|
+
mdxOptions.rehypePlugins
|
|
444
|
+
);
|
|
445
|
+
return {
|
|
446
|
+
...mdxOptions,
|
|
447
|
+
remarkPlugins,
|
|
448
|
+
rehypePlugins
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
async function loadDefaultOptions(config) {
|
|
452
|
+
const input = config.global?.mdxOptions;
|
|
453
|
+
config._mdx_loader ??= {};
|
|
454
|
+
const mdxLoader = config._mdx_loader;
|
|
455
|
+
if (!mdxLoader.cachedOptions) {
|
|
456
|
+
mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions(await input()) : getDefaultMDXOptions(input ?? {});
|
|
457
|
+
}
|
|
458
|
+
return mdxLoader.cachedOptions;
|
|
459
|
+
}
|
|
460
|
+
|
|
483
461
|
// src/loader-mdx.ts
|
|
484
462
|
async function loader(source, callback) {
|
|
485
463
|
this.cacheable(true);
|
|
@@ -523,7 +501,7 @@ async function loader(source, callback) {
|
|
|
523
501
|
}
|
|
524
502
|
try {
|
|
525
503
|
const lineOffset = "\n".repeat(
|
|
526
|
-
this.mode === "development" ?
|
|
504
|
+
this.mode === "development" ? countLines(matter.matter) : 0
|
|
527
505
|
);
|
|
528
506
|
const file = await buildMDX(
|
|
529
507
|
`${configHash}:${collectionId ?? "global"}`,
|
|
@@ -547,20 +525,3 @@ async function loader(source, callback) {
|
|
|
547
525
|
callback(error);
|
|
548
526
|
}
|
|
549
527
|
}
|
|
550
|
-
async function loadDefaultOptions(config) {
|
|
551
|
-
const input = config.global?.mdxOptions;
|
|
552
|
-
config._mdx_loader ??= {};
|
|
553
|
-
const mdxLoader = config._mdx_loader;
|
|
554
|
-
if (!mdxLoader.cachedOptions) {
|
|
555
|
-
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
|
|
556
|
-
mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions2(await input()) : getDefaultMDXOptions2(input ?? {});
|
|
557
|
-
}
|
|
558
|
-
return mdxLoader.cachedOptions;
|
|
559
|
-
}
|
|
560
|
-
function lines(s) {
|
|
561
|
-
let num = 0;
|
|
562
|
-
for (const c of s) {
|
|
563
|
-
if (c === "\n") num++;
|
|
564
|
-
}
|
|
565
|
-
return num;
|
|
566
|
-
}
|