fumadocs-mdx 12.0.0 → 12.0.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/bin.cjs +103 -85
- package/dist/bin.js +1 -1
- package/dist/{browser-D5lvL8vv.d.ts → browser-BupUnhpC.d.ts} +1 -1
- package/dist/{browser-DjWADqp8.d.cts → browser-R0x9IPaQ.d.cts} +1 -1
- package/dist/bun/index.cjs +156 -130
- package/dist/bun/index.js +10 -10
- package/dist/chunk-ADR6R7HM.js +29 -0
- package/dist/{chunk-3M4SHY6K.js → chunk-FSZMKRVH.js} +1 -1
- package/dist/{chunk-POXTQZ4D.js → chunk-LGYVNESJ.js} +2 -6
- package/dist/chunk-LMG6UWCL.js +167 -0
- package/dist/{chunk-SWNOXPYJ.js → chunk-QAUWMR5D.js} +6 -6
- package/dist/{chunk-KGUBBRL6.js → chunk-RMDXSZYE.js} +11 -39
- package/dist/{chunk-YC25YEBF.js → chunk-U4MQ44TS.js} +1 -1
- package/dist/chunk-XMFLD5J6.js +30 -0
- package/dist/{chunk-TLD6JMT6.js → chunk-ZX7TM4AR.js} +4 -2
- package/dist/config/index.cjs +84 -56
- package/dist/config/index.d.cts +2 -6
- package/dist/config/index.d.ts +2 -6
- package/dist/config/index.js +2 -2
- package/dist/{define--6HQ1ehX.d.cts → define-DJbJduHy.d.cts} +15 -15
- package/dist/{define--6HQ1ehX.d.ts → define-DJbJduHy.d.ts} +15 -15
- package/dist/index.cjs +127 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +11 -0
- package/dist/load-UUXLUBHL.js +9 -0
- package/dist/loader-mdx.cjs +217 -174
- package/dist/loader-mdx.js +7 -7
- package/dist/next/index.cjs +129 -109
- package/dist/next/index.js +40 -54
- package/dist/node/loader.cjs +152 -109
- package/dist/node/loader.js +6 -7
- package/dist/postinstall-SCSXM4IM.js +10 -0
- package/dist/{preset-WFEORCAB.js → preset-ZMP6U62C.js} +1 -1
- package/dist/runtime/next/async.cjs +117 -65
- package/dist/runtime/next/async.d.cts +3 -3
- package/dist/runtime/next/async.d.ts +3 -3
- package/dist/runtime/next/async.js +15 -8
- package/dist/runtime/next/index.d.cts +8 -8
- package/dist/runtime/next/index.d.ts +8 -8
- package/dist/runtime/vite/browser.d.cts +2 -2
- package/dist/runtime/vite/browser.d.ts +2 -2
- package/dist/runtime/vite/server.d.cts +5 -5
- package/dist/runtime/vite/server.d.ts +5 -5
- package/dist/{shared-CqgMnt9h.d.cts → shared-Cnm1afPW.d.cts} +3 -2
- package/dist/{shared-0QIuV0XZ.d.ts → shared-DpXxElc1.d.ts} +3 -2
- package/dist/{types-DLIAvrgC.d.ts → types-CbLt05Gc.d.cts} +7 -8
- package/dist/{types-Dl8HLbm5.d.cts → types-Ci6BA1tA.d.ts} +7 -8
- package/dist/vite/index.cjs +177 -145
- package/dist/vite/index.d.cts +1 -0
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/index.js +15 -20
- package/dist/{watcher-4NDMOH4R.js → watcher-HGOH3APP.js} +1 -1
- package/package.json +23 -15
- package/dist/chunk-KTDVTBMH.js +0 -139
- package/dist/postinstall-U7VROOY7.js +0 -9
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
remarkInclude
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LMG6UWCL.js";
|
|
4
4
|
|
|
5
|
-
// src/mdx/build-mdx.ts
|
|
5
|
+
// src/loaders/mdx/build-mdx.ts
|
|
6
6
|
import { createProcessor } from "@mdx-js/mdx";
|
|
7
7
|
|
|
8
|
-
// src/mdx/remark-postprocess.ts
|
|
8
|
+
// src/loaders/mdx/remark-postprocess.ts
|
|
9
9
|
import { visit } from "unist-util-visit";
|
|
10
10
|
import { toMarkdown } from "mdast-util-to-markdown";
|
|
11
11
|
import { valueToEstree } from "estree-util-value-to-estree";
|
|
@@ -34,7 +34,7 @@ function remarkPostprocess({
|
|
|
34
34
|
if (includeProcessedMarkdown) {
|
|
35
35
|
file.data._markdown = toMarkdown(tree, {
|
|
36
36
|
...this.data("settings"),
|
|
37
|
-
//
|
|
37
|
+
// from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js
|
|
38
38
|
extensions: this.data("toMarkdownExtensions") || []
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -88,7 +88,7 @@ function flattenNode(node) {
|
|
|
88
88
|
return "";
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
// src/mdx/build-mdx.ts
|
|
91
|
+
// src/loaders/mdx/build-mdx.ts
|
|
92
92
|
var cache = /* @__PURE__ */ new Map();
|
|
93
93
|
async function buildMDX(cacheKey, source, options) {
|
|
94
94
|
const { filePath, frontmatter, data, _compiler, ...rest } = options;
|
|
@@ -124,7 +124,7 @@ async function buildMDX(cacheKey, source, options) {
|
|
|
124
124
|
return processor;
|
|
125
125
|
}
|
|
126
126
|
return getProcessor(
|
|
127
|
-
options.format ?? filePath.endsWith(".mdx") ? "mdx" : "md"
|
|
127
|
+
options.format ?? (filePath.endsWith(".mdx") ? "mdx" : "md")
|
|
128
128
|
).process({
|
|
129
129
|
value: source,
|
|
130
130
|
path: filePath,
|
|
@@ -1,28 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildMDX
|
|
3
|
+
} from "./chunk-QAUWMR5D.js";
|
|
1
4
|
import {
|
|
2
5
|
getGitTimestamp,
|
|
3
6
|
validate
|
|
4
7
|
} from "./chunk-IQAEAI4P.js";
|
|
5
|
-
import {
|
|
6
|
-
getConfigHash,
|
|
7
|
-
loadConfig
|
|
8
|
-
} from "./chunk-POXTQZ4D.js";
|
|
9
|
-
import {
|
|
10
|
-
buildMDX
|
|
11
|
-
} from "./chunk-SWNOXPYJ.js";
|
|
12
8
|
import {
|
|
13
9
|
fumaMatter
|
|
14
10
|
} from "./chunk-VWJKRQZR.js";
|
|
15
11
|
|
|
16
|
-
// src/
|
|
17
|
-
function countLines(s) {
|
|
18
|
-
let num = 0;
|
|
19
|
-
for (const c of s) {
|
|
20
|
-
if (c === "\n") num++;
|
|
21
|
-
}
|
|
22
|
-
return num;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// src/loaders/mdx.ts
|
|
12
|
+
// src/loaders/mdx/index.ts
|
|
26
13
|
import { z } from "zod";
|
|
27
14
|
import fs from "fs/promises";
|
|
28
15
|
import path from "path";
|
|
@@ -121,29 +108,14 @@ function createMdxLoader(configLoader) {
|
|
|
121
108
|
function generateCacheHash(input) {
|
|
122
109
|
return createHash("md5").update(input).digest("hex");
|
|
123
110
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function dynamicConfig(configPath, outDir) {
|
|
134
|
-
return {
|
|
135
|
-
async getConfig(hash) {
|
|
136
|
-
return loadConfig(
|
|
137
|
-
configPath,
|
|
138
|
-
outDir,
|
|
139
|
-
hash ?? await getConfigHash(configPath)
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
111
|
+
function countLines(s) {
|
|
112
|
+
let num = 0;
|
|
113
|
+
for (const c of s) {
|
|
114
|
+
if (c === "\n") num++;
|
|
115
|
+
}
|
|
116
|
+
return num;
|
|
143
117
|
}
|
|
144
118
|
|
|
145
119
|
export {
|
|
146
|
-
createMdxLoader
|
|
147
|
-
resolvedConfig,
|
|
148
|
-
dynamicConfig
|
|
120
|
+
createMdxLoader
|
|
149
121
|
};
|
|
@@ -34,7 +34,7 @@ function buildConfig(config) {
|
|
|
34
34
|
const input = this.global.mdxOptions;
|
|
35
35
|
async function uncached() {
|
|
36
36
|
const options = typeof input === "function" ? await input() : input;
|
|
37
|
-
const { getDefaultMDXOptions } = await import("./preset-
|
|
37
|
+
const { getDefaultMDXOptions } = await import("./preset-ZMP6U62C.js");
|
|
38
38
|
if (options?.preset === "minimal") return options;
|
|
39
39
|
return getDefaultMDXOptions({
|
|
40
40
|
...options,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/loaders/config/index.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
function findConfigFile() {
|
|
4
|
+
return path.resolve("source.config.ts");
|
|
5
|
+
}
|
|
6
|
+
function resolvedConfig(loaded) {
|
|
7
|
+
return {
|
|
8
|
+
getConfig() {
|
|
9
|
+
return loaded;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function dynamicConfig(configPath, outDir) {
|
|
14
|
+
return {
|
|
15
|
+
async getConfig(hash) {
|
|
16
|
+
const { loadConfig, getConfigHash } = await import("./load-UUXLUBHL.js");
|
|
17
|
+
return loadConfig(
|
|
18
|
+
configPath,
|
|
19
|
+
outDir,
|
|
20
|
+
hash ?? await getConfigHash(configPath)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
findConfigFile,
|
|
28
|
+
resolvedConfig,
|
|
29
|
+
dynamicConfig
|
|
30
|
+
};
|
|
@@ -4,9 +4,11 @@ import {
|
|
|
4
4
|
toImportPath
|
|
5
5
|
} from "./chunk-6Y5JDZHD.js";
|
|
6
6
|
import {
|
|
7
|
-
findConfigFile,
|
|
8
7
|
loadConfig
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LGYVNESJ.js";
|
|
9
|
+
import {
|
|
10
|
+
findConfigFile
|
|
11
|
+
} from "./chunk-XMFLD5J6.js";
|
|
10
12
|
|
|
11
13
|
// src/vite/postinstall.ts
|
|
12
14
|
import fs from "fs/promises";
|
package/dist/config/index.cjs
CHANGED
|
@@ -86,7 +86,7 @@ function defineConfig(config = {}) {
|
|
|
86
86
|
return config;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
// src/mdx/preset.ts
|
|
89
|
+
// src/loaders/mdx/preset.ts
|
|
90
90
|
var plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
91
91
|
function pluginOption(def, options = []) {
|
|
92
92
|
const list = def(Array.isArray(options) ? options : []).filter(
|
|
@@ -163,7 +163,7 @@ function getDefaultMDXOptions({
|
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
// src/mdx/remark-include.ts
|
|
166
|
+
// src/loaders/mdx/remark-include.ts
|
|
167
167
|
var import_unified = require("unified");
|
|
168
168
|
var import_unist_util_visit = require("unist-util-visit");
|
|
169
169
|
var path = __toESM(require("path"), 1);
|
|
@@ -185,11 +185,32 @@ function fumaMatter(input) {
|
|
|
185
185
|
return output;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
// src/mdx/remark-include.ts
|
|
188
|
+
// src/loaders/mdx/remark-include.ts
|
|
189
189
|
var import_remark_parse = __toESM(require("remark-parse"), 1);
|
|
190
190
|
var import_remark_mdx = __toESM(require("remark-mdx"), 1);
|
|
191
191
|
var import_mdx_plugins = require("fumadocs-core/mdx-plugins");
|
|
192
|
-
var
|
|
192
|
+
var ElementLikeTypes = [
|
|
193
|
+
"mdxJsxFlowElement",
|
|
194
|
+
"mdxJsxTextElement",
|
|
195
|
+
"containerDirective",
|
|
196
|
+
"textDirective",
|
|
197
|
+
"leafDirective"
|
|
198
|
+
];
|
|
199
|
+
function isElementLike(node) {
|
|
200
|
+
return ElementLikeTypes.includes(node.type);
|
|
201
|
+
}
|
|
202
|
+
function parseElementAttributes(element) {
|
|
203
|
+
if (Array.isArray(element.attributes)) {
|
|
204
|
+
const attributes = {};
|
|
205
|
+
for (const attr of element.attributes) {
|
|
206
|
+
if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
|
|
207
|
+
attributes[attr.name] = attr.value;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return attributes;
|
|
211
|
+
}
|
|
212
|
+
return element.attributes ?? {};
|
|
213
|
+
}
|
|
193
214
|
function flattenNode(node) {
|
|
194
215
|
if ("children" in node)
|
|
195
216
|
return node.children.map((child) => flattenNode(child)).join("");
|
|
@@ -206,21 +227,31 @@ function parseSpecifier(specifier) {
|
|
|
206
227
|
}
|
|
207
228
|
function extractSection(root, section) {
|
|
208
229
|
let nodes;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
230
|
+
let capturingHeadingContent = false;
|
|
231
|
+
(0, import_unist_util_visit.visit)(root, (node) => {
|
|
232
|
+
if (node.type === "heading") {
|
|
233
|
+
if (capturingHeadingContent) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
if (node.data?.hProperties?.id === section) {
|
|
237
|
+
capturingHeadingContent = true;
|
|
238
|
+
nodes = [node];
|
|
239
|
+
return "skip";
|
|
240
|
+
}
|
|
241
|
+
return;
|
|
215
242
|
}
|
|
216
|
-
if (
|
|
217
|
-
nodes
|
|
218
|
-
|
|
243
|
+
if (capturingHeadingContent) {
|
|
244
|
+
nodes?.push(node);
|
|
245
|
+
return "skip";
|
|
219
246
|
}
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
247
|
+
if (isElementLike(node) && node.name === "section") {
|
|
248
|
+
const attributes = parseElementAttributes(node);
|
|
249
|
+
if (attributes.id === section) {
|
|
250
|
+
nodes = node.children;
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
224
255
|
if (nodes)
|
|
225
256
|
return {
|
|
226
257
|
type: "root",
|
|
@@ -252,55 +283,52 @@ ${e instanceof Error ? e.message : String(e)}`,
|
|
|
252
283
|
data: {}
|
|
253
284
|
};
|
|
254
285
|
}
|
|
255
|
-
const
|
|
286
|
+
const parser = (data._getProcessor ?? getDefaultProcessor)(
|
|
256
287
|
ext === ".mdx" ? "mdx" : "md"
|
|
257
288
|
);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
289
|
+
const parsed = fumaMatter(content);
|
|
290
|
+
let mdast = parser.parse({
|
|
291
|
+
path: file,
|
|
292
|
+
value: parsed.content,
|
|
293
|
+
data: { frontmatter: parsed.data }
|
|
294
|
+
});
|
|
261
295
|
if (heading) {
|
|
262
|
-
const extracted = extractSection(
|
|
296
|
+
const extracted = extractSection(
|
|
297
|
+
await (0, import_unified.unified)().use(import_mdx_plugins.remarkHeading).run(mdast),
|
|
298
|
+
heading
|
|
299
|
+
);
|
|
263
300
|
if (!extracted)
|
|
264
301
|
throw new Error(
|
|
265
|
-
`Cannot find section ${heading} in ${file}, make sure you have encapsulated the section in a <section id="${heading}"> tag.`
|
|
302
|
+
`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.`
|
|
266
303
|
);
|
|
267
|
-
|
|
304
|
+
mdast = extracted;
|
|
268
305
|
}
|
|
269
|
-
await update(
|
|
270
|
-
return
|
|
306
|
+
await update(mdast, path.dirname(file), data);
|
|
307
|
+
return mdast;
|
|
271
308
|
}
|
|
272
309
|
async function update(tree, directory, data) {
|
|
273
310
|
const queue = [];
|
|
274
|
-
(0, import_unist_util_visit.visit)(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
Object.assign(
|
|
296
|
-
parent && parent.type === "paragraph" ? parent : node,
|
|
297
|
-
replace
|
|
298
|
-
);
|
|
299
|
-
})
|
|
300
|
-
);
|
|
301
|
-
return "skip";
|
|
302
|
-
}
|
|
303
|
-
);
|
|
311
|
+
(0, import_unist_util_visit.visit)(tree, ElementLikeTypes, (_node, _, parent) => {
|
|
312
|
+
const node = _node;
|
|
313
|
+
if (node.name !== TagName) return;
|
|
314
|
+
const specifier = flattenNode(node);
|
|
315
|
+
if (specifier.length === 0) return "skip";
|
|
316
|
+
const attributes = parseElementAttributes(node);
|
|
317
|
+
const { file: relativePath, section } = parseSpecifier(specifier);
|
|
318
|
+
const file = path.resolve(
|
|
319
|
+
"cwd" in attributes ? process.cwd() : directory,
|
|
320
|
+
relativePath
|
|
321
|
+
);
|
|
322
|
+
queue.push(
|
|
323
|
+
embedContent(file, section, attributes, data).then((replace) => {
|
|
324
|
+
Object.assign(
|
|
325
|
+
parent && parent.type === "paragraph" ? parent : node,
|
|
326
|
+
replace
|
|
327
|
+
);
|
|
328
|
+
})
|
|
329
|
+
);
|
|
330
|
+
return "skip";
|
|
331
|
+
});
|
|
304
332
|
await Promise.all(queue);
|
|
305
333
|
}
|
|
306
334
|
return async (tree, file) => {
|
package/dist/config/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AnyCollection, B as BaseCollection, C as CollectionSchema, D as DefaultMDXOptions, a as DocCollection, b as DocsCollection, G as GlobalConfig, M as MetaCollection, d as defineCollections, e as defineConfig, c as defineDocs, f as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../define
|
|
1
|
+
export { A as AnyCollection, B as BaseCollection, C as CollectionSchema, D as DefaultMDXOptions, a as DocCollection, b as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, e as defineConfig, c as defineDocs, f as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../define-DJbJduHy.cjs';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
4
|
import '@standard-schema/spec';
|
|
@@ -6,10 +6,6 @@ import 'fumadocs-core/mdx-plugins';
|
|
|
6
6
|
import '@mdx-js/mdx';
|
|
7
7
|
import 'zod';
|
|
8
8
|
|
|
9
|
-
interface Params {
|
|
10
|
-
lang?: string;
|
|
11
|
-
meta?: string;
|
|
12
|
-
}
|
|
13
9
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
14
10
|
|
|
15
|
-
export {
|
|
11
|
+
export { remarkInclude };
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AnyCollection, B as BaseCollection, C as CollectionSchema, D as DefaultMDXOptions, a as DocCollection, b as DocsCollection, G as GlobalConfig, M as MetaCollection, d as defineCollections, e as defineConfig, c as defineDocs, f as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../define
|
|
1
|
+
export { A as AnyCollection, B as BaseCollection, C as CollectionSchema, D as DefaultMDXOptions, a as DocCollection, b as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, e as defineConfig, c as defineDocs, f as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../define-DJbJduHy.js';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
4
|
import '@standard-schema/spec';
|
|
@@ -6,10 +6,6 @@ import 'fumadocs-core/mdx-plugins';
|
|
|
6
6
|
import '@mdx-js/mdx';
|
|
7
7
|
import 'zod';
|
|
8
8
|
|
|
9
|
-
interface Params {
|
|
10
|
-
lang?: string;
|
|
11
|
-
meta?: string;
|
|
12
|
-
}
|
|
13
9
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
14
10
|
|
|
15
|
-
export {
|
|
11
|
+
export { remarkInclude };
|
package/dist/config/index.js
CHANGED
|
@@ -4,6 +4,20 @@ import { ProcessorOptions } from '@mdx-js/mdx';
|
|
|
4
4
|
import { Pluggable } from 'unified';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
|
+
interface ExtractedReference {
|
|
8
|
+
href: string;
|
|
9
|
+
}
|
|
10
|
+
interface PostprocessOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Properties to export from `vfile.data`
|
|
13
|
+
*/
|
|
14
|
+
valueToExport?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* stringify MDAST and export via `_markdown`.
|
|
17
|
+
*/
|
|
18
|
+
includeProcessedMarkdown?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
7
21
|
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
8
22
|
type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
|
|
9
23
|
rehypePlugins?: ResolvePlugins;
|
|
@@ -38,20 +52,6 @@ declare const frontmatterSchema: z.ZodObject<{
|
|
|
38
52
|
_openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
39
53
|
}, z.core.$strip>;
|
|
40
54
|
|
|
41
|
-
interface ExtractedReference {
|
|
42
|
-
href: string;
|
|
43
|
-
}
|
|
44
|
-
interface PostprocessOptions {
|
|
45
|
-
/**
|
|
46
|
-
* Properties to export from `vfile.data`
|
|
47
|
-
*/
|
|
48
|
-
valueToExport?: string[];
|
|
49
|
-
/**
|
|
50
|
-
* stringify MDAST and export via `_markdown`.
|
|
51
|
-
*/
|
|
52
|
-
includeProcessedMarkdown?: boolean;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
55
|
type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
|
|
56
56
|
type AnyCollection = DocsCollection | DocCollection | MetaCollection;
|
|
57
57
|
interface BaseCollection {
|
|
@@ -128,4 +128,4 @@ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmat
|
|
|
128
128
|
}): DocsCollection<DocSchema, MetaSchema, Async>;
|
|
129
129
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
130
130
|
|
|
131
|
-
export { type AnyCollection as A, type BaseCollection as B, type CollectionSchema as C, type DefaultMDXOptions as D, type ExtractedReference as E, type GlobalConfig as G, type MetaCollection as M, type DocCollection as a, type DocsCollection as b, defineDocs as c, defineCollections as d, defineConfig as e, frontmatterSchema as f, getDefaultMDXOptions as g, metaSchema as m };
|
|
131
|
+
export { type AnyCollection as A, type BaseCollection as B, type CollectionSchema as C, type DefaultMDXOptions as D, type ExtractedReference as E, type GlobalConfig as G, type MetaCollection as M, type PostprocessOptions as P, type DocCollection as a, type DocsCollection as b, defineDocs as c, defineCollections as d, defineConfig as e, frontmatterSchema as f, getDefaultMDXOptions as g, metaSchema as m };
|
|
@@ -4,6 +4,20 @@ import { ProcessorOptions } from '@mdx-js/mdx';
|
|
|
4
4
|
import { Pluggable } from 'unified';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
|
+
interface ExtractedReference {
|
|
8
|
+
href: string;
|
|
9
|
+
}
|
|
10
|
+
interface PostprocessOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Properties to export from `vfile.data`
|
|
13
|
+
*/
|
|
14
|
+
valueToExport?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* stringify MDAST and export via `_markdown`.
|
|
17
|
+
*/
|
|
18
|
+
includeProcessedMarkdown?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
7
21
|
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
8
22
|
type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
|
|
9
23
|
rehypePlugins?: ResolvePlugins;
|
|
@@ -38,20 +52,6 @@ declare const frontmatterSchema: z.ZodObject<{
|
|
|
38
52
|
_openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
39
53
|
}, z.core.$strip>;
|
|
40
54
|
|
|
41
|
-
interface ExtractedReference {
|
|
42
|
-
href: string;
|
|
43
|
-
}
|
|
44
|
-
interface PostprocessOptions {
|
|
45
|
-
/**
|
|
46
|
-
* Properties to export from `vfile.data`
|
|
47
|
-
*/
|
|
48
|
-
valueToExport?: string[];
|
|
49
|
-
/**
|
|
50
|
-
* stringify MDAST and export via `_markdown`.
|
|
51
|
-
*/
|
|
52
|
-
includeProcessedMarkdown?: boolean;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
55
|
type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
|
|
56
56
|
type AnyCollection = DocsCollection | DocCollection | MetaCollection;
|
|
57
57
|
interface BaseCollection {
|
|
@@ -128,4 +128,4 @@ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmat
|
|
|
128
128
|
}): DocsCollection<DocSchema, MetaSchema, Async>;
|
|
129
129
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
130
130
|
|
|
131
|
-
export { type AnyCollection as A, type BaseCollection as B, type CollectionSchema as C, type DefaultMDXOptions as D, type ExtractedReference as E, type GlobalConfig as G, type MetaCollection as M, type DocCollection as a, type DocsCollection as b, defineDocs as c, defineCollections as d, defineConfig as e, frontmatterSchema as f, getDefaultMDXOptions as g, metaSchema as m };
|
|
131
|
+
export { type AnyCollection as A, type BaseCollection as B, type CollectionSchema as C, type DefaultMDXOptions as D, type ExtractedReference as E, type GlobalConfig as G, type MetaCollection as M, type PostprocessOptions as P, type DocCollection as a, type DocsCollection as b, defineDocs as c, defineCollections as d, defineConfig as e, frontmatterSchema as f, getDefaultMDXOptions as g, metaSchema as m };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
_runtime: () => _runtime,
|
|
34
|
+
createMDXSource: () => createMDXSource,
|
|
35
|
+
resolveFiles: () => resolveFiles
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
|
|
39
|
+
// src/runtime/next/index.ts
|
|
40
|
+
var fs = __toESM(require("fs/promises"), 1);
|
|
41
|
+
|
|
42
|
+
// src/runtime/shared.ts
|
|
43
|
+
function missingProcessedMarkdown() {
|
|
44
|
+
throw new Error(
|
|
45
|
+
"getText('processed') requires `includeProcessedMarkdown` to be enabled in your collection config."
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/runtime/next/index.ts
|
|
50
|
+
var _runtime = {
|
|
51
|
+
doc(files) {
|
|
52
|
+
return files.map((file) => {
|
|
53
|
+
const data = file.data;
|
|
54
|
+
const filePath = file.info.fullPath;
|
|
55
|
+
return {
|
|
56
|
+
info: file.info,
|
|
57
|
+
_exports: data,
|
|
58
|
+
body: data.default,
|
|
59
|
+
lastModified: data.lastModified,
|
|
60
|
+
toc: data.toc,
|
|
61
|
+
structuredData: data.structuredData,
|
|
62
|
+
extractedReferences: data.extractedReferences,
|
|
63
|
+
...data.frontmatter,
|
|
64
|
+
async getText(type) {
|
|
65
|
+
if (type === "raw") {
|
|
66
|
+
return (await fs.readFile(filePath)).toString();
|
|
67
|
+
}
|
|
68
|
+
if (typeof data._markdown !== "string") missingProcessedMarkdown();
|
|
69
|
+
return data._markdown;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
meta(files) {
|
|
75
|
+
return files.map((file) => {
|
|
76
|
+
return {
|
|
77
|
+
info: file.info,
|
|
78
|
+
...file.data
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
docs(docs, metas) {
|
|
83
|
+
const parsedDocs = this.doc(docs);
|
|
84
|
+
const parsedMetas = this.meta(metas);
|
|
85
|
+
return {
|
|
86
|
+
docs: parsedDocs,
|
|
87
|
+
meta: parsedMetas,
|
|
88
|
+
toFumadocsSource() {
|
|
89
|
+
return createMDXSource(parsedDocs, parsedMetas);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
function createMDXSource(docs, meta = []) {
|
|
95
|
+
return {
|
|
96
|
+
files: () => resolveFiles({
|
|
97
|
+
docs,
|
|
98
|
+
meta
|
|
99
|
+
})
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function resolveFiles({ docs, meta }) {
|
|
103
|
+
const outputs = [];
|
|
104
|
+
for (const entry of docs) {
|
|
105
|
+
outputs.push({
|
|
106
|
+
type: "page",
|
|
107
|
+
absolutePath: entry.info.fullPath,
|
|
108
|
+
path: entry.info.path,
|
|
109
|
+
data: entry
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
for (const entry of meta) {
|
|
113
|
+
outputs.push({
|
|
114
|
+
type: "meta",
|
|
115
|
+
absolutePath: entry.info.fullPath,
|
|
116
|
+
path: entry.info.path,
|
|
117
|
+
data: entry
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return outputs;
|
|
121
|
+
}
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
_runtime,
|
|
125
|
+
createMDXSource,
|
|
126
|
+
resolveFiles
|
|
127
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { A as AsyncDocCollectionEntry, D as DocCollectionEntry, a as DocData, b as DocMethods, F as FileInfo, M as MetaCollectionEntry, O as Override, m as missingProcessedMarkdown } from './shared-Cnm1afPW.cjs';
|
|
2
|
+
export { AnyCollectionEntry, _runtime, createMDXSource, resolveFiles } from './runtime/next/index.cjs';
|
|
3
|
+
export { E as ExtractedReference } from './define-DJbJduHy.cjs';
|
|
4
|
+
export { c as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, a as Runtime, R as RuntimeAsync, b as RuntimeFile } from './types-CbLt05Gc.cjs';
|
|
5
|
+
import 'fumadocs-core/mdx-plugins';
|
|
6
|
+
import 'fumadocs-core/server';
|
|
7
|
+
import 'react';
|
|
8
|
+
import 'mdx/types';
|
|
9
|
+
import 'fumadocs-core/source';
|
|
10
|
+
import '@standard-schema/spec';
|
|
11
|
+
import '@mdx-js/mdx';
|
|
12
|
+
import 'unified';
|
|
13
|
+
import 'zod';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { A as AsyncDocCollectionEntry, D as DocCollectionEntry, a as DocData, b as DocMethods, F as FileInfo, M as MetaCollectionEntry, O as Override, m as missingProcessedMarkdown } from './shared-DpXxElc1.js';
|
|
2
|
+
export { AnyCollectionEntry, _runtime, createMDXSource, resolveFiles } from './runtime/next/index.js';
|
|
3
|
+
export { E as ExtractedReference } from './define-DJbJduHy.js';
|
|
4
|
+
export { c as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, a as Runtime, R as RuntimeAsync, b as RuntimeFile } from './types-Ci6BA1tA.js';
|
|
5
|
+
import 'fumadocs-core/mdx-plugins';
|
|
6
|
+
import 'fumadocs-core/server';
|
|
7
|
+
import 'react';
|
|
8
|
+
import 'mdx/types';
|
|
9
|
+
import 'fumadocs-core/source';
|
|
10
|
+
import '@standard-schema/spec';
|
|
11
|
+
import '@mdx-js/mdx';
|
|
12
|
+
import 'unified';
|
|
13
|
+
import 'zod';
|