fumadocs-mdx 11.5.8 → 11.6.0
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-KGLACICA.js → chunk-2ZOW45YZ.js} +25 -5
- package/dist/config/index.cjs +1 -0
- package/dist/config/index.d.cts +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/{define-CGHfrlrJ.d.cts → define-BaW0PQDJ.d.cts} +1 -1
- package/dist/{define-CGHfrlrJ.d.ts → define-BaW0PQDJ.d.ts} +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/loader-mdx.cjs +25 -6
- package/dist/loader-mdx.js +3 -3
- package/dist/next/index.cjs +105 -101
- package/dist/next/index.js +84 -98
- package/dist/runtime/async.cjs +4 -4
- package/dist/runtime/async.d.cts +2 -2
- package/dist/runtime/async.d.ts +2 -2
- package/dist/runtime/async.js +7 -7
- package/dist/{types-DCyuz-WB.d.cts → types-BNrQHCj5.d.cts} +10 -4
- package/dist/{types-DfVJrYH1.d.ts → types-DEduCvIT.d.ts} +10 -4
- package/package.json +7 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/utils/schema.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import picocolors from "picocolors";
|
|
3
4
|
var metaSchema = z.object({
|
|
4
5
|
title: z.string().optional(),
|
|
5
6
|
pages: z.array(z.string()).optional(),
|
|
@@ -16,6 +17,28 @@ var frontmatterSchema = z.object({
|
|
|
16
17
|
// Fumadocs OpenAPI generated
|
|
17
18
|
_openapi: z.object({}).passthrough().optional()
|
|
18
19
|
});
|
|
20
|
+
var ValidationError = class extends Error {
|
|
21
|
+
constructor(message, issues) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.issues = issues;
|
|
24
|
+
}
|
|
25
|
+
print() {
|
|
26
|
+
console.error(
|
|
27
|
+
[
|
|
28
|
+
`[MDX] ${this.message}:`,
|
|
29
|
+
...this.issues.map(
|
|
30
|
+
(issue) => picocolors.redBright(
|
|
31
|
+
`- ${picocolors.bold(issue.path?.join(".") ?? "*")}: ${issue.message}`
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
].join("\n")
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
toString() {
|
|
38
|
+
return `${this.message}:
|
|
39
|
+
${this.issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
19
42
|
async function validate(schema, data, context, errorMessage) {
|
|
20
43
|
if (typeof schema === "function" && !("~standard" in schema)) {
|
|
21
44
|
schema = schema(context);
|
|
@@ -25,19 +48,16 @@ async function validate(schema, data, context, errorMessage) {
|
|
|
25
48
|
data
|
|
26
49
|
);
|
|
27
50
|
if (result.issues) {
|
|
28
|
-
throw new
|
|
51
|
+
throw new ValidationError(errorMessage, result.issues);
|
|
29
52
|
}
|
|
30
53
|
return result.value;
|
|
31
54
|
}
|
|
32
55
|
return data;
|
|
33
56
|
}
|
|
34
|
-
function formatError(message, issues) {
|
|
35
|
-
return `${message}:
|
|
36
|
-
${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
37
|
-
}
|
|
38
57
|
|
|
39
58
|
export {
|
|
40
59
|
metaSchema,
|
|
41
60
|
frontmatterSchema,
|
|
61
|
+
ValidationError,
|
|
42
62
|
validate
|
|
43
63
|
};
|
package/dist/config/index.cjs
CHANGED
|
@@ -42,6 +42,7 @@ module.exports = __toCommonJS(config_exports);
|
|
|
42
42
|
|
|
43
43
|
// src/utils/schema.ts
|
|
44
44
|
var import_zod = require("zod");
|
|
45
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
45
46
|
var metaSchema = import_zod.z.object({
|
|
46
47
|
title: import_zod.z.string().optional(),
|
|
47
48
|
pages: import_zod.z.array(import_zod.z.string()).optional(),
|
package/dist/config/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { c as BaseCollection, B as BaseCollectionEntry, C as CollectionSchema, h as DefaultMDXOptions, D as DocCollection, a as DocsCollection, F as FileInfo, G as GlobalConfig, b as MarkdownProps, M as MetaCollection, d as defineCollections, g as defineConfig, e as defineDocs, f as frontmatterSchema, i as getDefaultMDXOptions, m as metaSchema } from '../define-BaW0PQDJ.cjs';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
4
|
import '@mdx-js/mdx';
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { c as BaseCollection, B as BaseCollectionEntry, C as CollectionSchema, h as DefaultMDXOptions, D as DocCollection, a as DocsCollection, F as FileInfo, G as GlobalConfig, b as MarkdownProps, M as MetaCollection, d as defineCollections, g as defineConfig, e as defineDocs, f as frontmatterSchema, i as getDefaultMDXOptions, m as metaSchema } from '../define-BaW0PQDJ.js';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
4
|
import '@mdx-js/mdx';
|
package/dist/config/index.js
CHANGED
|
@@ -198,4 +198,4 @@ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmat
|
|
|
198
198
|
};
|
|
199
199
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
200
200
|
|
|
201
|
-
export { type BaseCollectionEntry as B, type CollectionSchema as C, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type
|
|
201
|
+
export { type BaseCollectionEntry as B, type CollectionSchema as C, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type MetaCollection as M, type DocsCollection as a, type MarkdownProps as b, type BaseCollection as c, defineCollections as d, defineDocs as e, frontmatterSchema as f, defineConfig as g, type DefaultMDXOptions as h, getDefaultMDXOptions as i, metaSchema as m };
|
|
@@ -198,4 +198,4 @@ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmat
|
|
|
198
198
|
};
|
|
199
199
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
200
200
|
|
|
201
|
-
export { type BaseCollectionEntry as B, type CollectionSchema as C, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type
|
|
201
|
+
export { type BaseCollectionEntry as B, type CollectionSchema as C, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type MetaCollection as M, type DocsCollection as a, type MarkdownProps as b, type BaseCollection as c, defineCollections as d, defineDocs as e, frontmatterSchema as f, defineConfig as g, type DefaultMDXOptions as h, getDefaultMDXOptions as i, metaSchema as m };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
-
import { B as BaseCollectionEntry } from './define-
|
|
3
|
-
import { R as Runtime } from './types-
|
|
4
|
-
export { a as RuntimeFile } from './types-DCyuz-WB.cjs';
|
|
2
|
+
import { B as BaseCollectionEntry } from './define-BaW0PQDJ.cjs';
|
|
3
|
+
import { R as Runtime } from './types-BNrQHCj5.cjs';
|
|
5
4
|
import '@mdx-js/mdx';
|
|
6
5
|
import 'mdx/types';
|
|
7
6
|
import 'fumadocs-core/mdx-plugins';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
-
import { B as BaseCollectionEntry } from './define-
|
|
3
|
-
import { R as Runtime } from './types-
|
|
4
|
-
export { a as RuntimeFile } from './types-DfVJrYH1.js';
|
|
2
|
+
import { B as BaseCollectionEntry } from './define-BaW0PQDJ.js';
|
|
3
|
+
import { R as Runtime } from './types-DEduCvIT.js';
|
|
5
4
|
import '@mdx-js/mdx';
|
|
6
5
|
import 'mdx/types';
|
|
7
6
|
import 'fumadocs-core/mdx-plugins';
|
package/dist/loader-mdx.cjs
CHANGED
|
@@ -389,6 +389,7 @@ function getGitTimestamp(file) {
|
|
|
389
389
|
|
|
390
390
|
// src/utils/schema.ts
|
|
391
391
|
var import_zod = require("zod");
|
|
392
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
392
393
|
var metaSchema = import_zod.z.object({
|
|
393
394
|
title: import_zod.z.string().optional(),
|
|
394
395
|
pages: import_zod.z.array(import_zod.z.string()).optional(),
|
|
@@ -405,6 +406,28 @@ var frontmatterSchema = import_zod.z.object({
|
|
|
405
406
|
// Fumadocs OpenAPI generated
|
|
406
407
|
_openapi: import_zod.z.object({}).passthrough().optional()
|
|
407
408
|
});
|
|
409
|
+
var ValidationError = class extends Error {
|
|
410
|
+
constructor(message, issues) {
|
|
411
|
+
super(message);
|
|
412
|
+
this.issues = issues;
|
|
413
|
+
}
|
|
414
|
+
print() {
|
|
415
|
+
console.error(
|
|
416
|
+
[
|
|
417
|
+
`[MDX] ${this.message}:`,
|
|
418
|
+
...this.issues.map(
|
|
419
|
+
(issue) => import_picocolors.default.redBright(
|
|
420
|
+
`- ${import_picocolors.default.bold(issue.path?.join(".") ?? "*")}: ${issue.message}`
|
|
421
|
+
)
|
|
422
|
+
)
|
|
423
|
+
].join("\n")
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
toString() {
|
|
427
|
+
return `${this.message}:
|
|
428
|
+
${this.issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
429
|
+
}
|
|
430
|
+
};
|
|
408
431
|
async function validate(schema, data, context, errorMessage) {
|
|
409
432
|
if (typeof schema === "function" && !("~standard" in schema)) {
|
|
410
433
|
schema = schema(context);
|
|
@@ -414,16 +437,12 @@ async function validate(schema, data, context, errorMessage) {
|
|
|
414
437
|
data
|
|
415
438
|
);
|
|
416
439
|
if (result.issues) {
|
|
417
|
-
throw new
|
|
440
|
+
throw new ValidationError(errorMessage, result.issues);
|
|
418
441
|
}
|
|
419
442
|
return result.value;
|
|
420
443
|
}
|
|
421
444
|
return data;
|
|
422
445
|
}
|
|
423
|
-
function formatError(message, issues) {
|
|
424
|
-
return `${message}:
|
|
425
|
-
${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
426
|
-
}
|
|
427
446
|
|
|
428
447
|
// src/loader-mdx.ts
|
|
429
448
|
function parseQuery(query) {
|
|
@@ -467,7 +486,7 @@ async function loader(source, callback) {
|
|
|
467
486
|
source,
|
|
468
487
|
path: filePath
|
|
469
488
|
},
|
|
470
|
-
`invalid frontmatter in ${filePath}
|
|
489
|
+
`invalid frontmatter in ${filePath}`
|
|
471
490
|
);
|
|
472
491
|
}
|
|
473
492
|
let timestamp;
|
package/dist/loader-mdx.js
CHANGED
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
getConfigHash,
|
|
3
3
|
loadConfig
|
|
4
4
|
} from "./chunk-HFLDWPJA.js";
|
|
5
|
+
import "./chunk-DRVUBK5B.js";
|
|
5
6
|
import {
|
|
6
7
|
validate
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2ZOW45YZ.js";
|
|
8
9
|
import {
|
|
9
10
|
remarkInclude
|
|
10
11
|
} from "./chunk-MK7EXW7O.js";
|
|
11
|
-
import "./chunk-DRVUBK5B.js";
|
|
12
12
|
|
|
13
13
|
// src/loader-mdx.ts
|
|
14
14
|
import * as path2 from "node:path";
|
|
@@ -118,7 +118,7 @@ async function loader(source, callback) {
|
|
|
118
118
|
source,
|
|
119
119
|
path: filePath
|
|
120
120
|
},
|
|
121
|
-
`invalid frontmatter in ${filePath}
|
|
121
|
+
`invalid frontmatter in ${filePath}`
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
124
|
let timestamp;
|
package/dist/next/index.cjs
CHANGED
|
@@ -167,11 +167,11 @@ async function getConfigHash(configPath) {
|
|
|
167
167
|
|
|
168
168
|
// src/map/index.ts
|
|
169
169
|
var path3 = __toESM(require("path"), 1);
|
|
170
|
-
var
|
|
170
|
+
var fs3 = __toESM(require("fs/promises"), 1);
|
|
171
171
|
|
|
172
172
|
// src/map/generate.ts
|
|
173
173
|
var path2 = __toESM(require("path"), 1);
|
|
174
|
-
var
|
|
174
|
+
var fs2 = __toESM(require("fs/promises"), 1);
|
|
175
175
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
176
176
|
|
|
177
177
|
// src/utils/get-type-from-path.ts
|
|
@@ -186,6 +186,7 @@ function getTypeFromPath(path6) {
|
|
|
186
186
|
|
|
187
187
|
// src/utils/schema.ts
|
|
188
188
|
var import_zod = require("zod");
|
|
189
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
189
190
|
var metaSchema = import_zod.z.object({
|
|
190
191
|
title: import_zod.z.string().optional(),
|
|
191
192
|
pages: import_zod.z.array(import_zod.z.string()).optional(),
|
|
@@ -202,6 +203,28 @@ var frontmatterSchema = import_zod.z.object({
|
|
|
202
203
|
// Fumadocs OpenAPI generated
|
|
203
204
|
_openapi: import_zod.z.object({}).passthrough().optional()
|
|
204
205
|
});
|
|
206
|
+
var ValidationError = class extends Error {
|
|
207
|
+
constructor(message, issues) {
|
|
208
|
+
super(message);
|
|
209
|
+
this.issues = issues;
|
|
210
|
+
}
|
|
211
|
+
print() {
|
|
212
|
+
console.error(
|
|
213
|
+
[
|
|
214
|
+
`[MDX] ${this.message}:`,
|
|
215
|
+
...this.issues.map(
|
|
216
|
+
(issue) => import_picocolors.default.redBright(
|
|
217
|
+
`- ${import_picocolors.default.bold(issue.path?.join(".") ?? "*")}: ${issue.message}`
|
|
218
|
+
)
|
|
219
|
+
)
|
|
220
|
+
].join("\n")
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
toString() {
|
|
224
|
+
return `${this.message}:
|
|
225
|
+
${this.issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
205
228
|
async function validate(schema, data, context, errorMessage) {
|
|
206
229
|
if (typeof schema === "function" && !("~standard" in schema)) {
|
|
207
230
|
schema = schema(context);
|
|
@@ -211,16 +234,12 @@ async function validate(schema, data, context, errorMessage) {
|
|
|
211
234
|
data
|
|
212
235
|
);
|
|
213
236
|
if (result.issues) {
|
|
214
|
-
throw new
|
|
237
|
+
throw new ValidationError(errorMessage, result.issues);
|
|
215
238
|
}
|
|
216
239
|
return result.value;
|
|
217
240
|
}
|
|
218
241
|
return data;
|
|
219
242
|
}
|
|
220
|
-
function formatError(message, issues) {
|
|
221
|
-
return `${message}:
|
|
222
|
-
${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
|
|
223
|
-
}
|
|
224
243
|
|
|
225
244
|
// src/map/file-cache.ts
|
|
226
245
|
var import_lru_cache = require("lru-cache");
|
|
@@ -242,46 +261,12 @@ var fileCache = {
|
|
|
242
261
|
}
|
|
243
262
|
};
|
|
244
263
|
|
|
245
|
-
// src/utils/read-frontmatter.ts
|
|
246
|
-
var fs2 = __toESM(require("fs"), 1);
|
|
247
|
-
var import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
248
|
-
async function readFrontmatter(file) {
|
|
249
|
-
const readStream = fs2.createReadStream(file, {
|
|
250
|
-
highWaterMark: 250
|
|
251
|
-
});
|
|
252
|
-
return new Promise((res, rej) => {
|
|
253
|
-
let idx = 0;
|
|
254
|
-
let str = "";
|
|
255
|
-
readStream.on("data", (_chunk) => {
|
|
256
|
-
const chunk = _chunk.toString();
|
|
257
|
-
if (idx === 0 && !chunk.startsWith("---")) {
|
|
258
|
-
res({});
|
|
259
|
-
readStream.close();
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
str += chunk;
|
|
263
|
-
idx++;
|
|
264
|
-
if (str.includes("\n---")) {
|
|
265
|
-
res(
|
|
266
|
-
(0, import_gray_matter.default)({
|
|
267
|
-
content: str
|
|
268
|
-
}).data
|
|
269
|
-
);
|
|
270
|
-
readStream.close();
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
readStream.on("end", () => res({}));
|
|
274
|
-
readStream.on("error", (e) => rej(e));
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
264
|
// src/map/generate.ts
|
|
279
|
-
|
|
280
|
-
|
|
265
|
+
var import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
266
|
+
async function readFileWithCache(file) {
|
|
267
|
+
const cached = fileCache.read("read-file", file);
|
|
281
268
|
if (cached) return cached;
|
|
282
|
-
|
|
283
|
-
fileCache.write("read-frontmatter", file, res);
|
|
284
|
-
return res;
|
|
269
|
+
return (await fs2.readFile(file)).toString();
|
|
285
270
|
}
|
|
286
271
|
async function generateJS(configPath, config, outputPath, configHash) {
|
|
287
272
|
const outDir2 = path2.dirname(outputPath);
|
|
@@ -299,28 +284,8 @@ async function generateJS(configPath, config, outputPath, configHash) {
|
|
|
299
284
|
})
|
|
300
285
|
];
|
|
301
286
|
const entries = Array.from(config.collections.entries());
|
|
302
|
-
async function
|
|
287
|
+
async function getDocEntries(collectionName, files) {
|
|
303
288
|
const items = files.map(async (file, i) => {
|
|
304
|
-
if (collection.type === "meta") {
|
|
305
|
-
const cached = fileCache.read("generate-js", file.absolutePath);
|
|
306
|
-
if (cached) return cached;
|
|
307
|
-
const source = (await fs3.readFile(file.absolutePath)).toString();
|
|
308
|
-
let data = JSON.parse(source);
|
|
309
|
-
if (collection?.schema) {
|
|
310
|
-
data = await validate(
|
|
311
|
-
collection.schema,
|
|
312
|
-
data,
|
|
313
|
-
{
|
|
314
|
-
source,
|
|
315
|
-
path: file.absolutePath
|
|
316
|
-
},
|
|
317
|
-
`invalid data in ${file.absolutePath}:`
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
const entry = `{ info: ${JSON.stringify(file)}, data: ${JSON.stringify(data)} }`;
|
|
321
|
-
fileCache.write("generate-js", file.absolutePath, entry);
|
|
322
|
-
return entry;
|
|
323
|
-
}
|
|
324
289
|
const importId = `${collectionName}_${i}`;
|
|
325
290
|
lines.unshift(
|
|
326
291
|
getImportCode({
|
|
@@ -333,7 +298,29 @@ async function generateJS(configPath, config, outputPath, configHash) {
|
|
|
333
298
|
});
|
|
334
299
|
return Promise.all(items);
|
|
335
300
|
}
|
|
336
|
-
async function
|
|
301
|
+
async function getMetaEntries(collection, files) {
|
|
302
|
+
const items = files.map(async (file) => {
|
|
303
|
+
const source = await readFileWithCache(file.absolutePath).catch(() => "");
|
|
304
|
+
let data = source.length === 0 ? {} : JSON.parse(source);
|
|
305
|
+
if (collection?.schema) {
|
|
306
|
+
data = await validate(
|
|
307
|
+
collection.schema,
|
|
308
|
+
data,
|
|
309
|
+
{
|
|
310
|
+
source,
|
|
311
|
+
path: file.absolutePath
|
|
312
|
+
},
|
|
313
|
+
`invalid data in ${file.absolutePath}`
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
return JSON.stringify({
|
|
317
|
+
info: file,
|
|
318
|
+
data
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
return Promise.all(items);
|
|
322
|
+
}
|
|
323
|
+
async function getAsyncEntries(collection, files) {
|
|
337
324
|
if (!asyncInit) {
|
|
338
325
|
lines.unshift(
|
|
339
326
|
getImportCode({
|
|
@@ -347,9 +334,21 @@ async function generateJS(configPath, config, outputPath, configHash) {
|
|
|
347
334
|
asyncInit = true;
|
|
348
335
|
}
|
|
349
336
|
const entries2 = files.map(async (file) => {
|
|
337
|
+
const parsed = (0, import_gray_matter.default)(
|
|
338
|
+
await readFileWithCache(file.absolutePath).catch(() => "")
|
|
339
|
+
);
|
|
340
|
+
if (collection.schema) {
|
|
341
|
+
parsed.data = await validate(
|
|
342
|
+
collection.schema,
|
|
343
|
+
parsed.data,
|
|
344
|
+
{ path: file.absolutePath, source: parsed.content },
|
|
345
|
+
`invalid frontmatter in ${file.absolutePath}`
|
|
346
|
+
);
|
|
347
|
+
}
|
|
350
348
|
return JSON.stringify({
|
|
351
349
|
info: file,
|
|
352
|
-
data:
|
|
350
|
+
data: parsed.data,
|
|
351
|
+
content: parsed.content
|
|
353
352
|
});
|
|
354
353
|
});
|
|
355
354
|
return Promise.all(entries2);
|
|
@@ -358,23 +357,23 @@ async function generateJS(configPath, config, outputPath, configHash) {
|
|
|
358
357
|
if (collection.type === "docs") {
|
|
359
358
|
const docs = await getCollectionFiles(collection.docs);
|
|
360
359
|
const metas = await getCollectionFiles(collection.meta);
|
|
361
|
-
const metaEntries = (await
|
|
360
|
+
const metaEntries = (await getMetaEntries(collection.meta, metas)).join(
|
|
362
361
|
", "
|
|
363
362
|
);
|
|
364
363
|
if (collection.docs.async) {
|
|
365
|
-
const docsEntries2 = (await getAsyncEntries(docs)).join(
|
|
364
|
+
const docsEntries2 = (await getAsyncEntries(collection.docs, docs)).join(
|
|
365
|
+
", "
|
|
366
|
+
);
|
|
366
367
|
return `export const ${k} = _runtimeAsync.docs<typeof _source.${k}>([${docsEntries2}], [${metaEntries}], "${k}", _sourceConfig)`;
|
|
367
368
|
}
|
|
368
|
-
const docsEntries = (await
|
|
369
|
-
", "
|
|
370
|
-
);
|
|
369
|
+
const docsEntries = (await getDocEntries(k, docs)).join(", ");
|
|
371
370
|
return `export const ${k} = _runtime.docs<typeof _source.${k}>([${docsEntries}], [${metaEntries}])`;
|
|
372
371
|
}
|
|
373
372
|
const files = await getCollectionFiles(collection);
|
|
374
373
|
if (collection.type === "doc" && collection.async) {
|
|
375
|
-
return `export const ${k} = _runtimeAsync.doc<typeof _source.${k}>([${(await getAsyncEntries(files)).join(", ")}], "${k}", _sourceConfig)`;
|
|
374
|
+
return `export const ${k} = _runtimeAsync.doc<typeof _source.${k}>([${(await getAsyncEntries(collection, files)).join(", ")}], "${k}", _sourceConfig)`;
|
|
376
375
|
}
|
|
377
|
-
return `export const ${k} = _runtime.${collection.type}<typeof _source.${k}>([${(await
|
|
376
|
+
return `export const ${k} = _runtime.${collection.type}<typeof _source.${k}>([${(await getDocEntries(k, files)).join(", ")}]);`;
|
|
378
377
|
});
|
|
379
378
|
const resolvedDeclares = await Promise.all(declares);
|
|
380
379
|
return [
|
|
@@ -430,18 +429,26 @@ function toImportPath(file, dir) {
|
|
|
430
429
|
|
|
431
430
|
// src/map/index.ts
|
|
432
431
|
async function start(dev, configPath, outDir2) {
|
|
433
|
-
void
|
|
434
|
-
void
|
|
435
|
-
await
|
|
432
|
+
void fs3.rm(path3.resolve(outDir2, `index.js`), { force: true });
|
|
433
|
+
void fs3.rm(path3.resolve(outDir2, `index.d.ts`), { force: true });
|
|
434
|
+
await fs3.mkdir(outDir2, { recursive: true });
|
|
436
435
|
let configHash = await getConfigHash(configPath);
|
|
437
436
|
let config = await loadConfig(configPath, configHash, true);
|
|
438
437
|
const outPath = path3.resolve(outDir2, `index.ts`);
|
|
439
438
|
async function updateMapFile() {
|
|
440
439
|
console.time(`[MDX] update map file`);
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
440
|
+
try {
|
|
441
|
+
await fs3.writeFile(
|
|
442
|
+
outPath,
|
|
443
|
+
await generateJS(configPath, config, outPath, configHash)
|
|
444
|
+
);
|
|
445
|
+
} catch (err) {
|
|
446
|
+
if (err instanceof ValidationError) {
|
|
447
|
+
err.print();
|
|
448
|
+
} else {
|
|
449
|
+
console.error(err);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
445
452
|
console.timeEnd(`[MDX] update map file`);
|
|
446
453
|
}
|
|
447
454
|
await updateMapFile();
|
|
@@ -492,22 +499,19 @@ function createMDX({
|
|
|
492
499
|
};
|
|
493
500
|
return {
|
|
494
501
|
...nextConfig,
|
|
495
|
-
|
|
496
|
-
...nextConfig
|
|
497
|
-
|
|
498
|
-
...nextConfig
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
],
|
|
509
|
-
as: "*.js"
|
|
510
|
-
}
|
|
502
|
+
turbopack: {
|
|
503
|
+
...nextConfig?.turbopack,
|
|
504
|
+
rules: {
|
|
505
|
+
...nextConfig?.turbopack?.rules,
|
|
506
|
+
// @ts-expect-error -- safe
|
|
507
|
+
"*.{md,mdx}": {
|
|
508
|
+
loaders: [
|
|
509
|
+
{
|
|
510
|
+
loader: "fumadocs-mdx/loader-mdx",
|
|
511
|
+
options: mdxLoaderOptions
|
|
512
|
+
}
|
|
513
|
+
],
|
|
514
|
+
as: "*.js"
|
|
511
515
|
}
|
|
512
516
|
}
|
|
513
517
|
},
|
|
@@ -535,13 +539,13 @@ function createMDX({
|
|
|
535
539
|
|
|
536
540
|
// src/postinstall.ts
|
|
537
541
|
var path5 = __toESM(require("path"), 1);
|
|
538
|
-
var
|
|
542
|
+
var fs4 = __toESM(require("fs"), 1);
|
|
539
543
|
async function postInstall(configPath = findConfigFile()) {
|
|
540
544
|
const jsOut = path5.resolve(".source/index.ts");
|
|
541
545
|
const hash = await getConfigHash(configPath);
|
|
542
546
|
const config = await loadConfig(configPath, hash, true);
|
|
543
|
-
|
|
544
|
-
|
|
547
|
+
fs4.mkdirSync(path5.dirname(jsOut), { recursive: true });
|
|
548
|
+
fs4.writeFileSync(
|
|
545
549
|
jsOut,
|
|
546
550
|
await generateJS(
|
|
547
551
|
configPath,
|
package/dist/next/index.js
CHANGED
|
@@ -3,21 +3,22 @@ import {
|
|
|
3
3
|
getConfigHash,
|
|
4
4
|
loadConfig
|
|
5
5
|
} from "../chunk-HFLDWPJA.js";
|
|
6
|
+
import "../chunk-DRVUBK5B.js";
|
|
6
7
|
import {
|
|
8
|
+
ValidationError,
|
|
7
9
|
validate
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-DRVUBK5B.js";
|
|
10
|
+
} from "../chunk-2ZOW45YZ.js";
|
|
10
11
|
|
|
11
12
|
// src/next/create.ts
|
|
12
13
|
import path3 from "node:path";
|
|
13
14
|
|
|
14
15
|
// src/map/index.ts
|
|
15
16
|
import * as path2 from "node:path";
|
|
16
|
-
import * as
|
|
17
|
+
import * as fs2 from "node:fs/promises";
|
|
17
18
|
|
|
18
19
|
// src/map/generate.ts
|
|
19
20
|
import * as path from "node:path";
|
|
20
|
-
import * as
|
|
21
|
+
import * as fs from "node:fs/promises";
|
|
21
22
|
import fg from "fast-glob";
|
|
22
23
|
|
|
23
24
|
// src/utils/get-type-from-path.ts
|
|
@@ -50,46 +51,12 @@ var fileCache = {
|
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
|
|
53
|
-
// src/utils/read-frontmatter.ts
|
|
54
|
-
import * as fs from "node:fs";
|
|
55
|
-
import grayMatter from "gray-matter";
|
|
56
|
-
async function readFrontmatter(file) {
|
|
57
|
-
const readStream = fs.createReadStream(file, {
|
|
58
|
-
highWaterMark: 250
|
|
59
|
-
});
|
|
60
|
-
return new Promise((res, rej) => {
|
|
61
|
-
let idx = 0;
|
|
62
|
-
let str = "";
|
|
63
|
-
readStream.on("data", (_chunk) => {
|
|
64
|
-
const chunk = _chunk.toString();
|
|
65
|
-
if (idx === 0 && !chunk.startsWith("---")) {
|
|
66
|
-
res({});
|
|
67
|
-
readStream.close();
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
str += chunk;
|
|
71
|
-
idx++;
|
|
72
|
-
if (str.includes("\n---")) {
|
|
73
|
-
res(
|
|
74
|
-
grayMatter({
|
|
75
|
-
content: str
|
|
76
|
-
}).data
|
|
77
|
-
);
|
|
78
|
-
readStream.close();
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
readStream.on("end", () => res({}));
|
|
82
|
-
readStream.on("error", (e) => rej(e));
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
54
|
// src/map/generate.ts
|
|
87
|
-
|
|
88
|
-
|
|
55
|
+
import matter from "gray-matter";
|
|
56
|
+
async function readFileWithCache(file) {
|
|
57
|
+
const cached = fileCache.read("read-file", file);
|
|
89
58
|
if (cached) return cached;
|
|
90
|
-
|
|
91
|
-
fileCache.write("read-frontmatter", file, res);
|
|
92
|
-
return res;
|
|
59
|
+
return (await fs.readFile(file)).toString();
|
|
93
60
|
}
|
|
94
61
|
async function generateJS(configPath, config, outputPath, configHash) {
|
|
95
62
|
const outDir2 = path.dirname(outputPath);
|
|
@@ -107,28 +74,8 @@ async function generateJS(configPath, config, outputPath, configHash) {
|
|
|
107
74
|
})
|
|
108
75
|
];
|
|
109
76
|
const entries = Array.from(config.collections.entries());
|
|
110
|
-
async function
|
|
77
|
+
async function getDocEntries(collectionName, files) {
|
|
111
78
|
const items = files.map(async (file, i) => {
|
|
112
|
-
if (collection.type === "meta") {
|
|
113
|
-
const cached = fileCache.read("generate-js", file.absolutePath);
|
|
114
|
-
if (cached) return cached;
|
|
115
|
-
const source = (await fs2.readFile(file.absolutePath)).toString();
|
|
116
|
-
let data = JSON.parse(source);
|
|
117
|
-
if (collection?.schema) {
|
|
118
|
-
data = await validate(
|
|
119
|
-
collection.schema,
|
|
120
|
-
data,
|
|
121
|
-
{
|
|
122
|
-
source,
|
|
123
|
-
path: file.absolutePath
|
|
124
|
-
},
|
|
125
|
-
`invalid data in ${file.absolutePath}:`
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
const entry = `{ info: ${JSON.stringify(file)}, data: ${JSON.stringify(data)} }`;
|
|
129
|
-
fileCache.write("generate-js", file.absolutePath, entry);
|
|
130
|
-
return entry;
|
|
131
|
-
}
|
|
132
79
|
const importId = `${collectionName}_${i}`;
|
|
133
80
|
lines.unshift(
|
|
134
81
|
getImportCode({
|
|
@@ -141,7 +88,29 @@ async function generateJS(configPath, config, outputPath, configHash) {
|
|
|
141
88
|
});
|
|
142
89
|
return Promise.all(items);
|
|
143
90
|
}
|
|
144
|
-
async function
|
|
91
|
+
async function getMetaEntries(collection, files) {
|
|
92
|
+
const items = files.map(async (file) => {
|
|
93
|
+
const source = await readFileWithCache(file.absolutePath).catch(() => "");
|
|
94
|
+
let data = source.length === 0 ? {} : JSON.parse(source);
|
|
95
|
+
if (collection?.schema) {
|
|
96
|
+
data = await validate(
|
|
97
|
+
collection.schema,
|
|
98
|
+
data,
|
|
99
|
+
{
|
|
100
|
+
source,
|
|
101
|
+
path: file.absolutePath
|
|
102
|
+
},
|
|
103
|
+
`invalid data in ${file.absolutePath}`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return JSON.stringify({
|
|
107
|
+
info: file,
|
|
108
|
+
data
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
return Promise.all(items);
|
|
112
|
+
}
|
|
113
|
+
async function getAsyncEntries(collection, files) {
|
|
145
114
|
if (!asyncInit) {
|
|
146
115
|
lines.unshift(
|
|
147
116
|
getImportCode({
|
|
@@ -155,9 +124,21 @@ async function generateJS(configPath, config, outputPath, configHash) {
|
|
|
155
124
|
asyncInit = true;
|
|
156
125
|
}
|
|
157
126
|
const entries2 = files.map(async (file) => {
|
|
127
|
+
const parsed = matter(
|
|
128
|
+
await readFileWithCache(file.absolutePath).catch(() => "")
|
|
129
|
+
);
|
|
130
|
+
if (collection.schema) {
|
|
131
|
+
parsed.data = await validate(
|
|
132
|
+
collection.schema,
|
|
133
|
+
parsed.data,
|
|
134
|
+
{ path: file.absolutePath, source: parsed.content },
|
|
135
|
+
`invalid frontmatter in ${file.absolutePath}`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
158
138
|
return JSON.stringify({
|
|
159
139
|
info: file,
|
|
160
|
-
data:
|
|
140
|
+
data: parsed.data,
|
|
141
|
+
content: parsed.content
|
|
161
142
|
});
|
|
162
143
|
});
|
|
163
144
|
return Promise.all(entries2);
|
|
@@ -166,23 +147,23 @@ async function generateJS(configPath, config, outputPath, configHash) {
|
|
|
166
147
|
if (collection.type === "docs") {
|
|
167
148
|
const docs = await getCollectionFiles(collection.docs);
|
|
168
149
|
const metas = await getCollectionFiles(collection.meta);
|
|
169
|
-
const metaEntries = (await
|
|
150
|
+
const metaEntries = (await getMetaEntries(collection.meta, metas)).join(
|
|
170
151
|
", "
|
|
171
152
|
);
|
|
172
153
|
if (collection.docs.async) {
|
|
173
|
-
const docsEntries2 = (await getAsyncEntries(docs)).join(
|
|
154
|
+
const docsEntries2 = (await getAsyncEntries(collection.docs, docs)).join(
|
|
155
|
+
", "
|
|
156
|
+
);
|
|
174
157
|
return `export const ${k} = _runtimeAsync.docs<typeof _source.${k}>([${docsEntries2}], [${metaEntries}], "${k}", _sourceConfig)`;
|
|
175
158
|
}
|
|
176
|
-
const docsEntries = (await
|
|
177
|
-
", "
|
|
178
|
-
);
|
|
159
|
+
const docsEntries = (await getDocEntries(k, docs)).join(", ");
|
|
179
160
|
return `export const ${k} = _runtime.docs<typeof _source.${k}>([${docsEntries}], [${metaEntries}])`;
|
|
180
161
|
}
|
|
181
162
|
const files = await getCollectionFiles(collection);
|
|
182
163
|
if (collection.type === "doc" && collection.async) {
|
|
183
|
-
return `export const ${k} = _runtimeAsync.doc<typeof _source.${k}>([${(await getAsyncEntries(files)).join(", ")}], "${k}", _sourceConfig)`;
|
|
164
|
+
return `export const ${k} = _runtimeAsync.doc<typeof _source.${k}>([${(await getAsyncEntries(collection, files)).join(", ")}], "${k}", _sourceConfig)`;
|
|
184
165
|
}
|
|
185
|
-
return `export const ${k} = _runtime.${collection.type}<typeof _source.${k}>([${(await
|
|
166
|
+
return `export const ${k} = _runtime.${collection.type}<typeof _source.${k}>([${(await getDocEntries(k, files)).join(", ")}]);`;
|
|
186
167
|
});
|
|
187
168
|
const resolvedDeclares = await Promise.all(declares);
|
|
188
169
|
return [
|
|
@@ -238,18 +219,26 @@ function toImportPath(file, dir) {
|
|
|
238
219
|
|
|
239
220
|
// src/map/index.ts
|
|
240
221
|
async function start(dev, configPath, outDir2) {
|
|
241
|
-
void
|
|
242
|
-
void
|
|
243
|
-
await
|
|
222
|
+
void fs2.rm(path2.resolve(outDir2, `index.js`), { force: true });
|
|
223
|
+
void fs2.rm(path2.resolve(outDir2, `index.d.ts`), { force: true });
|
|
224
|
+
await fs2.mkdir(outDir2, { recursive: true });
|
|
244
225
|
let configHash = await getConfigHash(configPath);
|
|
245
226
|
let config = await loadConfig(configPath, configHash, true);
|
|
246
227
|
const outPath = path2.resolve(outDir2, `index.ts`);
|
|
247
228
|
async function updateMapFile() {
|
|
248
229
|
console.time(`[MDX] update map file`);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
230
|
+
try {
|
|
231
|
+
await fs2.writeFile(
|
|
232
|
+
outPath,
|
|
233
|
+
await generateJS(configPath, config, outPath, configHash)
|
|
234
|
+
);
|
|
235
|
+
} catch (err) {
|
|
236
|
+
if (err instanceof ValidationError) {
|
|
237
|
+
err.print();
|
|
238
|
+
} else {
|
|
239
|
+
console.error(err);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
253
242
|
console.timeEnd(`[MDX] update map file`);
|
|
254
243
|
}
|
|
255
244
|
await updateMapFile();
|
|
@@ -300,22 +289,19 @@ function createMDX({
|
|
|
300
289
|
};
|
|
301
290
|
return {
|
|
302
291
|
...nextConfig,
|
|
303
|
-
|
|
304
|
-
...nextConfig
|
|
305
|
-
|
|
306
|
-
...nextConfig
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
],
|
|
317
|
-
as: "*.js"
|
|
318
|
-
}
|
|
292
|
+
turbopack: {
|
|
293
|
+
...nextConfig?.turbopack,
|
|
294
|
+
rules: {
|
|
295
|
+
...nextConfig?.turbopack?.rules,
|
|
296
|
+
// @ts-expect-error -- safe
|
|
297
|
+
"*.{md,mdx}": {
|
|
298
|
+
loaders: [
|
|
299
|
+
{
|
|
300
|
+
loader: "fumadocs-mdx/loader-mdx",
|
|
301
|
+
options: mdxLoaderOptions
|
|
302
|
+
}
|
|
303
|
+
],
|
|
304
|
+
as: "*.js"
|
|
319
305
|
}
|
|
320
306
|
}
|
|
321
307
|
},
|
|
@@ -343,13 +329,13 @@ function createMDX({
|
|
|
343
329
|
|
|
344
330
|
// src/postinstall.ts
|
|
345
331
|
import * as path4 from "node:path";
|
|
346
|
-
import * as
|
|
332
|
+
import * as fs3 from "node:fs";
|
|
347
333
|
async function postInstall(configPath = findConfigFile()) {
|
|
348
334
|
const jsOut = path4.resolve(".source/index.ts");
|
|
349
335
|
const hash = await getConfigHash(configPath);
|
|
350
336
|
const config = await loadConfig(configPath, hash, true);
|
|
351
|
-
|
|
352
|
-
|
|
337
|
+
fs3.mkdirSync(path4.dirname(jsOut), { recursive: true });
|
|
338
|
+
fs3.writeFileSync(
|
|
353
339
|
jsOut,
|
|
354
340
|
await generateJS(
|
|
355
341
|
configPath,
|
package/dist/runtime/async.cjs
CHANGED
|
@@ -35,7 +35,6 @@ __export(async_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(async_exports);
|
|
37
37
|
var import_mdx_remote = require("@fumadocs/mdx-remote");
|
|
38
|
-
var fs2 = __toESM(require("fs/promises"), 1);
|
|
39
38
|
|
|
40
39
|
// src/mdx-plugins/remark-include.ts
|
|
41
40
|
var import_unist_util_visit = require("unist-util-visit");
|
|
@@ -230,14 +229,15 @@ async function initCompiler(config, collection) {
|
|
|
230
229
|
var _runtimeAsync = {
|
|
231
230
|
doc(files, collection, config) {
|
|
232
231
|
const init = initCompiler(config, collection);
|
|
233
|
-
return files.map(({ info: file, data
|
|
232
|
+
return files.map(({ info: file, data, content }) => {
|
|
234
233
|
return {
|
|
235
|
-
...
|
|
234
|
+
...data,
|
|
236
235
|
_file: file,
|
|
236
|
+
content,
|
|
237
237
|
async load() {
|
|
238
238
|
const compiler = await init;
|
|
239
239
|
const out = await compiler.compile({
|
|
240
|
-
source:
|
|
240
|
+
source: content,
|
|
241
241
|
filePath: file.absolutePath
|
|
242
242
|
});
|
|
243
243
|
return {
|
package/dist/runtime/async.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LoadedConfig,
|
|
2
|
-
import '../define-
|
|
1
|
+
import { L as LoadedConfig, a as RuntimeAsync } from '../types-BNrQHCj5.cjs';
|
|
2
|
+
import '../define-BaW0PQDJ.cjs';
|
|
3
3
|
import '@mdx-js/mdx';
|
|
4
4
|
import 'mdx/types';
|
|
5
5
|
import 'fumadocs-core/mdx-plugins';
|
package/dist/runtime/async.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LoadedConfig,
|
|
2
|
-
import '../define-
|
|
1
|
+
import { L as LoadedConfig, a as RuntimeAsync } from '../types-DEduCvIT.js';
|
|
2
|
+
import '../define-BaW0PQDJ.js';
|
|
3
3
|
import '@mdx-js/mdx';
|
|
4
4
|
import 'mdx/types';
|
|
5
5
|
import 'fumadocs-core/mdx-plugins';
|
package/dist/runtime/async.js
CHANGED
|
@@ -2,16 +2,15 @@ import {
|
|
|
2
2
|
_runtime,
|
|
3
3
|
createMDXSource
|
|
4
4
|
} from "../chunk-VFALQK6O.js";
|
|
5
|
-
import {
|
|
6
|
-
remarkInclude
|
|
7
|
-
} from "../chunk-MK7EXW7O.js";
|
|
8
5
|
import {
|
|
9
6
|
buildConfig
|
|
10
7
|
} from "../chunk-DRVUBK5B.js";
|
|
8
|
+
import {
|
|
9
|
+
remarkInclude
|
|
10
|
+
} from "../chunk-MK7EXW7O.js";
|
|
11
11
|
|
|
12
12
|
// src/runtime/async.ts
|
|
13
13
|
import { createCompiler } from "@fumadocs/mdx-remote";
|
|
14
|
-
import * as fs from "node:fs/promises";
|
|
15
14
|
import {
|
|
16
15
|
remarkStructure
|
|
17
16
|
} from "fumadocs-core/mdx-plugins";
|
|
@@ -35,14 +34,15 @@ async function initCompiler(config, collection) {
|
|
|
35
34
|
var _runtimeAsync = {
|
|
36
35
|
doc(files, collection, config) {
|
|
37
36
|
const init = initCompiler(config, collection);
|
|
38
|
-
return files.map(({ info: file, data
|
|
37
|
+
return files.map(({ info: file, data, content }) => {
|
|
39
38
|
return {
|
|
40
|
-
...
|
|
39
|
+
...data,
|
|
41
40
|
_file: file,
|
|
41
|
+
content,
|
|
42
42
|
async load() {
|
|
43
43
|
const compiler = await init;
|
|
44
44
|
const out = await compiler.compile({
|
|
45
|
-
source:
|
|
45
|
+
source: content,
|
|
46
46
|
filePath: file.absolutePath
|
|
47
47
|
});
|
|
48
48
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DocCollection,
|
|
1
|
+
import { D as DocCollection, M as MetaCollection, a as DocsCollection, G as GlobalConfig, F as FileInfo, b as MarkdownProps, B as BaseCollectionEntry } from './define-BaW0PQDJ.cjs';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
import { Source, PageData, MetaData } from 'fumadocs-core/source';
|
|
4
4
|
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
@@ -19,6 +19,11 @@ interface RuntimeFile {
|
|
|
19
19
|
info: FileInfo;
|
|
20
20
|
data: Record<string, unknown>;
|
|
21
21
|
}
|
|
22
|
+
interface AsyncRuntimeFile {
|
|
23
|
+
info: FileInfo;
|
|
24
|
+
data: Record<string, unknown>;
|
|
25
|
+
content: string;
|
|
26
|
+
}
|
|
22
27
|
type DocOut<Schema extends StandardSchemaV1> = Omit<MarkdownProps, keyof StandardSchemaV1.InferOutput<Schema>> & StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
|
|
23
28
|
type MetaOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
|
|
24
29
|
interface Runtime {
|
|
@@ -58,16 +63,17 @@ interface Runtime {
|
|
|
58
63
|
} : never;
|
|
59
64
|
}
|
|
60
65
|
type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
|
|
66
|
+
content: string;
|
|
61
67
|
load: () => Promise<MarkdownProps>;
|
|
62
68
|
};
|
|
63
69
|
interface RuntimeAsync {
|
|
64
|
-
doc: <C>(files:
|
|
70
|
+
doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends {
|
|
65
71
|
type: 'doc';
|
|
66
72
|
_type: {
|
|
67
73
|
schema: infer Schema extends StandardSchemaV1;
|
|
68
74
|
};
|
|
69
75
|
} ? AsyncDocOut<Schema>[] : never;
|
|
70
|
-
docs: <C>(docs:
|
|
76
|
+
docs: <C>(docs: AsyncRuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => C extends {
|
|
71
77
|
type: 'docs';
|
|
72
78
|
docs: {
|
|
73
79
|
type: 'doc';
|
|
@@ -91,4 +97,4 @@ interface RuntimeAsync {
|
|
|
91
97
|
} : never;
|
|
92
98
|
}
|
|
93
99
|
|
|
94
|
-
export type { LoadedConfig as L, Runtime as R,
|
|
100
|
+
export type { LoadedConfig as L, Runtime as R, RuntimeAsync as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DocCollection,
|
|
1
|
+
import { D as DocCollection, M as MetaCollection, a as DocsCollection, G as GlobalConfig, F as FileInfo, b as MarkdownProps, B as BaseCollectionEntry } from './define-BaW0PQDJ.js';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
import { Source, PageData, MetaData } from 'fumadocs-core/source';
|
|
4
4
|
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
@@ -19,6 +19,11 @@ interface RuntimeFile {
|
|
|
19
19
|
info: FileInfo;
|
|
20
20
|
data: Record<string, unknown>;
|
|
21
21
|
}
|
|
22
|
+
interface AsyncRuntimeFile {
|
|
23
|
+
info: FileInfo;
|
|
24
|
+
data: Record<string, unknown>;
|
|
25
|
+
content: string;
|
|
26
|
+
}
|
|
22
27
|
type DocOut<Schema extends StandardSchemaV1> = Omit<MarkdownProps, keyof StandardSchemaV1.InferOutput<Schema>> & StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
|
|
23
28
|
type MetaOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
|
|
24
29
|
interface Runtime {
|
|
@@ -58,16 +63,17 @@ interface Runtime {
|
|
|
58
63
|
} : never;
|
|
59
64
|
}
|
|
60
65
|
type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
|
|
66
|
+
content: string;
|
|
61
67
|
load: () => Promise<MarkdownProps>;
|
|
62
68
|
};
|
|
63
69
|
interface RuntimeAsync {
|
|
64
|
-
doc: <C>(files:
|
|
70
|
+
doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends {
|
|
65
71
|
type: 'doc';
|
|
66
72
|
_type: {
|
|
67
73
|
schema: infer Schema extends StandardSchemaV1;
|
|
68
74
|
};
|
|
69
75
|
} ? AsyncDocOut<Schema>[] : never;
|
|
70
|
-
docs: <C>(docs:
|
|
76
|
+
docs: <C>(docs: AsyncRuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => C extends {
|
|
71
77
|
type: 'docs';
|
|
72
78
|
docs: {
|
|
73
79
|
type: 'doc';
|
|
@@ -91,4 +97,4 @@ interface RuntimeAsync {
|
|
|
91
97
|
} : never;
|
|
92
98
|
}
|
|
93
99
|
|
|
94
|
-
export type { LoadedConfig as L, Runtime as R,
|
|
100
|
+
export type { LoadedConfig as L, Runtime as R, RuntimeAsync as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.6.0",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -47,10 +47,11 @@
|
|
|
47
47
|
"chokidar": "^4.0.3",
|
|
48
48
|
"cross-spawn": "^7.0.6",
|
|
49
49
|
"esbuild": "^0.25.2",
|
|
50
|
-
"estree-util-value-to-estree": "^3.3.
|
|
50
|
+
"estree-util-value-to-estree": "^3.3.3",
|
|
51
51
|
"fast-glob": "^3.3.3",
|
|
52
52
|
"gray-matter": "^4.0.3",
|
|
53
53
|
"lru-cache": "^11.1.0",
|
|
54
|
+
"picocolors": "^1.1.1",
|
|
54
55
|
"unist-util-visit": "^5.0.0",
|
|
55
56
|
"zod": "^3.24.2"
|
|
56
57
|
},
|
|
@@ -60,19 +61,19 @@
|
|
|
60
61
|
"@types/mdx": "^2.0.13",
|
|
61
62
|
"@types/react": "^19.1.0",
|
|
62
63
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
63
|
-
"next": "^15.
|
|
64
|
+
"next": "^15.3.0",
|
|
64
65
|
"unified": "^11.0.5",
|
|
65
66
|
"vfile": "^6.0.3",
|
|
66
|
-
"webpack": "^5.
|
|
67
|
+
"webpack": "^5.99.5",
|
|
67
68
|
"@fumadocs/mdx-remote": "1.3.0",
|
|
68
69
|
"eslint-config-custom": "0.0.0",
|
|
69
|
-
"fumadocs-core": "15.2.
|
|
70
|
+
"fumadocs-core": "15.2.7",
|
|
70
71
|
"tsconfig": "0.0.0"
|
|
71
72
|
},
|
|
72
73
|
"peerDependencies": {
|
|
73
74
|
"@fumadocs/mdx-remote": "^1.2.0",
|
|
74
75
|
"fumadocs-core": "^14.0.0 || ^15.0.0",
|
|
75
|
-
"next": "
|
|
76
|
+
"next": "^15.3.0"
|
|
76
77
|
},
|
|
77
78
|
"peerDependenciesMeta": {
|
|
78
79
|
"@fumadocs/mdx-remote": {
|