fumadocs-mdx 13.0.8 → 14.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 +985 -893
- package/dist/bin.js +3 -3
- package/dist/build-mdx-6UAK5FF5.js +8 -0
- package/dist/bun/index.cjs +613 -471
- package/dist/bun/index.d.cts +9 -2
- package/dist/bun/index.d.ts +9 -2
- package/dist/bun/index.js +15 -14
- package/dist/chunk-4JSFLXXT.js +8 -0
- package/dist/chunk-5OBUOALK.js +141 -0
- package/dist/{chunk-2E2JCOSO.js → chunk-6NISOLQ6.js} +16 -44
- package/dist/chunk-7UKSZSPY.js +331 -0
- package/dist/chunk-BEBCWQC7.js +224 -0
- package/dist/chunk-E5DJTSIM.js +86 -0
- package/dist/{chunk-K5ZLPEIQ.js → chunk-FBLMK4RS.js} +9 -6
- package/dist/chunk-IQGEFL2B.js +17 -0
- package/dist/{chunk-5FTSWCB4.js → chunk-K6HCOGOX.js} +9 -11
- package/dist/{chunk-QXHN25N3.js → chunk-MTTISKQJ.js} +6 -6
- package/dist/{chunk-3J3WL7WN.js → chunk-SLY7WXTX.js} +71 -58
- package/dist/chunk-TYJDYTKH.js +85 -0
- package/dist/chunk-WBIHDYMN.js +126 -0
- package/dist/{chunk-2HXTGJBI.js → chunk-ZY6UZ7NH.js} +22 -19
- package/dist/config/index.cjs +79 -71
- package/dist/config/index.d.cts +7 -1
- package/dist/config/index.d.ts +7 -1
- package/dist/config/index.js +5 -5
- package/dist/core-B9ZoS6sA.d.ts +341 -0
- package/dist/core-DTuP23zu.d.cts +341 -0
- package/dist/index-BD8Woo4m.d.cts +8 -0
- package/dist/index-CNOvhtOn.d.ts +8 -0
- package/dist/index.d.cts +38 -56
- package/dist/index.d.ts +38 -56
- package/dist/load-from-file-5HUQN36V.js +8 -0
- package/dist/next/index.cjs +763 -473
- package/dist/next/index.d.cts +16 -1
- package/dist/next/index.d.ts +16 -1
- package/dist/next/index.js +80 -281
- package/dist/node/loader.cjs +764 -627
- package/dist/node/loader.js +10 -11
- package/dist/plugins/index-file.cjs +495 -0
- package/dist/plugins/index-file.d.cts +14 -0
- package/dist/plugins/index-file.d.ts +14 -0
- package/dist/plugins/index-file.js +8 -0
- package/dist/plugins/json-schema.d.cts +9 -2
- package/dist/plugins/json-schema.d.ts +9 -2
- package/dist/plugins/last-modified.cjs +110 -0
- package/dist/plugins/last-modified.d.cts +37 -0
- package/dist/plugins/last-modified.d.ts +37 -0
- package/dist/plugins/last-modified.js +74 -0
- package/dist/runtime/browser.cjs +93 -0
- package/dist/runtime/browser.d.cts +53 -0
- package/dist/runtime/browser.d.ts +53 -0
- package/dist/runtime/browser.js +67 -0
- package/dist/runtime/dynamic.cjs +1023 -0
- package/dist/runtime/dynamic.d.cts +27 -0
- package/dist/runtime/dynamic.d.ts +27 -0
- package/dist/runtime/dynamic.js +79 -0
- package/dist/runtime/server.cjs +176 -0
- package/dist/runtime/server.d.cts +14 -0
- package/dist/runtime/server.d.ts +14 -0
- package/dist/runtime/server.js +8 -0
- package/dist/runtime/types.cjs +18 -0
- package/dist/runtime/types.d.cts +61 -0
- package/dist/runtime/types.d.ts +61 -0
- package/dist/runtime/types.js +0 -0
- package/dist/vite/index.cjs +984 -621
- package/dist/vite/index.d.cts +17 -22
- package/dist/vite/index.d.ts +17 -22
- package/dist/vite/index.js +32 -222
- package/dist/webpack/mdx.cjs +647 -514
- package/dist/webpack/mdx.d.cts +15 -1
- package/dist/webpack/mdx.d.ts +15 -1
- package/dist/webpack/mdx.js +12 -17
- package/dist/webpack/meta.cjs +360 -231
- package/dist/webpack/meta.d.cts +15 -1
- package/dist/webpack/meta.d.ts +15 -1
- package/dist/webpack/meta.js +13 -15
- package/package.json +15 -32
- package/dist/build-mdx-BjXOmv0b.d.cts +0 -53
- package/dist/build-mdx-CY5UldCO.d.ts +0 -53
- package/dist/chunk-2AQRQXSO.js +0 -119
- package/dist/chunk-CXA4JO4Z.js +0 -45
- package/dist/chunk-DMJ6I4C3.js +0 -76
- package/dist/chunk-FSZMKRVH.js +0 -80
- package/dist/chunk-II3H5ZVZ.js +0 -77
- package/dist/chunk-KILFIBVW.js +0 -75
- package/dist/chunk-NVRDCY6Z.js +0 -30
- package/dist/chunk-VUEZTR2H.js +0 -26
- package/dist/core-DB7TdlyC.d.cts +0 -234
- package/dist/core-DB7TdlyC.d.ts +0 -234
- package/dist/index-D7s7kCc2.d.cts +0 -7
- package/dist/index-D7s7kCc2.d.ts +0 -7
- package/dist/load-from-file-AVYOFOI7.js +0 -7
- package/dist/preset-ZMP6U62C.js +0 -6
- package/dist/runtime/next/async.cjs +0 -760
- package/dist/runtime/next/async.d.cts +0 -19
- package/dist/runtime/next/async.d.ts +0 -19
- package/dist/runtime/next/async.js +0 -86
- package/dist/runtime/next/index.cjs +0 -136
- package/dist/runtime/next/index.d.cts +0 -33
- package/dist/runtime/next/index.d.ts +0 -33
- package/dist/runtime/next/index.js +0 -11
- package/dist/runtime/vite/browser.cjs +0 -107
- package/dist/runtime/vite/browser.d.cts +0 -59
- package/dist/runtime/vite/browser.d.ts +0 -59
- package/dist/runtime/vite/browser.js +0 -11
- package/dist/runtime/vite/server.cjs +0 -243
- package/dist/runtime/vite/server.d.cts +0 -30
- package/dist/runtime/vite/server.d.ts +0 -30
- package/dist/runtime/vite/server.js +0 -111
- package/dist/types-Bnh9n7mj.d.cts +0 -45
- package/dist/types-ey1AZqrg.d.ts +0 -45
package/dist/node/loader.js
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMdxLoader
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-6NISOLQ6.js";
|
|
4
4
|
import {
|
|
5
5
|
createMetaLoader
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-TYJDYTKH.js";
|
|
7
7
|
import {
|
|
8
8
|
createStandaloneConfigLoader,
|
|
9
9
|
toNode
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-K5ZLPEIQ.js";
|
|
13
|
-
import "../chunk-VUEZTR2H.js";
|
|
10
|
+
} from "../chunk-K6HCOGOX.js";
|
|
11
|
+
import "../chunk-4JSFLXXT.js";
|
|
14
12
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "../chunk-
|
|
13
|
+
_Defaults,
|
|
14
|
+
createCore
|
|
15
|
+
} from "../chunk-BEBCWQC7.js";
|
|
16
|
+
import "../chunk-WBIHDYMN.js";
|
|
18
17
|
import "../chunk-VWJKRQZR.js";
|
|
19
18
|
|
|
20
19
|
// src/node/loader.ts
|
|
21
20
|
var core = createCore({
|
|
22
21
|
environment: "node",
|
|
23
|
-
configPath:
|
|
24
|
-
outDir:
|
|
22
|
+
configPath: _Defaults.configPath,
|
|
23
|
+
outDir: _Defaults.outDir
|
|
25
24
|
});
|
|
26
25
|
var configLoader = createStandaloneConfigLoader({
|
|
27
26
|
core,
|
|
@@ -0,0 +1,495 @@
|
|
|
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/plugins/index-file.ts
|
|
31
|
+
var index_file_exports = {};
|
|
32
|
+
__export(index_file_exports, {
|
|
33
|
+
default: () => indexFile
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_file_exports);
|
|
36
|
+
var import_path = __toESM(require("path"), 1);
|
|
37
|
+
|
|
38
|
+
// src/utils/codegen.ts
|
|
39
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
40
|
+
var import_tinyglobby = require("tinyglobby");
|
|
41
|
+
function createCodegen({
|
|
42
|
+
target = "default",
|
|
43
|
+
outDir = "",
|
|
44
|
+
jsExtension = false,
|
|
45
|
+
globCache = /* @__PURE__ */ new Map()
|
|
46
|
+
}) {
|
|
47
|
+
let eagerImportId = 0;
|
|
48
|
+
const banner = ["// @ts-nocheck"];
|
|
49
|
+
if (target === "vite") {
|
|
50
|
+
banner.push('/// <reference types="vite/client" />');
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
options: {
|
|
54
|
+
target,
|
|
55
|
+
outDir
|
|
56
|
+
},
|
|
57
|
+
lines: [],
|
|
58
|
+
addImport(statement) {
|
|
59
|
+
this.lines.unshift(statement);
|
|
60
|
+
},
|
|
61
|
+
async pushAsync(insert) {
|
|
62
|
+
for (const line of await Promise.all(insert)) {
|
|
63
|
+
if (line === void 0) continue;
|
|
64
|
+
this.lines.push(line);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
async generateGlobImport(patterns, options) {
|
|
68
|
+
if (target === "vite") {
|
|
69
|
+
return this.generateViteGlobImport(patterns, options);
|
|
70
|
+
}
|
|
71
|
+
return this.generateNodeGlobImport(patterns, options);
|
|
72
|
+
},
|
|
73
|
+
generateViteGlobImport(patterns, { base, ...rest }) {
|
|
74
|
+
patterns = (typeof patterns === "string" ? [patterns] : patterns).map(
|
|
75
|
+
normalizeViteGlobPath
|
|
76
|
+
);
|
|
77
|
+
return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(
|
|
78
|
+
{
|
|
79
|
+
base: normalizeViteGlobPath(import_node_path.default.relative(outDir, base)),
|
|
80
|
+
...rest
|
|
81
|
+
},
|
|
82
|
+
null,
|
|
83
|
+
2
|
|
84
|
+
)})`;
|
|
85
|
+
},
|
|
86
|
+
async generateNodeGlobImport(patterns, {
|
|
87
|
+
base,
|
|
88
|
+
eager = false,
|
|
89
|
+
query = {},
|
|
90
|
+
import: importName
|
|
91
|
+
}) {
|
|
92
|
+
const cacheKey = JSON.stringify({ patterns, base });
|
|
93
|
+
let files = globCache.get(cacheKey);
|
|
94
|
+
if (!files) {
|
|
95
|
+
files = (0, import_tinyglobby.glob)(patterns, {
|
|
96
|
+
cwd: base
|
|
97
|
+
});
|
|
98
|
+
globCache.set(cacheKey, files);
|
|
99
|
+
}
|
|
100
|
+
let code = "{";
|
|
101
|
+
for (const item of await files) {
|
|
102
|
+
const fullPath = import_node_path.default.join(base, item);
|
|
103
|
+
const searchParams = new URLSearchParams();
|
|
104
|
+
for (const [k, v] of Object.entries(query)) {
|
|
105
|
+
searchParams.set(k, v);
|
|
106
|
+
}
|
|
107
|
+
const importPath = this.formatImportPath(fullPath) + "?" + searchParams.toString();
|
|
108
|
+
if (eager) {
|
|
109
|
+
const name = `__fd_glob_${eagerImportId++}`;
|
|
110
|
+
this.lines.unshift(
|
|
111
|
+
importName ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}` : `import * as ${name} from ${JSON.stringify(importPath)}`
|
|
112
|
+
);
|
|
113
|
+
code += `${JSON.stringify(item)}: ${name}, `;
|
|
114
|
+
} else {
|
|
115
|
+
let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;
|
|
116
|
+
if (importName) {
|
|
117
|
+
line += `.then(mod => mod.${importName})`;
|
|
118
|
+
}
|
|
119
|
+
code += `${line}, `;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
code += "}";
|
|
123
|
+
return code;
|
|
124
|
+
},
|
|
125
|
+
formatImportPath(file) {
|
|
126
|
+
const ext = import_node_path.default.extname(file);
|
|
127
|
+
let filename;
|
|
128
|
+
if (ext === ".ts" && jsExtension) {
|
|
129
|
+
filename = file.substring(0, file.length - ext.length) + ".js";
|
|
130
|
+
} else if (ext === ".ts") {
|
|
131
|
+
filename = file.substring(0, file.length - ext.length);
|
|
132
|
+
} else {
|
|
133
|
+
filename = file;
|
|
134
|
+
}
|
|
135
|
+
const importPath = slash(import_node_path.default.relative(outDir, filename));
|
|
136
|
+
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
137
|
+
},
|
|
138
|
+
toString() {
|
|
139
|
+
return [...banner, ...this.lines].join("\n");
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function normalizeViteGlobPath(file) {
|
|
144
|
+
file = slash(file);
|
|
145
|
+
if (file.startsWith("./")) return file;
|
|
146
|
+
if (file.startsWith("/")) return `.${file}`;
|
|
147
|
+
return `./${file}`;
|
|
148
|
+
}
|
|
149
|
+
function slash(path4) {
|
|
150
|
+
const isExtendedLengthPath = path4.startsWith("\\\\?\\");
|
|
151
|
+
if (isExtendedLengthPath) {
|
|
152
|
+
return path4;
|
|
153
|
+
}
|
|
154
|
+
return path4.replaceAll("\\", "/");
|
|
155
|
+
}
|
|
156
|
+
function ident(code, tab = 1) {
|
|
157
|
+
return code.split("\n").map((v) => " ".repeat(tab) + v).join("\n");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/plugins/index-file.ts
|
|
161
|
+
var import_tinyglobby2 = require("tinyglobby");
|
|
162
|
+
|
|
163
|
+
// src/utils/fs-cache.ts
|
|
164
|
+
var import_lru_cache = require("lru-cache");
|
|
165
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
166
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
167
|
+
var map = new import_lru_cache.LRUCache({
|
|
168
|
+
max: 100
|
|
169
|
+
});
|
|
170
|
+
function toFullPath(file) {
|
|
171
|
+
if (import_node_path2.default.isAbsolute(file)) {
|
|
172
|
+
return import_node_path2.default.relative(process.cwd(), file);
|
|
173
|
+
}
|
|
174
|
+
return file;
|
|
175
|
+
}
|
|
176
|
+
function readFileWithCache(file) {
|
|
177
|
+
const fullPath = toFullPath(file);
|
|
178
|
+
const cached = map.get(fullPath);
|
|
179
|
+
if (cached) return cached;
|
|
180
|
+
const read = import_promises.default.readFile(fullPath).then((s) => s.toString());
|
|
181
|
+
map.set(fullPath, read);
|
|
182
|
+
return read;
|
|
183
|
+
}
|
|
184
|
+
function removeFileCache(file) {
|
|
185
|
+
map.delete(toFullPath(file));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/plugins/index-file.ts
|
|
189
|
+
var import_crypto = require("crypto");
|
|
190
|
+
|
|
191
|
+
// src/utils/fuma-matter.ts
|
|
192
|
+
var import_js_yaml = require("js-yaml");
|
|
193
|
+
var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
|
|
194
|
+
function fumaMatter(input) {
|
|
195
|
+
const output = { matter: "", data: {}, content: input };
|
|
196
|
+
const match = regex.exec(input);
|
|
197
|
+
if (!match) {
|
|
198
|
+
return output;
|
|
199
|
+
}
|
|
200
|
+
output.matter = match[0];
|
|
201
|
+
output.content = input.slice(match[0].length);
|
|
202
|
+
const loaded = (0, import_js_yaml.load)(match[1]);
|
|
203
|
+
output.data = loaded ?? {};
|
|
204
|
+
return output;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// src/plugins/index-file.ts
|
|
208
|
+
function indexFile(options = {}) {
|
|
209
|
+
const {
|
|
210
|
+
target = "default",
|
|
211
|
+
addJsExtension,
|
|
212
|
+
browser = true,
|
|
213
|
+
dynamic = true
|
|
214
|
+
} = options;
|
|
215
|
+
let config;
|
|
216
|
+
let dynamicCollections;
|
|
217
|
+
function isDynamic(collection) {
|
|
218
|
+
return collection.type === "docs" && collection.docs.dynamic || collection.type === "doc" && collection.dynamic;
|
|
219
|
+
}
|
|
220
|
+
function generateConfigs(core) {
|
|
221
|
+
const serverOptions = {};
|
|
222
|
+
const typeConfigs = [];
|
|
223
|
+
const ctx = core.getPluginContext();
|
|
224
|
+
for (const plugin of core.getPlugins()) {
|
|
225
|
+
const indexFilePlugin = plugin["index-file"];
|
|
226
|
+
if (!indexFilePlugin) continue;
|
|
227
|
+
indexFilePlugin.serverOptions?.call(ctx, serverOptions);
|
|
228
|
+
const config2 = indexFilePlugin.generateTypeConfig?.call(ctx);
|
|
229
|
+
if (config2) typeConfigs.push(config2);
|
|
230
|
+
}
|
|
231
|
+
if (typeConfigs.length === 0) {
|
|
232
|
+
typeConfigs.push("{ DocData: {} }");
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
serverOptions,
|
|
236
|
+
tc: typeConfigs.join(" & ")
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
name: "index-file",
|
|
241
|
+
config(v) {
|
|
242
|
+
config = v;
|
|
243
|
+
dynamicCollections = config.collectionList.filter(isDynamic);
|
|
244
|
+
},
|
|
245
|
+
configureServer(server) {
|
|
246
|
+
if (!server.watcher) return;
|
|
247
|
+
server.watcher.on("all", async (event, file) => {
|
|
248
|
+
removeFileCache(file);
|
|
249
|
+
if (dynamicCollections.length === 0) {
|
|
250
|
+
if (target === "vite") return;
|
|
251
|
+
if (target === "default" && event === "change") return;
|
|
252
|
+
}
|
|
253
|
+
const updatedCollection = config.collectionList.find(
|
|
254
|
+
(collection) => collection.hasFile(file)
|
|
255
|
+
);
|
|
256
|
+
if (!updatedCollection) return;
|
|
257
|
+
if (!isDynamic(updatedCollection)) {
|
|
258
|
+
if (target === "vite") return;
|
|
259
|
+
if (target === "default" && event === "change") return;
|
|
260
|
+
}
|
|
261
|
+
await this.core.emitAndWrite({
|
|
262
|
+
filterPlugin: (plugin) => plugin.name === "index-file"
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
async emit() {
|
|
267
|
+
const globCache = /* @__PURE__ */ new Map();
|
|
268
|
+
const { serverOptions, tc } = generateConfigs(this.core);
|
|
269
|
+
const toEmitEntry = async (path4, content) => {
|
|
270
|
+
const codegen = createCodegen({
|
|
271
|
+
target,
|
|
272
|
+
outDir: this.outDir,
|
|
273
|
+
jsExtension: addJsExtension,
|
|
274
|
+
globCache
|
|
275
|
+
});
|
|
276
|
+
await content({
|
|
277
|
+
core: this.core,
|
|
278
|
+
codegen,
|
|
279
|
+
serverOptions,
|
|
280
|
+
tc
|
|
281
|
+
});
|
|
282
|
+
return {
|
|
283
|
+
path: path4,
|
|
284
|
+
content: codegen.toString()
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
const out = [
|
|
288
|
+
toEmitEntry("server.ts", generateServerIndexFile)
|
|
289
|
+
];
|
|
290
|
+
if (dynamic)
|
|
291
|
+
out.push(toEmitEntry("dynamic.ts", generateDynamicIndexFile));
|
|
292
|
+
if (browser)
|
|
293
|
+
out.push(toEmitEntry("browser.ts", generateBrowserIndexFile));
|
|
294
|
+
return await Promise.all(out);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
async function generateServerIndexFile({
|
|
299
|
+
core,
|
|
300
|
+
codegen,
|
|
301
|
+
serverOptions,
|
|
302
|
+
tc
|
|
303
|
+
}) {
|
|
304
|
+
codegen.lines.push(
|
|
305
|
+
`import { server } from 'fumadocs-mdx/runtime/server';`,
|
|
306
|
+
`import type * as Config from '${codegen.formatImportPath(core.getOptions().configPath)}';`,
|
|
307
|
+
"",
|
|
308
|
+
`const create = server<typeof Config, ${tc}>(${JSON.stringify(serverOptions)});`
|
|
309
|
+
);
|
|
310
|
+
async function generateCollectionObject(collection) {
|
|
311
|
+
switch (collection.type) {
|
|
312
|
+
case "docs": {
|
|
313
|
+
if (collection.docs.dynamic) return;
|
|
314
|
+
if (collection.docs.async) {
|
|
315
|
+
const [metaGlob2, headGlob, bodyGlob] = await Promise.all([
|
|
316
|
+
generateMetaCollectionGlob(codegen, collection.meta, true),
|
|
317
|
+
generateDocCollectionFrontmatterGlob(
|
|
318
|
+
codegen,
|
|
319
|
+
collection.docs,
|
|
320
|
+
true
|
|
321
|
+
),
|
|
322
|
+
generateDocCollectionGlob(codegen, collection.docs)
|
|
323
|
+
]);
|
|
324
|
+
return `await create.docsLazy("${collection.name}", "${collection.dir}", ${metaGlob2}, ${headGlob}, ${bodyGlob})`;
|
|
325
|
+
}
|
|
326
|
+
const [metaGlob, docGlob] = await Promise.all([
|
|
327
|
+
generateMetaCollectionGlob(codegen, collection.meta, true),
|
|
328
|
+
generateDocCollectionGlob(codegen, collection.docs, true)
|
|
329
|
+
]);
|
|
330
|
+
return `await create.docs("${collection.name}", "${collection.dir}", ${metaGlob}, ${docGlob})`;
|
|
331
|
+
}
|
|
332
|
+
case "doc":
|
|
333
|
+
if (collection.dynamic) return;
|
|
334
|
+
if (collection.async) {
|
|
335
|
+
const [headGlob, bodyGlob] = await Promise.all([
|
|
336
|
+
generateDocCollectionFrontmatterGlob(codegen, collection, true),
|
|
337
|
+
generateDocCollectionGlob(codegen, collection)
|
|
338
|
+
]);
|
|
339
|
+
return `await create.docLazy("${collection.name}", "${collection.dir}", ${headGlob}, ${bodyGlob})`;
|
|
340
|
+
}
|
|
341
|
+
return `await create.doc("${collection.name}", "${collection.dir}", ${await generateDocCollectionGlob(
|
|
342
|
+
codegen,
|
|
343
|
+
collection,
|
|
344
|
+
true
|
|
345
|
+
)})`;
|
|
346
|
+
case "meta":
|
|
347
|
+
return `await create.meta("${collection.name}", "${collection.dir}", ${await generateMetaCollectionGlob(
|
|
348
|
+
codegen,
|
|
349
|
+
collection,
|
|
350
|
+
true
|
|
351
|
+
)})`;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
await codegen.pushAsync(
|
|
355
|
+
core.getConfig().collectionList.map(async (collection) => {
|
|
356
|
+
const obj = await generateCollectionObject(collection);
|
|
357
|
+
if (!obj) return;
|
|
358
|
+
return `
|
|
359
|
+
export const ${collection.name} = ${obj};`;
|
|
360
|
+
})
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
async function generateDynamicIndexFile({
|
|
364
|
+
core,
|
|
365
|
+
codegen,
|
|
366
|
+
serverOptions,
|
|
367
|
+
tc
|
|
368
|
+
}) {
|
|
369
|
+
const { configPath } = core.getOptions();
|
|
370
|
+
codegen.lines.push(
|
|
371
|
+
`import { dynamic } from 'fumadocs-mdx/runtime/dynamic';`,
|
|
372
|
+
`import * as Config from '${codegen.formatImportPath(configPath)}';`,
|
|
373
|
+
"",
|
|
374
|
+
`const create = await dynamic<typeof Config, ${tc}>(Config, ${JSON.stringify(core.getOptions())}, ${JSON.stringify(serverOptions)});`
|
|
375
|
+
);
|
|
376
|
+
async function generateCollectionObjectEntry(collection, file) {
|
|
377
|
+
const fullPath = import_path.default.join(collection.dir, file);
|
|
378
|
+
const content = await readFileWithCache(fullPath).catch(() => "");
|
|
379
|
+
const parsed = fumaMatter(content);
|
|
380
|
+
const data = await core.transformFrontmatter(
|
|
381
|
+
{
|
|
382
|
+
collection,
|
|
383
|
+
filePath: fullPath,
|
|
384
|
+
source: content
|
|
385
|
+
},
|
|
386
|
+
parsed.data
|
|
387
|
+
);
|
|
388
|
+
const hash = (0, import_crypto.createHash)("md5").update(content).digest("hex");
|
|
389
|
+
const infoStr = [
|
|
390
|
+
// make sure it's included in vercel/nft
|
|
391
|
+
`absolutePath: path.resolve(${JSON.stringify(fullPath)})`
|
|
392
|
+
];
|
|
393
|
+
for (const [k, v] of Object.entries({
|
|
394
|
+
info: {
|
|
395
|
+
fullPath,
|
|
396
|
+
path: file
|
|
397
|
+
},
|
|
398
|
+
data,
|
|
399
|
+
hash
|
|
400
|
+
})) {
|
|
401
|
+
infoStr.push(`${k}: ${JSON.stringify(v)}`);
|
|
402
|
+
}
|
|
403
|
+
return `{ ${infoStr.join(", ")} }`;
|
|
404
|
+
}
|
|
405
|
+
async function generateCollectionObject(parent) {
|
|
406
|
+
let collection;
|
|
407
|
+
if (parent.type === "doc") collection = parent;
|
|
408
|
+
else if (parent.type === "docs") collection = parent.docs;
|
|
409
|
+
if (!collection || !collection.dynamic) return;
|
|
410
|
+
const files = await (0, import_tinyglobby2.glob)(collection.patterns, {
|
|
411
|
+
cwd: collection.dir
|
|
412
|
+
});
|
|
413
|
+
const entries = await Promise.all(
|
|
414
|
+
files.map((file) => generateCollectionObjectEntry(collection, file))
|
|
415
|
+
);
|
|
416
|
+
switch (parent.type) {
|
|
417
|
+
case "docs": {
|
|
418
|
+
const metaGlob = await generateMetaCollectionGlob(
|
|
419
|
+
codegen,
|
|
420
|
+
parent.meta,
|
|
421
|
+
true
|
|
422
|
+
);
|
|
423
|
+
return `await create.docs("${parent.name}", "${parent.dir}", ${metaGlob}, ${entries.join(", ")})`;
|
|
424
|
+
}
|
|
425
|
+
case "doc":
|
|
426
|
+
return `await create.doc("${collection.name}", "${collection.dir}", ${entries.join(", ")})`;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
await codegen.pushAsync(
|
|
430
|
+
core.getConfig().collectionList.map(async (collection) => {
|
|
431
|
+
const obj = await generateCollectionObject(collection);
|
|
432
|
+
if (!obj) return;
|
|
433
|
+
return `
|
|
434
|
+
export const ${collection.name} = ${obj};`;
|
|
435
|
+
})
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
async function generateBrowserIndexFile({ core, codegen, tc }) {
|
|
439
|
+
codegen.lines.push(
|
|
440
|
+
`import { browser } from 'fumadocs-mdx/runtime/browser';`,
|
|
441
|
+
`import type * as Config from '${codegen.formatImportPath(core.getOptions().configPath)}';`,
|
|
442
|
+
"",
|
|
443
|
+
`const create = browser<typeof Config, ${tc}>();`
|
|
444
|
+
);
|
|
445
|
+
async function generateCollectionObject(collection) {
|
|
446
|
+
switch (collection.type) {
|
|
447
|
+
case "docs": {
|
|
448
|
+
if (collection.docs.dynamic) return;
|
|
449
|
+
return generateCollectionObject(collection.docs);
|
|
450
|
+
}
|
|
451
|
+
case "doc":
|
|
452
|
+
if (collection.dynamic) return;
|
|
453
|
+
return `create.doc("${collection.name}", ${await generateDocCollectionGlob(codegen, collection)})`;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
codegen.lines.push("const browserCollections = {");
|
|
457
|
+
await codegen.pushAsync(
|
|
458
|
+
core.getConfig().collectionList.map(async (collection) => {
|
|
459
|
+
const obj = await generateCollectionObject(collection);
|
|
460
|
+
if (!obj) return;
|
|
461
|
+
return ident(`${collection.name}: ${obj},`);
|
|
462
|
+
})
|
|
463
|
+
);
|
|
464
|
+
codegen.lines.push("};", "export default browserCollections;");
|
|
465
|
+
}
|
|
466
|
+
function generateDocCollectionFrontmatterGlob(codegen, collection, eager = false) {
|
|
467
|
+
return codegen.generateGlobImport(collection.patterns, {
|
|
468
|
+
query: {
|
|
469
|
+
collection: collection.name,
|
|
470
|
+
only: "frontmatter"
|
|
471
|
+
},
|
|
472
|
+
import: "frontmatter",
|
|
473
|
+
base: collection.dir,
|
|
474
|
+
eager
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function generateDocCollectionGlob(codegen, collection, eager = false) {
|
|
478
|
+
return codegen.generateGlobImport(collection.patterns, {
|
|
479
|
+
query: {
|
|
480
|
+
collection: collection.name
|
|
481
|
+
},
|
|
482
|
+
base: collection.dir,
|
|
483
|
+
eager
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
function generateMetaCollectionGlob(codegen, collection, eager = false) {
|
|
487
|
+
return codegen.generateGlobImport(collection.patterns, {
|
|
488
|
+
query: {
|
|
489
|
+
collection: collection.name
|
|
490
|
+
},
|
|
491
|
+
import: "default",
|
|
492
|
+
base: collection.dir,
|
|
493
|
+
eager
|
|
494
|
+
});
|
|
495
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { J as IndexFilePlugin, I as IndexFilePluginOptions, H as default } from '../core-DTuP23zu.cjs';
|
|
2
|
+
import '@mdx-js/mdx';
|
|
3
|
+
import '@standard-schema/spec';
|
|
4
|
+
import 'unified';
|
|
5
|
+
import 'fumadocs-core/mdx-plugins';
|
|
6
|
+
import 'zod';
|
|
7
|
+
import 'chokidar';
|
|
8
|
+
import 'vfile';
|
|
9
|
+
import 'fumadocs-core/source';
|
|
10
|
+
import '../runtime/types.cjs';
|
|
11
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdx/types';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { J as IndexFilePlugin, I as IndexFilePluginOptions, H as default } from '../core-B9ZoS6sA.js';
|
|
2
|
+
import '@mdx-js/mdx';
|
|
3
|
+
import '@standard-schema/spec';
|
|
4
|
+
import 'unified';
|
|
5
|
+
import 'fumadocs-core/mdx-plugins';
|
|
6
|
+
import 'zod';
|
|
7
|
+
import 'chokidar';
|
|
8
|
+
import 'vfile';
|
|
9
|
+
import 'fumadocs-core/source';
|
|
10
|
+
import '../runtime/types.js';
|
|
11
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdx/types';
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as Plugin } from '../core-DTuP23zu.cjs';
|
|
2
2
|
import '@mdx-js/mdx';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
|
-
import 'fumadocs-core/mdx-plugins';
|
|
5
4
|
import 'unified';
|
|
5
|
+
import 'fumadocs-core/mdx-plugins';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'chokidar';
|
|
8
|
+
import 'vfile';
|
|
9
|
+
import 'fumadocs-core/source';
|
|
10
|
+
import '../runtime/types.cjs';
|
|
11
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdx/types';
|
|
8
15
|
|
|
9
16
|
interface JSONSchemaOptions {
|
|
10
17
|
/**
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as Plugin } from '../core-B9ZoS6sA.js';
|
|
2
2
|
import '@mdx-js/mdx';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
|
-
import 'fumadocs-core/mdx-plugins';
|
|
5
4
|
import 'unified';
|
|
5
|
+
import 'fumadocs-core/mdx-plugins';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'chokidar';
|
|
8
|
+
import 'vfile';
|
|
9
|
+
import 'fumadocs-core/source';
|
|
10
|
+
import '../runtime/types.js';
|
|
11
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdx/types';
|
|
8
15
|
|
|
9
16
|
interface JSONSchemaOptions {
|
|
10
17
|
/**
|