fumadocs-mdx 11.6.0 → 13.0.1
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/bin.cjs +1728 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +16 -0
- package/dist/build-mdx-CCNr86q6.d.ts +53 -0
- package/dist/build-mdx-D-r3_eQL.d.cts +53 -0
- package/dist/bun/index.cjs +857 -0
- package/dist/bun/index.d.cts +13 -0
- package/dist/bun/index.d.ts +13 -0
- package/dist/bun/index.js +62 -0
- package/dist/chunk-3J3WL7WN.js +160 -0
- package/dist/chunk-CXA4JO4Z.js +45 -0
- package/dist/chunk-EELYB2XC.js +207 -0
- package/dist/chunk-FSZMKRVH.js +80 -0
- package/dist/chunk-II3H5ZVZ.js +77 -0
- package/dist/chunk-JVZFH6ND.js +40 -0
- package/dist/chunk-K5ZLPEIQ.js +207 -0
- package/dist/{chunk-VFALQK6O.js → chunk-KILFIBVW.js} +21 -12
- package/dist/chunk-NVRDCY6Z.js +30 -0
- package/dist/chunk-U4MQ44TS.js +53 -0
- package/dist/chunk-VWJKRQZR.js +19 -0
- package/dist/chunk-XQ5O7IPO.js +128 -0
- package/dist/chunk-XZY2AWJI.js +81 -0
- package/dist/chunk-YVCR6FUH.js +82 -0
- package/dist/config/index.cjs +232 -128
- package/dist/config/index.d.cts +4 -6
- package/dist/config/index.d.ts +4 -6
- package/dist/config/index.js +26 -19
- package/dist/core-B6j6Fxse.d.cts +218 -0
- package/dist/core-B6j6Fxse.d.ts +218 -0
- package/dist/index.cjs +0 -76
- package/dist/index.d.cts +73 -20
- package/dist/index.d.ts +73 -20
- package/dist/index.js +0 -10
- package/dist/load-MNG3CLET.js +7 -0
- package/dist/next/index.cjs +567 -314
- package/dist/next/index.d.cts +9 -12
- package/dist/next/index.d.ts +9 -12
- package/dist/next/index.js +238 -211
- package/dist/node/loader.cjs +922 -0
- package/dist/node/loader.d.cts +5 -0
- package/dist/node/loader.d.ts +5 -0
- package/dist/node/loader.js +33 -0
- package/dist/plugins/json-schema.cjs +162 -0
- package/dist/plugins/json-schema.d.cts +24 -0
- package/dist/plugins/json-schema.d.ts +24 -0
- package/dist/plugins/json-schema.js +78 -0
- package/dist/{mdx-options-CAU273O3.js → preset-ZMP6U62C.js} +1 -1
- package/dist/runtime/next/async.cjs +715 -0
- package/dist/runtime/next/async.d.cts +21 -0
- package/dist/runtime/next/async.d.ts +21 -0
- package/dist/runtime/next/async.js +89 -0
- package/dist/runtime/next/index.cjs +136 -0
- package/dist/runtime/next/index.d.cts +33 -0
- package/dist/runtime/next/index.d.ts +33 -0
- package/dist/runtime/next/index.js +11 -0
- package/dist/runtime/vite/browser.cjs +107 -0
- package/dist/runtime/vite/browser.d.cts +59 -0
- package/dist/runtime/vite/browser.d.ts +59 -0
- package/dist/runtime/vite/browser.js +11 -0
- package/dist/runtime/vite/server.cjs +243 -0
- package/dist/runtime/vite/server.d.cts +30 -0
- package/dist/runtime/vite/server.d.ts +30 -0
- package/dist/runtime/vite/server.js +111 -0
- package/dist/types-AGzTfBmf.d.ts +45 -0
- package/dist/types-DKGMoay5.d.cts +45 -0
- package/dist/vite/index.cjs +1185 -0
- package/dist/vite/index.d.cts +45 -0
- package/dist/vite/index.d.ts +45 -0
- package/dist/vite/index.js +297 -0
- package/dist/webpack/index.cjs +957 -0
- package/dist/{loader-mdx.d.cts → webpack/index.d.cts} +3 -6
- package/dist/{loader-mdx.d.ts → webpack/index.d.ts} +3 -6
- package/dist/webpack/index.js +44 -0
- package/loader-mdx.cjs +1 -1
- package/package.json +86 -29
- package/bin.js +0 -5
- package/dist/chunk-2ZOW45YZ.js +0 -63
- package/dist/chunk-DRVUBK5B.js +0 -39
- package/dist/chunk-HFLDWPJA.js +0 -62
- package/dist/chunk-IOENRFUX.js +0 -112
- package/dist/chunk-MK7EXW7O.js +0 -75
- package/dist/define-BaW0PQDJ.d.cts +0 -201
- package/dist/define-BaW0PQDJ.d.ts +0 -201
- package/dist/loader-mdx.cjs +0 -527
- package/dist/loader-mdx.js +0 -162
- package/dist/runtime/async.cjs +0 -269
- package/dist/runtime/async.d.cts +0 -18
- package/dist/runtime/async.d.ts +0 -18
- package/dist/runtime/async.js +0 -73
- package/dist/types-BNrQHCj5.d.cts +0 -100
- package/dist/types-DEduCvIT.d.ts +0 -100
- package/dist/watcher-IAZDSTU7.js +0 -24
package/dist/config/index.cjs
CHANGED
|
@@ -40,9 +40,8 @@ __export(config_exports, {
|
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(config_exports);
|
|
42
42
|
|
|
43
|
-
// src/
|
|
43
|
+
// src/config/zod-4.ts
|
|
44
44
|
var import_zod = require("zod");
|
|
45
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
46
45
|
var metaSchema = import_zod.z.object({
|
|
47
46
|
title: import_zod.z.string().optional(),
|
|
48
47
|
pages: import_zod.z.array(import_zod.z.string()).optional(),
|
|
@@ -57,33 +56,24 @@ var frontmatterSchema = import_zod.z.object({
|
|
|
57
56
|
icon: import_zod.z.string().optional(),
|
|
58
57
|
full: import_zod.z.boolean().optional(),
|
|
59
58
|
// Fumadocs OpenAPI generated
|
|
60
|
-
_openapi: import_zod.z.
|
|
59
|
+
_openapi: import_zod.z.looseObject({}).optional()
|
|
61
60
|
});
|
|
62
61
|
|
|
63
62
|
// src/config/define.ts
|
|
64
63
|
function defineCollections(options) {
|
|
65
|
-
return
|
|
66
|
-
// @ts-expect-error -- internal type inferring
|
|
67
|
-
_type: void 0,
|
|
68
|
-
...options
|
|
69
|
-
};
|
|
64
|
+
return options;
|
|
70
65
|
}
|
|
71
66
|
function defineDocs(options) {
|
|
72
|
-
|
|
73
|
-
console.warn(
|
|
74
|
-
"[`source.config.ts`] Deprecated: please pass options to `defineDocs()` and specify a `dir`."
|
|
75
|
-
);
|
|
76
|
-
const dir = options?.dir ?? "content/docs";
|
|
67
|
+
const dir = options.dir ?? "content/docs";
|
|
77
68
|
return {
|
|
78
69
|
type: "docs",
|
|
79
|
-
|
|
70
|
+
dir,
|
|
80
71
|
docs: defineCollections({
|
|
81
72
|
type: "doc",
|
|
82
73
|
dir,
|
|
83
74
|
schema: frontmatterSchema,
|
|
84
75
|
...options?.docs
|
|
85
76
|
}),
|
|
86
|
-
// @ts-expect-error -- internal type inferring
|
|
87
77
|
meta: defineCollections({
|
|
88
78
|
type: "meta",
|
|
89
79
|
dir,
|
|
@@ -96,54 +86,8 @@ function defineConfig(config = {}) {
|
|
|
96
86
|
return config;
|
|
97
87
|
}
|
|
98
88
|
|
|
99
|
-
// src/
|
|
89
|
+
// src/loaders/mdx/preset.ts
|
|
100
90
|
var plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
101
|
-
|
|
102
|
-
// src/mdx-plugins/remark-exports.ts
|
|
103
|
-
var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
104
|
-
function remarkMdxExport({ values }) {
|
|
105
|
-
return (tree, vfile) => {
|
|
106
|
-
for (const name of values) {
|
|
107
|
-
if (!(name in vfile.data)) return;
|
|
108
|
-
tree.children.unshift(getMdastExport(name, vfile.data[name]));
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function getMdastExport(name, value) {
|
|
113
|
-
return {
|
|
114
|
-
type: "mdxjsEsm",
|
|
115
|
-
value: "",
|
|
116
|
-
data: {
|
|
117
|
-
estree: {
|
|
118
|
-
type: "Program",
|
|
119
|
-
sourceType: "module",
|
|
120
|
-
body: [
|
|
121
|
-
{
|
|
122
|
-
type: "ExportNamedDeclaration",
|
|
123
|
-
specifiers: [],
|
|
124
|
-
source: null,
|
|
125
|
-
declaration: {
|
|
126
|
-
type: "VariableDeclaration",
|
|
127
|
-
kind: "let",
|
|
128
|
-
declarations: [
|
|
129
|
-
{
|
|
130
|
-
type: "VariableDeclarator",
|
|
131
|
-
id: {
|
|
132
|
-
type: "Identifier",
|
|
133
|
-
name
|
|
134
|
-
},
|
|
135
|
-
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// src/utils/mdx-options.ts
|
|
147
91
|
function pluginOption(def, options = []) {
|
|
148
92
|
const list = def(Array.isArray(options) ? options : []).filter(
|
|
149
93
|
Boolean
|
|
@@ -160,14 +104,10 @@ function getDefaultMDXOptions({
|
|
|
160
104
|
remarkHeadingOptions,
|
|
161
105
|
remarkStructureOptions,
|
|
162
106
|
remarkCodeTabOptions,
|
|
107
|
+
remarkNpmOptions,
|
|
108
|
+
_withoutBundler = false,
|
|
163
109
|
...mdxOptions
|
|
164
110
|
}) {
|
|
165
|
-
const mdxExports = [
|
|
166
|
-
"structuredData",
|
|
167
|
-
"frontmatter",
|
|
168
|
-
"lastModified",
|
|
169
|
-
...valueToExport
|
|
170
|
-
];
|
|
171
111
|
const remarkPlugins = pluginOption(
|
|
172
112
|
(v) => [
|
|
173
113
|
plugins.remarkGfm,
|
|
@@ -178,15 +118,32 @@ function getDefaultMDXOptions({
|
|
|
178
118
|
...remarkHeadingOptions
|
|
179
119
|
}
|
|
180
120
|
],
|
|
181
|
-
remarkImageOptions !== false && [
|
|
182
|
-
|
|
183
|
-
|
|
121
|
+
remarkImageOptions !== false && [
|
|
122
|
+
plugins.remarkImage,
|
|
123
|
+
{
|
|
124
|
+
...remarkImageOptions,
|
|
125
|
+
useImport: _withoutBundler ? false : remarkImageOptions?.useImport
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
|
|
129
|
+
plugins.remarkCodeTab,
|
|
130
|
+
remarkCodeTabOptions
|
|
131
|
+
],
|
|
132
|
+
"remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
|
|
184
133
|
...v,
|
|
185
134
|
remarkStructureOptions !== false && [
|
|
186
135
|
plugins.remarkStructure,
|
|
187
136
|
remarkStructureOptions
|
|
188
137
|
],
|
|
189
|
-
|
|
138
|
+
() => {
|
|
139
|
+
return (_, file) => {
|
|
140
|
+
file.data["mdx-export"] ??= [];
|
|
141
|
+
for (const name of valueToExport) {
|
|
142
|
+
if (name in file.data)
|
|
143
|
+
file.data["mdx-export"].push({ name, value: file.data[name] });
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
190
147
|
],
|
|
191
148
|
mdxOptions.remarkPlugins
|
|
192
149
|
);
|
|
@@ -194,86 +151,233 @@ function getDefaultMDXOptions({
|
|
|
194
151
|
(v) => [
|
|
195
152
|
rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
|
|
196
153
|
...v,
|
|
197
|
-
|
|
154
|
+
plugins.rehypeToc
|
|
198
155
|
],
|
|
199
156
|
mdxOptions.rehypePlugins
|
|
200
157
|
);
|
|
201
158
|
return {
|
|
202
159
|
...mdxOptions,
|
|
160
|
+
outputFormat: _withoutBundler ? "function-body" : mdxOptions.outputFormat,
|
|
203
161
|
remarkPlugins,
|
|
204
162
|
rehypePlugins
|
|
205
163
|
};
|
|
206
164
|
}
|
|
207
165
|
|
|
208
|
-
// src/mdx
|
|
209
|
-
var
|
|
166
|
+
// src/loaders/mdx/remark-include.ts
|
|
167
|
+
var import_unified = require("unified");
|
|
168
|
+
var import_unist_util_visit2 = require("unist-util-visit");
|
|
210
169
|
var path = __toESM(require("path"), 1);
|
|
211
170
|
var fs = __toESM(require("fs/promises"), 1);
|
|
212
|
-
|
|
171
|
+
|
|
172
|
+
// src/utils/fuma-matter.ts
|
|
173
|
+
var import_js_yaml = require("js-yaml");
|
|
174
|
+
var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
|
|
175
|
+
function fumaMatter(input) {
|
|
176
|
+
const output = { matter: "", data: {}, content: input };
|
|
177
|
+
const match = regex.exec(input);
|
|
178
|
+
if (!match) {
|
|
179
|
+
return output;
|
|
180
|
+
}
|
|
181
|
+
output.matter = match[0];
|
|
182
|
+
output.content = input.slice(match[0].length);
|
|
183
|
+
const loaded = (0, import_js_yaml.load)(match[1]);
|
|
184
|
+
output.data = loaded ?? {};
|
|
185
|
+
return output;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/loaders/mdx/remark-include.ts
|
|
189
|
+
var import_mdx_plugins = require("fumadocs-core/mdx-plugins");
|
|
190
|
+
|
|
191
|
+
// src/loaders/mdx/remark-unravel.ts
|
|
192
|
+
var import_unist_util_visit = require("unist-util-visit");
|
|
193
|
+
function remarkMarkAndUnravel() {
|
|
194
|
+
return (tree) => {
|
|
195
|
+
(0, import_unist_util_visit.visit)(tree, function(node, index, parent) {
|
|
196
|
+
let offset = -1;
|
|
197
|
+
let all = true;
|
|
198
|
+
let oneOrMore = false;
|
|
199
|
+
if (parent && typeof index === "number" && node.type === "paragraph") {
|
|
200
|
+
const children = node.children;
|
|
201
|
+
while (++offset < children.length) {
|
|
202
|
+
const child = children[offset];
|
|
203
|
+
if (child.type === "mdxJsxTextElement" || child.type === "mdxTextExpression") {
|
|
204
|
+
oneOrMore = true;
|
|
205
|
+
} else if (child.type === "text" && child.value.trim().length === 0) {
|
|
206
|
+
} else {
|
|
207
|
+
all = false;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (all && oneOrMore) {
|
|
212
|
+
offset = -1;
|
|
213
|
+
const newChildren = [];
|
|
214
|
+
while (++offset < children.length) {
|
|
215
|
+
const child = children[offset];
|
|
216
|
+
if (child.type === "mdxJsxTextElement") {
|
|
217
|
+
child.type = "mdxJsxFlowElement";
|
|
218
|
+
}
|
|
219
|
+
if (child.type === "mdxTextExpression") {
|
|
220
|
+
child.type = "mdxFlowExpression";
|
|
221
|
+
}
|
|
222
|
+
if (child.type === "text" && /^[\t\r\n ]+$/.test(String(child.value))) {
|
|
223
|
+
} else {
|
|
224
|
+
newChildren.push(child);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
parent.children.splice(index, 1, ...newChildren);
|
|
228
|
+
return index;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/loaders/mdx/remark-include.ts
|
|
236
|
+
var ElementLikeTypes = [
|
|
237
|
+
"mdxJsxFlowElement",
|
|
238
|
+
"mdxJsxTextElement",
|
|
239
|
+
"containerDirective",
|
|
240
|
+
"textDirective",
|
|
241
|
+
"leafDirective"
|
|
242
|
+
];
|
|
243
|
+
function isElementLike(node) {
|
|
244
|
+
return ElementLikeTypes.includes(node.type);
|
|
245
|
+
}
|
|
246
|
+
function parseElementAttributes(element) {
|
|
247
|
+
if (Array.isArray(element.attributes)) {
|
|
248
|
+
const attributes = {};
|
|
249
|
+
for (const attr of element.attributes) {
|
|
250
|
+
if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
|
|
251
|
+
attributes[attr.name] = attr.value;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return attributes;
|
|
255
|
+
}
|
|
256
|
+
return element.attributes ?? {};
|
|
257
|
+
}
|
|
213
258
|
function flattenNode(node) {
|
|
214
259
|
if ("children" in node)
|
|
215
260
|
return node.children.map((child) => flattenNode(child)).join("");
|
|
216
261
|
if ("value" in node) return node.value;
|
|
217
262
|
return "";
|
|
218
263
|
}
|
|
264
|
+
function parseSpecifier(specifier) {
|
|
265
|
+
const idx = specifier.lastIndexOf("#");
|
|
266
|
+
if (idx === -1) return { file: specifier };
|
|
267
|
+
return {
|
|
268
|
+
file: specifier.slice(0, idx),
|
|
269
|
+
section: specifier.slice(idx + 1)
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function extractSection(root, section) {
|
|
273
|
+
let nodes;
|
|
274
|
+
let capturingHeadingContent = false;
|
|
275
|
+
(0, import_unist_util_visit2.visit)(root, (node) => {
|
|
276
|
+
if (node.type === "heading") {
|
|
277
|
+
if (capturingHeadingContent) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
if (node.data?.hProperties?.id === section) {
|
|
281
|
+
capturingHeadingContent = true;
|
|
282
|
+
nodes = [node];
|
|
283
|
+
return "skip";
|
|
284
|
+
}
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (capturingHeadingContent) {
|
|
288
|
+
nodes?.push(node);
|
|
289
|
+
return "skip";
|
|
290
|
+
}
|
|
291
|
+
if (isElementLike(node) && node.name === "section") {
|
|
292
|
+
const attributes = parseElementAttributes(node);
|
|
293
|
+
if (attributes.id === section) {
|
|
294
|
+
nodes = node.children;
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
if (nodes)
|
|
300
|
+
return {
|
|
301
|
+
type: "root",
|
|
302
|
+
children: nodes
|
|
303
|
+
};
|
|
304
|
+
}
|
|
219
305
|
function remarkInclude() {
|
|
220
306
|
const TagName = "include";
|
|
221
|
-
async
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const parsed = processor.parse((0, import_gray_matter.default)(content).content);
|
|
261
|
-
await update(parsed, targetPath, processor, compiler);
|
|
262
|
-
Object.assign(
|
|
263
|
-
parent && parent.type === "paragraph" ? parent : node,
|
|
264
|
-
parsed
|
|
265
|
-
);
|
|
266
|
-
}).catch((e) => {
|
|
267
|
-
console.warn(`failed to read file: ${targetPath}`, e);
|
|
268
|
-
})
|
|
307
|
+
const embedContent = async (file, heading, params, data) => {
|
|
308
|
+
let content;
|
|
309
|
+
try {
|
|
310
|
+
content = (await fs.readFile(file)).toString();
|
|
311
|
+
} catch (e) {
|
|
312
|
+
throw new Error(
|
|
313
|
+
`failed to read file ${file}
|
|
314
|
+
${e instanceof Error ? e.message : String(e)}`,
|
|
315
|
+
{ cause: e }
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
const ext = path.extname(file);
|
|
319
|
+
data._compiler?.addDependency(file);
|
|
320
|
+
if (params.lang || ext !== ".md" && ext !== ".mdx") {
|
|
321
|
+
const lang = params.lang ?? ext.slice(1);
|
|
322
|
+
return {
|
|
323
|
+
type: "code",
|
|
324
|
+
lang,
|
|
325
|
+
meta: params.meta,
|
|
326
|
+
value: content,
|
|
327
|
+
data: {}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
const parser = data._getProcessor ? data._getProcessor(ext === ".mdx" ? "mdx" : "md") : this;
|
|
331
|
+
const parsed = fumaMatter(content);
|
|
332
|
+
let mdast = parser.parse({
|
|
333
|
+
path: file,
|
|
334
|
+
value: parsed.content,
|
|
335
|
+
data: { frontmatter: parsed.data }
|
|
336
|
+
});
|
|
337
|
+
const baseProcessor = (0, import_unified.unified)().use(remarkMarkAndUnravel);
|
|
338
|
+
if (heading) {
|
|
339
|
+
const extracted = extractSection(
|
|
340
|
+
await baseProcessor.use(import_mdx_plugins.remarkHeading).run(mdast),
|
|
341
|
+
heading
|
|
342
|
+
);
|
|
343
|
+
if (!extracted)
|
|
344
|
+
throw new Error(
|
|
345
|
+
`Cannot find section ${heading} in ${file}, make sure you have encapsulated the section in a <section id="${heading}"> tag, or a :::section directive with remark-directive configured.`
|
|
269
346
|
);
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
347
|
+
mdast = extracted;
|
|
348
|
+
} else {
|
|
349
|
+
mdast = await baseProcessor.run(mdast);
|
|
350
|
+
}
|
|
351
|
+
await update(mdast, path.dirname(file), data);
|
|
352
|
+
return mdast;
|
|
353
|
+
};
|
|
354
|
+
async function update(tree, directory, data) {
|
|
355
|
+
const queue = [];
|
|
356
|
+
(0, import_unist_util_visit2.visit)(tree, ElementLikeTypes, (_node, _, parent) => {
|
|
357
|
+
const node = _node;
|
|
358
|
+
if (node.name !== TagName) return;
|
|
359
|
+
const specifier = flattenNode(node);
|
|
360
|
+
if (specifier.length === 0) return "skip";
|
|
361
|
+
const attributes = parseElementAttributes(node);
|
|
362
|
+
const { file: relativePath, section } = parseSpecifier(specifier);
|
|
363
|
+
const file = path.resolve(
|
|
364
|
+
"cwd" in attributes ? process.cwd() : directory,
|
|
365
|
+
relativePath
|
|
366
|
+
);
|
|
367
|
+
queue.push(
|
|
368
|
+
embedContent(file, section, attributes, data).then((replace) => {
|
|
369
|
+
Object.assign(
|
|
370
|
+
parent && parent.type === "paragraph" ? parent : node,
|
|
371
|
+
replace
|
|
372
|
+
);
|
|
373
|
+
})
|
|
374
|
+
);
|
|
375
|
+
return "skip";
|
|
376
|
+
});
|
|
273
377
|
await Promise.all(queue);
|
|
274
378
|
}
|
|
275
379
|
return async (tree, file) => {
|
|
276
|
-
await update(tree, file.path,
|
|
380
|
+
await update(tree, path.dirname(file.path), file.data);
|
|
277
381
|
};
|
|
278
382
|
}
|
|
279
383
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/config/index.d.cts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, D as DefaultMDXOptions, b as DocCollection, c as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, f as defineConfig, e as defineDocs, h as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-B6j6Fxse.cjs';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
|
-
import '@
|
|
5
|
-
import 'mdx/types';
|
|
4
|
+
import '@standard-schema/spec';
|
|
6
5
|
import 'fumadocs-core/mdx-plugins';
|
|
7
|
-
import '
|
|
8
|
-
import 'react';
|
|
6
|
+
import '@mdx-js/mdx';
|
|
9
7
|
import 'zod';
|
|
10
|
-
import '
|
|
8
|
+
import 'chokidar';
|
|
11
9
|
|
|
12
10
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
13
11
|
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, D as DefaultMDXOptions, b as DocCollection, c as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, f as defineConfig, e as defineDocs, h as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-B6j6Fxse.js';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
|
-
import '@
|
|
5
|
-
import 'mdx/types';
|
|
4
|
+
import '@standard-schema/spec';
|
|
6
5
|
import 'fumadocs-core/mdx-plugins';
|
|
7
|
-
import '
|
|
8
|
-
import 'react';
|
|
6
|
+
import '@mdx-js/mdx';
|
|
9
7
|
import 'zod';
|
|
10
|
-
import '
|
|
8
|
+
import 'chokidar';
|
|
11
9
|
|
|
12
10
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
13
11
|
|
package/dist/config/index.js
CHANGED
|
@@ -1,38 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "../chunk-2ZOW45YZ.js";
|
|
2
|
+
getDefaultMDXOptions
|
|
3
|
+
} from "../chunk-FSZMKRVH.js";
|
|
5
4
|
import {
|
|
6
5
|
remarkInclude
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
} from "../chunk-K5ZLPEIQ.js";
|
|
7
|
+
import "../chunk-VWJKRQZR.js";
|
|
8
|
+
|
|
9
|
+
// src/config/zod-4.ts
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
var metaSchema = z.object({
|
|
12
|
+
title: z.string().optional(),
|
|
13
|
+
pages: z.array(z.string()).optional(),
|
|
14
|
+
description: z.string().optional(),
|
|
15
|
+
root: z.boolean().optional(),
|
|
16
|
+
defaultOpen: z.boolean().optional(),
|
|
17
|
+
icon: z.string().optional()
|
|
18
|
+
});
|
|
19
|
+
var frontmatterSchema = z.object({
|
|
20
|
+
title: z.string(),
|
|
21
|
+
description: z.string().optional(),
|
|
22
|
+
icon: z.string().optional(),
|
|
23
|
+
full: z.boolean().optional(),
|
|
24
|
+
// Fumadocs OpenAPI generated
|
|
25
|
+
_openapi: z.looseObject({}).optional()
|
|
26
|
+
});
|
|
11
27
|
|
|
12
28
|
// src/config/define.ts
|
|
13
29
|
function defineCollections(options) {
|
|
14
|
-
return
|
|
15
|
-
// @ts-expect-error -- internal type inferring
|
|
16
|
-
_type: void 0,
|
|
17
|
-
...options
|
|
18
|
-
};
|
|
30
|
+
return options;
|
|
19
31
|
}
|
|
20
32
|
function defineDocs(options) {
|
|
21
|
-
|
|
22
|
-
console.warn(
|
|
23
|
-
"[`source.config.ts`] Deprecated: please pass options to `defineDocs()` and specify a `dir`."
|
|
24
|
-
);
|
|
25
|
-
const dir = options?.dir ?? "content/docs";
|
|
33
|
+
const dir = options.dir ?? "content/docs";
|
|
26
34
|
return {
|
|
27
35
|
type: "docs",
|
|
28
|
-
|
|
36
|
+
dir,
|
|
29
37
|
docs: defineCollections({
|
|
30
38
|
type: "doc",
|
|
31
39
|
dir,
|
|
32
40
|
schema: frontmatterSchema,
|
|
33
41
|
...options?.docs
|
|
34
42
|
}),
|
|
35
|
-
// @ts-expect-error -- internal type inferring
|
|
36
43
|
meta: defineCollections({
|
|
37
44
|
type: "meta",
|
|
38
45
|
dir,
|