fumadocs-mdx 14.0.0 → 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 +270 -201
- package/dist/bun/index.cjs +63 -28
- package/dist/bun/index.d.cts +7 -1
- package/dist/bun/index.d.ts +7 -1
- package/dist/bun/index.js +6 -5
- package/dist/{chunk-5YXP7JLN.js → chunk-5OBUOALK.js} +8 -5
- package/dist/{chunk-XHJCLBZ4.js → chunk-7UKSZSPY.js} +87 -162
- package/dist/{chunk-7L2KNF6B.js → chunk-BEBCWQC7.js} +51 -7
- package/dist/{chunk-5UMZCWKV.js → chunk-IQGEFL2B.js} +1 -1
- package/dist/{chunk-SRSRFOVI.js → chunk-K6HCOGOX.js} +3 -3
- package/dist/{chunk-OXSRIWQW.js → chunk-MTTISKQJ.js} +3 -2
- package/dist/chunk-WBIHDYMN.js +126 -0
- package/dist/config/index.d.cts +6 -1
- package/dist/config/index.d.ts +6 -1
- package/dist/{index-D7JdSMpp.d.cts → core-B9ZoS6sA.d.ts} +73 -4
- package/dist/{index-D7JdSMpp.d.ts → core-DTuP23zu.d.cts} +73 -4
- package/dist/{index-BlVBvy-z.d.ts → index-BD8Woo4m.d.cts} +1 -1
- package/dist/{index-P2NNUkHn.d.cts → index-CNOvhtOn.d.ts} +1 -1
- package/dist/index.d.cts +56 -3
- package/dist/index.d.ts +56 -3
- package/dist/{load-from-file-I3ALLIVB.js → load-from-file-5HUQN36V.js} +1 -1
- package/dist/next/index.cjs +260 -192
- package/dist/next/index.d.cts +7 -2
- package/dist/next/index.d.ts +7 -2
- package/dist/next/index.js +10 -8
- package/dist/node/loader.cjs +72 -37
- package/dist/node/loader.js +3 -3
- package/dist/plugins/index-file.cjs +69 -45
- package/dist/plugins/index-file.d.cts +7 -22
- package/dist/plugins/index-file.d.ts +7 -22
- package/dist/plugins/index-file.js +2 -2
- package/dist/plugins/json-schema.d.cts +7 -1
- package/dist/plugins/json-schema.d.ts +7 -1
- package/dist/plugins/last-modified.cjs +41 -6
- package/dist/plugins/last-modified.d.cts +11 -1
- package/dist/plugins/last-modified.d.ts +11 -1
- package/dist/plugins/last-modified.js +34 -4
- package/dist/runtime/browser.cjs +7 -8
- package/dist/runtime/browser.d.cts +22 -19
- package/dist/runtime/browser.d.ts +22 -19
- package/dist/runtime/browser.js +5 -6
- package/dist/runtime/dynamic.cjs +81 -43
- package/dist/runtime/dynamic.d.cts +12 -12
- package/dist/runtime/dynamic.d.ts +12 -12
- package/dist/runtime/dynamic.js +9 -8
- package/dist/runtime/server.cjs +9 -6
- package/dist/runtime/server.d.cts +10 -157
- package/dist/runtime/server.d.ts +10 -157
- package/dist/runtime/server.js +3 -3
- 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 +257 -190
- package/dist/vite/index.d.cts +7 -2
- package/dist/vite/index.d.ts +7 -2
- package/dist/vite/index.js +7 -6
- package/dist/webpack/mdx.cjs +60 -25
- package/dist/webpack/mdx.d.cts +8 -2
- package/dist/webpack/mdx.d.ts +8 -2
- package/dist/webpack/mdx.js +4 -4
- package/dist/webpack/meta.cjs +60 -25
- package/dist/webpack/meta.d.cts +8 -2
- package/dist/webpack/meta.d.ts +8 -2
- package/dist/webpack/meta.js +4 -4
- package/package.json +2 -2
- package/dist/chunk-PKI7ZDA5.js +0 -29
|
@@ -33,19 +33,54 @@ __export(last_modified_exports, {
|
|
|
33
33
|
default: () => lastModified
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(last_modified_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
37
37
|
var import_tinyexec = require("tinyexec");
|
|
38
|
+
|
|
39
|
+
// src/utils/codegen.ts
|
|
40
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
41
|
+
var import_tinyglobby = require("tinyglobby");
|
|
42
|
+
function ident(code, tab = 1) {
|
|
43
|
+
return code.split("\n").map((v) => " ".repeat(tab) + v).join("\n");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/plugins/last-modified.ts
|
|
38
47
|
var cache = /* @__PURE__ */ new Map();
|
|
48
|
+
var ExtendTypes = `{
|
|
49
|
+
/**
|
|
50
|
+
* Last modified date of document file, obtained from version control.
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
lastModified?: Date;
|
|
54
|
+
}`;
|
|
39
55
|
function lastModified(options = {}) {
|
|
40
|
-
const { versionControl = "git" } = options;
|
|
56
|
+
const { versionControl = "git", filter = () => true } = options;
|
|
41
57
|
return {
|
|
42
58
|
name: "last-modified",
|
|
59
|
+
"index-file": {
|
|
60
|
+
generateTypeConfig() {
|
|
61
|
+
const lines = [];
|
|
62
|
+
lines.push("{");
|
|
63
|
+
lines.push(" DocData: {");
|
|
64
|
+
for (const collection of this.core.getConfig().collectionList) {
|
|
65
|
+
if (filter(collection.name)) {
|
|
66
|
+
lines.push(ident(`${collection.name}: ${ExtendTypes},`, 2));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
lines.push(" }");
|
|
70
|
+
lines.push("}");
|
|
71
|
+
return lines.join("\n");
|
|
72
|
+
},
|
|
73
|
+
serverOptions(options2) {
|
|
74
|
+
options2.doc ??= {};
|
|
75
|
+
options2.doc.passthroughs ??= [];
|
|
76
|
+
options2.doc.passthroughs.push("lastModified");
|
|
77
|
+
}
|
|
78
|
+
},
|
|
43
79
|
doc: {
|
|
44
80
|
async vfile(file) {
|
|
81
|
+
if (!filter(this.collection.name)) return;
|
|
45
82
|
if (versionControl === "git") {
|
|
46
|
-
const timestamp = await getGitTimestamp(this.filePath)
|
|
47
|
-
(v) => v?.getTime()
|
|
48
|
-
);
|
|
83
|
+
const timestamp = await getGitTimestamp(this.filePath);
|
|
49
84
|
if (timestamp === void 0) return;
|
|
50
85
|
file.data["mdx-export"] ??= [];
|
|
51
86
|
file.data["mdx-export"].push({
|
|
@@ -63,7 +98,7 @@ async function getGitTimestamp(file) {
|
|
|
63
98
|
const timePromise = (async () => {
|
|
64
99
|
const out = await (0, import_tinyexec.x)(
|
|
65
100
|
"git",
|
|
66
|
-
["log", "-1", '--pretty="%ai"',
|
|
101
|
+
["log", "-1", '--pretty="%ai"', import_node_path2.default.relative(process.cwd(), file)],
|
|
67
102
|
{
|
|
68
103
|
throwOnError: true
|
|
69
104
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as Plugin } from '../
|
|
1
|
+
import { j as Plugin } from '../core-DTuP23zu.cjs';
|
|
2
2
|
import '@mdx-js/mdx';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import 'unified';
|
|
@@ -6,6 +6,12 @@ import 'fumadocs-core/mdx-plugins';
|
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'chokidar';
|
|
8
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';
|
|
9
15
|
|
|
10
16
|
interface LastModifiedPluginOptions {
|
|
11
17
|
/**
|
|
@@ -18,6 +24,10 @@ interface LastModifiedPluginOptions {
|
|
|
18
24
|
* @defaultValue 'git'
|
|
19
25
|
*/
|
|
20
26
|
versionControl?: 'git';
|
|
27
|
+
/**
|
|
28
|
+
* Filter the collections to include by names
|
|
29
|
+
*/
|
|
30
|
+
filter?: (collection: string) => boolean;
|
|
21
31
|
}
|
|
22
32
|
/**
|
|
23
33
|
* Injects `lastModified` property to page exports.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as Plugin } from '../
|
|
1
|
+
import { j as Plugin } from '../core-B9ZoS6sA.js';
|
|
2
2
|
import '@mdx-js/mdx';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import 'unified';
|
|
@@ -6,6 +6,12 @@ import 'fumadocs-core/mdx-plugins';
|
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'chokidar';
|
|
8
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';
|
|
9
15
|
|
|
10
16
|
interface LastModifiedPluginOptions {
|
|
11
17
|
/**
|
|
@@ -18,6 +24,10 @@ interface LastModifiedPluginOptions {
|
|
|
18
24
|
* @defaultValue 'git'
|
|
19
25
|
*/
|
|
20
26
|
versionControl?: 'git';
|
|
27
|
+
/**
|
|
28
|
+
* Filter the collections to include by names
|
|
29
|
+
*/
|
|
30
|
+
filter?: (collection: string) => boolean;
|
|
21
31
|
}
|
|
22
32
|
/**
|
|
23
33
|
* Injects `lastModified` property to page exports.
|
|
@@ -1,17 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ident
|
|
3
|
+
} from "../chunk-WBIHDYMN.js";
|
|
4
|
+
|
|
1
5
|
// src/plugins/last-modified.ts
|
|
2
6
|
import path from "path";
|
|
3
7
|
import { x } from "tinyexec";
|
|
4
8
|
var cache = /* @__PURE__ */ new Map();
|
|
9
|
+
var ExtendTypes = `{
|
|
10
|
+
/**
|
|
11
|
+
* Last modified date of document file, obtained from version control.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
lastModified?: Date;
|
|
15
|
+
}`;
|
|
5
16
|
function lastModified(options = {}) {
|
|
6
|
-
const { versionControl = "git" } = options;
|
|
17
|
+
const { versionControl = "git", filter = () => true } = options;
|
|
7
18
|
return {
|
|
8
19
|
name: "last-modified",
|
|
20
|
+
"index-file": {
|
|
21
|
+
generateTypeConfig() {
|
|
22
|
+
const lines = [];
|
|
23
|
+
lines.push("{");
|
|
24
|
+
lines.push(" DocData: {");
|
|
25
|
+
for (const collection of this.core.getConfig().collectionList) {
|
|
26
|
+
if (filter(collection.name)) {
|
|
27
|
+
lines.push(ident(`${collection.name}: ${ExtendTypes},`, 2));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
lines.push(" }");
|
|
31
|
+
lines.push("}");
|
|
32
|
+
return lines.join("\n");
|
|
33
|
+
},
|
|
34
|
+
serverOptions(options2) {
|
|
35
|
+
options2.doc ??= {};
|
|
36
|
+
options2.doc.passthroughs ??= [];
|
|
37
|
+
options2.doc.passthroughs.push("lastModified");
|
|
38
|
+
}
|
|
39
|
+
},
|
|
9
40
|
doc: {
|
|
10
41
|
async vfile(file) {
|
|
42
|
+
if (!filter(this.collection.name)) return;
|
|
11
43
|
if (versionControl === "git") {
|
|
12
|
-
const timestamp = await getGitTimestamp(this.filePath)
|
|
13
|
-
(v) => v?.getTime()
|
|
14
|
-
);
|
|
44
|
+
const timestamp = await getGitTimestamp(this.filePath);
|
|
15
45
|
if (timestamp === void 0) return;
|
|
16
46
|
file.data["mdx-export"] ??= [];
|
|
17
47
|
file.data["mdx-export"].push({
|
package/dist/runtime/browser.cjs
CHANGED
|
@@ -20,19 +20,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/runtime/browser.ts
|
|
21
21
|
var browser_exports = {};
|
|
22
22
|
__export(browser_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
browser: () => browser,
|
|
24
|
+
createClientLoader: () => createClientLoader
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(browser_exports);
|
|
27
27
|
var import_react = require("react");
|
|
28
|
-
function
|
|
28
|
+
function browser() {
|
|
29
29
|
return {
|
|
30
30
|
doc(_name, glob) {
|
|
31
|
-
const raw = glob;
|
|
32
31
|
const out = {
|
|
33
|
-
raw,
|
|
32
|
+
raw: glob,
|
|
34
33
|
createClientLoader({ id = _name, ...options }) {
|
|
35
|
-
return createClientLoader(raw, { id, ...options });
|
|
34
|
+
return createClientLoader(this.raw, { id, ...options });
|
|
36
35
|
}
|
|
37
36
|
};
|
|
38
37
|
return out;
|
|
@@ -89,6 +88,6 @@ function createClientLoader(globEntries, options) {
|
|
|
89
88
|
}
|
|
90
89
|
// Annotate the CommonJS export names for ESM import in node:
|
|
91
90
|
0 && (module.exports = {
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
browser,
|
|
92
|
+
createClientLoader
|
|
94
93
|
});
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { ReactNode, FC } from 'react';
|
|
2
|
-
import { CompiledMDXFile } from './server.cjs';
|
|
3
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
|
-
import { D as DocCollection,
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
7
|
-
import 'fumadocs-core/toc';
|
|
8
|
-
import 'mdx/types';
|
|
9
|
-
import 'mdast';
|
|
3
|
+
import { D as DocCollection, a as DocsCollection } from '../core-DTuP23zu.cjs';
|
|
4
|
+
import { CompiledMDXProperties } from '../index.cjs';
|
|
5
|
+
import { InternalTypeConfig } from './types.cjs';
|
|
10
6
|
import '@mdx-js/mdx';
|
|
11
7
|
import 'unified';
|
|
8
|
+
import 'fumadocs-core/mdx-plugins';
|
|
12
9
|
import 'zod';
|
|
13
10
|
import 'chokidar';
|
|
14
11
|
import 'vfile';
|
|
12
|
+
import 'fumadocs-core/source';
|
|
13
|
+
import 'fumadocs-core/toc';
|
|
14
|
+
import 'mdx/types';
|
|
15
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
16
|
+
import 'mdast';
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
type CompiledMDXFile<Name extends string, Frontmatter, TC extends InternalTypeConfig> = CompiledMDXProperties<Frontmatter> & TC['DocData'][Name] & Record<string, unknown>;
|
|
19
|
+
interface ClientLoaderOptions<Doc, Props> {
|
|
17
20
|
/**
|
|
18
21
|
* Loader ID (usually your collection name)
|
|
19
22
|
*
|
|
@@ -24,10 +27,10 @@ interface ClientLoaderOptions<Frontmatter, Props> {
|
|
|
24
27
|
* @defaultValue ''
|
|
25
28
|
*/
|
|
26
29
|
id?: string;
|
|
27
|
-
component: (loaded:
|
|
30
|
+
component: (loaded: Doc, props: Props) => ReactNode;
|
|
28
31
|
}
|
|
29
|
-
interface ClientLoader<
|
|
30
|
-
preload: (path: string) => Promise<
|
|
32
|
+
interface ClientLoader<Doc, Props> {
|
|
33
|
+
preload: (path: string) => Promise<Doc>;
|
|
31
34
|
/**
|
|
32
35
|
* Get a component that renders content with `React.lazy`.
|
|
33
36
|
*/
|
|
@@ -37,14 +40,14 @@ interface ClientLoader<Frontmatter, Props> {
|
|
|
37
40
|
*/
|
|
38
41
|
useContent: (path: string, props: Props) => ReactNode;
|
|
39
42
|
}
|
|
40
|
-
type BrowserCreate<Config> = ReturnType<typeof
|
|
41
|
-
interface DocCollectionEntry<Frontmatter> {
|
|
42
|
-
raw: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>;
|
|
43
|
-
createClientLoader: <Props extends object>(options: ClientLoaderOptions<Frontmatter, Props>) => ClientLoader<Frontmatter, Props>;
|
|
43
|
+
type BrowserCreate<Config, TC extends InternalTypeConfig> = ReturnType<typeof browser<Config, TC>>;
|
|
44
|
+
interface DocCollectionEntry<Name extends string = string, Frontmatter = unknown, TC extends InternalTypeConfig = InternalTypeConfig> {
|
|
45
|
+
raw: Record<string, () => Promise<CompiledMDXFile<Name, Frontmatter, TC>>>;
|
|
46
|
+
createClientLoader: <Props extends object>(options: ClientLoaderOptions<CompiledMDXFile<Name, Frontmatter, TC>, Props>) => ClientLoader<CompiledMDXFile<Name, Frontmatter, TC>, Props>;
|
|
44
47
|
}
|
|
45
|
-
declare function
|
|
46
|
-
doc<Name extends keyof Config>(_name: Name, glob: Record<string, () => Promise<unknown>>): Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? DocCollectionEntry<StandardSchemaV1.InferOutput<Schema
|
|
48
|
+
declare function browser<Config, TC extends InternalTypeConfig>(): {
|
|
49
|
+
doc<Name extends keyof Config & string>(_name: Name, glob: Record<string, () => Promise<unknown>>): Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? DocCollectionEntry<Name, StandardSchemaV1.InferOutput<Schema>, TC> : never;
|
|
47
50
|
};
|
|
48
|
-
declare function createClientLoader<
|
|
51
|
+
declare function createClientLoader<Doc = CompiledMDXProperties, Props extends object = object>(globEntries: Record<string, () => Promise<Doc>>, options: ClientLoaderOptions<Doc, Props>): ClientLoader<Doc, Props>;
|
|
49
52
|
|
|
50
|
-
export { type BrowserCreate, type ClientLoader, type ClientLoaderOptions, type DocCollectionEntry,
|
|
53
|
+
export { type BrowserCreate, type ClientLoader, type ClientLoaderOptions, type DocCollectionEntry, browser, createClientLoader };
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { ReactNode, FC } from 'react';
|
|
2
|
-
import { CompiledMDXFile } from './server.js';
|
|
3
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
|
-
import { D as DocCollection,
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
7
|
-
import 'fumadocs-core/toc';
|
|
8
|
-
import 'mdx/types';
|
|
9
|
-
import 'mdast';
|
|
3
|
+
import { D as DocCollection, a as DocsCollection } from '../core-B9ZoS6sA.js';
|
|
4
|
+
import { CompiledMDXProperties } from '../index.js';
|
|
5
|
+
import { InternalTypeConfig } from './types.js';
|
|
10
6
|
import '@mdx-js/mdx';
|
|
11
7
|
import 'unified';
|
|
8
|
+
import 'fumadocs-core/mdx-plugins';
|
|
12
9
|
import 'zod';
|
|
13
10
|
import 'chokidar';
|
|
14
11
|
import 'vfile';
|
|
12
|
+
import 'fumadocs-core/source';
|
|
13
|
+
import 'fumadocs-core/toc';
|
|
14
|
+
import 'mdx/types';
|
|
15
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
16
|
+
import 'mdast';
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
type CompiledMDXFile<Name extends string, Frontmatter, TC extends InternalTypeConfig> = CompiledMDXProperties<Frontmatter> & TC['DocData'][Name] & Record<string, unknown>;
|
|
19
|
+
interface ClientLoaderOptions<Doc, Props> {
|
|
17
20
|
/**
|
|
18
21
|
* Loader ID (usually your collection name)
|
|
19
22
|
*
|
|
@@ -24,10 +27,10 @@ interface ClientLoaderOptions<Frontmatter, Props> {
|
|
|
24
27
|
* @defaultValue ''
|
|
25
28
|
*/
|
|
26
29
|
id?: string;
|
|
27
|
-
component: (loaded:
|
|
30
|
+
component: (loaded: Doc, props: Props) => ReactNode;
|
|
28
31
|
}
|
|
29
|
-
interface ClientLoader<
|
|
30
|
-
preload: (path: string) => Promise<
|
|
32
|
+
interface ClientLoader<Doc, Props> {
|
|
33
|
+
preload: (path: string) => Promise<Doc>;
|
|
31
34
|
/**
|
|
32
35
|
* Get a component that renders content with `React.lazy`.
|
|
33
36
|
*/
|
|
@@ -37,14 +40,14 @@ interface ClientLoader<Frontmatter, Props> {
|
|
|
37
40
|
*/
|
|
38
41
|
useContent: (path: string, props: Props) => ReactNode;
|
|
39
42
|
}
|
|
40
|
-
type BrowserCreate<Config> = ReturnType<typeof
|
|
41
|
-
interface DocCollectionEntry<Frontmatter> {
|
|
42
|
-
raw: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>;
|
|
43
|
-
createClientLoader: <Props extends object>(options: ClientLoaderOptions<Frontmatter, Props>) => ClientLoader<Frontmatter, Props>;
|
|
43
|
+
type BrowserCreate<Config, TC extends InternalTypeConfig> = ReturnType<typeof browser<Config, TC>>;
|
|
44
|
+
interface DocCollectionEntry<Name extends string = string, Frontmatter = unknown, TC extends InternalTypeConfig = InternalTypeConfig> {
|
|
45
|
+
raw: Record<string, () => Promise<CompiledMDXFile<Name, Frontmatter, TC>>>;
|
|
46
|
+
createClientLoader: <Props extends object>(options: ClientLoaderOptions<CompiledMDXFile<Name, Frontmatter, TC>, Props>) => ClientLoader<CompiledMDXFile<Name, Frontmatter, TC>, Props>;
|
|
44
47
|
}
|
|
45
|
-
declare function
|
|
46
|
-
doc<Name extends keyof Config>(_name: Name, glob: Record<string, () => Promise<unknown>>): Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? DocCollectionEntry<StandardSchemaV1.InferOutput<Schema
|
|
48
|
+
declare function browser<Config, TC extends InternalTypeConfig>(): {
|
|
49
|
+
doc<Name extends keyof Config & string>(_name: Name, glob: Record<string, () => Promise<unknown>>): Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? DocCollectionEntry<Name, StandardSchemaV1.InferOutput<Schema>, TC> : never;
|
|
47
50
|
};
|
|
48
|
-
declare function createClientLoader<
|
|
51
|
+
declare function createClientLoader<Doc = CompiledMDXProperties, Props extends object = object>(globEntries: Record<string, () => Promise<Doc>>, options: ClientLoaderOptions<Doc, Props>): ClientLoader<Doc, Props>;
|
|
49
52
|
|
|
50
|
-
export { type BrowserCreate, type ClientLoader, type ClientLoaderOptions, type DocCollectionEntry,
|
|
53
|
+
export { type BrowserCreate, type ClientLoader, type ClientLoaderOptions, type DocCollectionEntry, browser, createClientLoader };
|
package/dist/runtime/browser.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// src/runtime/browser.ts
|
|
2
2
|
import { lazy, createElement } from "react";
|
|
3
|
-
function
|
|
3
|
+
function browser() {
|
|
4
4
|
return {
|
|
5
5
|
doc(_name, glob) {
|
|
6
|
-
const raw = glob;
|
|
7
6
|
const out = {
|
|
8
|
-
raw,
|
|
7
|
+
raw: glob,
|
|
9
8
|
createClientLoader({ id = _name, ...options }) {
|
|
10
|
-
return createClientLoader(raw, { id, ...options });
|
|
9
|
+
return createClientLoader(this.raw, { id, ...options });
|
|
11
10
|
}
|
|
12
11
|
};
|
|
13
12
|
return out;
|
|
@@ -63,6 +62,6 @@ function createClientLoader(globEntries, options) {
|
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
64
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
browser,
|
|
66
|
+
createClientLoader
|
|
68
67
|
};
|
package/dist/runtime/dynamic.cjs
CHANGED
|
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/runtime/dynamic.ts
|
|
31
31
|
var dynamic_exports = {};
|
|
32
32
|
__export(dynamic_exports, {
|
|
33
|
-
|
|
33
|
+
dynamic: () => dynamic
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(dynamic_exports);
|
|
36
36
|
|
|
@@ -604,11 +604,12 @@ async function buildMDX(core, collection, {
|
|
|
604
604
|
// src/runtime/dynamic.ts
|
|
605
605
|
var import_client = require("@fumadocs/mdx-remote/client");
|
|
606
606
|
var import_node_url = require("url");
|
|
607
|
-
var
|
|
607
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
608
608
|
|
|
609
609
|
// src/runtime/server.ts
|
|
610
610
|
var path2 = __toESM(require("path"), 1);
|
|
611
|
-
function
|
|
611
|
+
function server(options = {}) {
|
|
612
|
+
const { doc: { passthroughs: docPassthroughs = [] } = {} } = options;
|
|
612
613
|
function fileInfo(file, base) {
|
|
613
614
|
if (file.startsWith("./")) {
|
|
614
615
|
file = file.slice(2);
|
|
@@ -619,19 +620,21 @@ function fromConfig() {
|
|
|
619
620
|
};
|
|
620
621
|
}
|
|
621
622
|
function mapDocData(entry) {
|
|
622
|
-
|
|
623
|
+
const data = {
|
|
623
624
|
body: entry.default,
|
|
624
625
|
toc: entry.toc,
|
|
625
|
-
extractedReferences: entry.extractedReferences,
|
|
626
626
|
structuredData: entry.structuredData,
|
|
627
|
-
lastModified: entry.lastModified,
|
|
628
627
|
_exports: entry
|
|
629
628
|
};
|
|
629
|
+
for (const key of docPassthroughs) {
|
|
630
|
+
data[key] = entry[key];
|
|
631
|
+
}
|
|
632
|
+
return data;
|
|
630
633
|
}
|
|
631
634
|
return {
|
|
632
|
-
async doc(_name, base,
|
|
635
|
+
async doc(_name, base, glob2) {
|
|
633
636
|
const out = await Promise.all(
|
|
634
|
-
Object.entries(
|
|
637
|
+
Object.entries(glob2).map(async ([k, v]) => {
|
|
635
638
|
const data = typeof v === "function" ? await v() : v;
|
|
636
639
|
return {
|
|
637
640
|
...mapDocData(data),
|
|
@@ -658,9 +661,9 @@ function fromConfig() {
|
|
|
658
661
|
);
|
|
659
662
|
return out;
|
|
660
663
|
},
|
|
661
|
-
async meta(_name, base,
|
|
664
|
+
async meta(_name, base, glob2) {
|
|
662
665
|
const out = await Promise.all(
|
|
663
|
-
Object.entries(
|
|
666
|
+
Object.entries(glob2).map(async ([k, v]) => {
|
|
664
667
|
const data = typeof v === "function" ? await v() : v;
|
|
665
668
|
return {
|
|
666
669
|
info: fileInfo(k, base),
|
|
@@ -719,8 +722,8 @@ function createDocMethods(info, load2) {
|
|
|
719
722
|
info,
|
|
720
723
|
async getText(type) {
|
|
721
724
|
if (type === "raw") {
|
|
722
|
-
const
|
|
723
|
-
return (await
|
|
725
|
+
const fs4 = await import("fs/promises");
|
|
726
|
+
return (await fs4.readFile(info.fullPath)).toString();
|
|
724
727
|
}
|
|
725
728
|
const data = await load2();
|
|
726
729
|
if (typeof data._markdown !== "string")
|
|
@@ -742,24 +745,7 @@ function createDocMethods(info, load2) {
|
|
|
742
745
|
|
|
743
746
|
// src/core.ts
|
|
744
747
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
745
|
-
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
746
|
-
|
|
747
|
-
// src/utils/codegen/cache.ts
|
|
748
|
-
var import_lru_cache = require("lru-cache");
|
|
749
748
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
750
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
751
|
-
var map = new import_lru_cache.LRUCache({
|
|
752
|
-
max: 100
|
|
753
|
-
});
|
|
754
|
-
function toFullPath(file) {
|
|
755
|
-
if (import_node_path.default.isAbsolute(file)) {
|
|
756
|
-
return import_node_path.default.relative(process.cwd(), file);
|
|
757
|
-
}
|
|
758
|
-
return file;
|
|
759
|
-
}
|
|
760
|
-
function removeFileCache(file) {
|
|
761
|
-
map.delete(toFullPath(file));
|
|
762
|
-
}
|
|
763
749
|
|
|
764
750
|
// src/utils/validation.ts
|
|
765
751
|
var ValidationError = class extends Error {
|
|
@@ -799,6 +785,13 @@ async function validate(schema, data, context, errorMessage) {
|
|
|
799
785
|
return data;
|
|
800
786
|
}
|
|
801
787
|
|
|
788
|
+
// src/utils/codegen.ts
|
|
789
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
790
|
+
var import_tinyglobby = require("tinyglobby");
|
|
791
|
+
function ident(code, tab = 1) {
|
|
792
|
+
return code.split("\n").map((v) => " ".repeat(tab) + v).join("\n");
|
|
793
|
+
}
|
|
794
|
+
|
|
802
795
|
// src/core.ts
|
|
803
796
|
async function getPlugins(pluginOptions) {
|
|
804
797
|
const plugins = [];
|
|
@@ -828,7 +821,6 @@ function createCore(options, defaultPlugins = []) {
|
|
|
828
821
|
return data;
|
|
829
822
|
}
|
|
830
823
|
const core = {
|
|
831
|
-
_options: options,
|
|
832
824
|
/**
|
|
833
825
|
* Convenient cache store, reset when config changes
|
|
834
826
|
*/
|
|
@@ -837,6 +829,7 @@ function createCore(options, defaultPlugins = []) {
|
|
|
837
829
|
config = await newConfig;
|
|
838
830
|
this.cache.clear();
|
|
839
831
|
plugins = await getPlugins([
|
|
832
|
+
postprocessPlugin(),
|
|
840
833
|
...defaultPlugins,
|
|
841
834
|
...config.global.plugins ?? []
|
|
842
835
|
]);
|
|
@@ -844,7 +837,9 @@ function createCore(options, defaultPlugins = []) {
|
|
|
844
837
|
const out = await plugin.config?.call(pluginContext, config);
|
|
845
838
|
if (out) config = out;
|
|
846
839
|
}
|
|
847
|
-
|
|
840
|
+
},
|
|
841
|
+
getOptions() {
|
|
842
|
+
return options;
|
|
848
843
|
},
|
|
849
844
|
getConfig() {
|
|
850
845
|
return config;
|
|
@@ -855,12 +850,15 @@ function createCore(options, defaultPlugins = []) {
|
|
|
855
850
|
getCompiledConfigPath() {
|
|
856
851
|
return import_node_path2.default.join(options.outDir, "source.config.mjs");
|
|
857
852
|
},
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
853
|
+
getPlugins() {
|
|
854
|
+
return plugins;
|
|
855
|
+
},
|
|
856
|
+
getPluginContext() {
|
|
857
|
+
return pluginContext;
|
|
858
|
+
},
|
|
859
|
+
async initServer(server2) {
|
|
862
860
|
for (const plugin of plugins) {
|
|
863
|
-
await plugin.configureServer?.call(pluginContext,
|
|
861
|
+
await plugin.configureServer?.call(pluginContext, server2);
|
|
864
862
|
}
|
|
865
863
|
},
|
|
866
864
|
async emit({ filterPlugin = () => true } = {}) {
|
|
@@ -877,8 +875,8 @@ function createCore(options, defaultPlugins = []) {
|
|
|
877
875
|
await Promise.all(
|
|
878
876
|
out.map(async (entry) => {
|
|
879
877
|
const file = import_node_path2.default.join(options.outDir, entry.path);
|
|
880
|
-
await
|
|
881
|
-
await
|
|
878
|
+
await import_promises.default.mkdir(import_node_path2.default.dirname(file), { recursive: true });
|
|
879
|
+
await import_promises.default.writeFile(file, entry.content);
|
|
882
880
|
})
|
|
883
881
|
);
|
|
884
882
|
console.log(`[MDX] generated files in ${performance.now() - start}ms`);
|
|
@@ -925,13 +923,53 @@ function createCore(options, defaultPlugins = []) {
|
|
|
925
923
|
};
|
|
926
924
|
return core;
|
|
927
925
|
}
|
|
926
|
+
function postprocessPlugin() {
|
|
927
|
+
const LinkReferenceTypes = `{
|
|
928
|
+
/**
|
|
929
|
+
* extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.
|
|
930
|
+
*/
|
|
931
|
+
extractedReferences?: import('fumadocs-mdx').ExtractedReference[];
|
|
932
|
+
}`;
|
|
933
|
+
return {
|
|
934
|
+
"index-file": {
|
|
935
|
+
generateTypeConfig() {
|
|
936
|
+
const lines = [];
|
|
937
|
+
lines.push("{");
|
|
938
|
+
lines.push(" DocData: {");
|
|
939
|
+
for (const collection of this.core.getConfig().collectionList) {
|
|
940
|
+
let postprocessOptions;
|
|
941
|
+
switch (collection.type) {
|
|
942
|
+
case "doc":
|
|
943
|
+
postprocessOptions = collection.postprocess;
|
|
944
|
+
break;
|
|
945
|
+
case "docs":
|
|
946
|
+
postprocessOptions = collection.docs.postprocess;
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
if (postprocessOptions?.extractLinkReferences) {
|
|
950
|
+
lines.push(ident(`${collection.name}: ${LinkReferenceTypes},`, 2));
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
lines.push(" }");
|
|
954
|
+
lines.push("}");
|
|
955
|
+
return lines.join("\n");
|
|
956
|
+
},
|
|
957
|
+
serverOptions(options) {
|
|
958
|
+
options.doc ??= {};
|
|
959
|
+
options.doc.passthroughs ??= [];
|
|
960
|
+
options.doc.passthroughs.push("extractedReferences");
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
}
|
|
928
965
|
|
|
929
966
|
// src/runtime/dynamic.ts
|
|
930
|
-
async function
|
|
931
|
-
const core =
|
|
967
|
+
async function dynamic(configExports, coreOptions, serverOptions) {
|
|
968
|
+
const core = createCore(coreOptions);
|
|
969
|
+
await core.init({
|
|
932
970
|
config: buildConfig(configExports)
|
|
933
971
|
});
|
|
934
|
-
const create =
|
|
972
|
+
const create = server(serverOptions);
|
|
935
973
|
function getDocCollection(name) {
|
|
936
974
|
const collection = core.getConfig().getCollection(name);
|
|
937
975
|
if (!collection) return;
|
|
@@ -942,7 +980,7 @@ async function fromConfigDynamic(configExports, coreOptions) {
|
|
|
942
980
|
const head = {};
|
|
943
981
|
const body = {};
|
|
944
982
|
async function compile({ info, data }) {
|
|
945
|
-
let content = (await
|
|
983
|
+
let content = (await import_promises2.default.readFile(info.fullPath)).toString();
|
|
946
984
|
content = fumaMatter(content).content;
|
|
947
985
|
const compiled = await buildMDX(core, collection, {
|
|
948
986
|
filePath: info.fullPath,
|
|
@@ -981,5 +1019,5 @@ async function fromConfigDynamic(configExports, coreOptions) {
|
|
|
981
1019
|
}
|
|
982
1020
|
// Annotate the CommonJS export names for ESM import in node:
|
|
983
1021
|
0 && (module.exports = {
|
|
984
|
-
|
|
1022
|
+
dynamic
|
|
985
1023
|
});
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import * as fumadocs_core_source from 'fumadocs-core/source';
|
|
2
|
-
import {
|
|
3
|
-
import { C as CoreOptions, D as DocCollection, b as DocsCollection } from '../index-D7JdSMpp.cjs';
|
|
2
|
+
import { i as CoreOptions, S as ServerOptions, D as DocCollection, a as DocsCollection, k as AsyncDocCollectionEntry, l as AsyncDocsCollectionEntry } from '../core-DTuP23zu.cjs';
|
|
4
3
|
import * as _standard_schema_spec from '@standard-schema/spec';
|
|
5
|
-
import '
|
|
6
|
-
import 'fumadocs-core/toc';
|
|
7
|
-
import 'mdx/types';
|
|
8
|
-
import 'mdast';
|
|
4
|
+
import { FileInfo, InternalTypeConfig } from './types.cjs';
|
|
9
5
|
import '@mdx-js/mdx';
|
|
10
|
-
import 'react';
|
|
11
6
|
import 'unified';
|
|
7
|
+
import 'fumadocs-core/mdx-plugins';
|
|
12
8
|
import 'zod';
|
|
13
9
|
import 'chokidar';
|
|
14
10
|
import 'vfile';
|
|
11
|
+
import 'fumadocs-core/mdx-plugins/remark-structure';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdx/types';
|
|
15
15
|
|
|
16
16
|
interface LazyEntry<Data = unknown> {
|
|
17
17
|
info: FileInfo;
|
|
18
18
|
data: Data;
|
|
19
19
|
hash?: string;
|
|
20
20
|
}
|
|
21
|
-
type CreateDynamic<Config> = ReturnType<typeof
|
|
22
|
-
declare function
|
|
23
|
-
doc<Name extends keyof Config>(name: Name, base: string, entries: LazyEntry<unknown>[]): Promise<Config[Name] extends DocCollection<infer Schema extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>> | DocsCollection<infer Schema extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>, _standard_schema_spec.StandardSchemaV1<unknown, unknown>> ? AsyncDocCollectionEntry<_standard_schema_spec.StandardSchemaV1.InferOutput<Schema
|
|
24
|
-
docs<Name extends keyof Config>(name: Name, base: string, meta: Record<string, unknown>, entries: LazyEntry<unknown>[]): Promise<Config[Name] extends DocsCollection<infer Page extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>, infer Meta extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>> ? _standard_schema_spec.StandardSchemaV1.InferOutput<Page> extends fumadocs_core_source.PageData ? _standard_schema_spec.StandardSchemaV1.InferOutput<Meta> extends fumadocs_core_source.MetaData ? AsyncDocsCollectionEntry<_standard_schema_spec.StandardSchemaV1.InferOutput<Page>, _standard_schema_spec.StandardSchemaV1.InferOutput<Meta
|
|
21
|
+
type CreateDynamic<Config, TC extends InternalTypeConfig = InternalTypeConfig> = ReturnType<typeof dynamic<Config, TC>>;
|
|
22
|
+
declare function dynamic<Config, TC extends InternalTypeConfig>(configExports: Config, coreOptions: CoreOptions, serverOptions?: ServerOptions): Promise<{
|
|
23
|
+
doc<Name extends keyof Config & string>(name: Name, base: string, entries: LazyEntry<unknown>[]): Promise<Config[Name] extends DocCollection<infer Schema extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>> | DocsCollection<infer Schema extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>, _standard_schema_spec.StandardSchemaV1<unknown, unknown>> ? AsyncDocCollectionEntry<Name, _standard_schema_spec.StandardSchemaV1.InferOutput<Schema>, TC>[] : never>;
|
|
24
|
+
docs<Name extends keyof Config & string>(name: Name, base: string, meta: Record<string, unknown>, entries: LazyEntry<unknown>[]): Promise<Config[Name] extends DocsCollection<infer Page extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>, infer Meta extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>> ? _standard_schema_spec.StandardSchemaV1.InferOutput<Page> extends fumadocs_core_source.PageData ? _standard_schema_spec.StandardSchemaV1.InferOutput<Meta> extends fumadocs_core_source.MetaData ? AsyncDocsCollectionEntry<Name, _standard_schema_spec.StandardSchemaV1.InferOutput<Page>, _standard_schema_spec.StandardSchemaV1.InferOutput<Meta>, TC> : never : never : never>;
|
|
25
25
|
}>;
|
|
26
26
|
|
|
27
|
-
export { type CreateDynamic, type LazyEntry,
|
|
27
|
+
export { type CreateDynamic, type LazyEntry, dynamic };
|