fumadocs-mdx 11.3.2 → 11.4.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/{build-mdx-TJcSpR7K.d.cts → build-mdx-o0kbHSlp.d.cts} +9 -7
- package/dist/{build-mdx-TJcSpR7K.d.ts → build-mdx-o0kbHSlp.d.ts} +9 -7
- package/dist/chunk-2DJQ3DOD.js +51 -0
- package/dist/{chunk-CQAAQB5I.js → chunk-IOENRFUX.js} +9 -16
- package/dist/{chunk-HPKXUFKR.js → chunk-IU4D6M3A.js} +7 -49
- package/dist/config/index.cjs +9 -8
- package/dist/config/index.d.cts +6 -126
- package/dist/config/index.d.ts +6 -126
- package/dist/config/index.js +1 -1
- package/dist/define-BB9hRiTI.d.cts +106 -0
- package/dist/define-D3l733EX.d.ts +106 -0
- package/dist/index.cjs +27 -42
- package/dist/index.d.cts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +25 -40
- package/dist/loader-mdx.cjs +45 -40
- package/dist/loader-mdx.js +5 -4
- package/dist/{mdx-options-2H42TB7P.js → mdx-options-CAU273O3.js} +1 -1
- package/dist/next/index.cjs +123 -77
- package/dist/next/index.js +79 -37
- package/dist/runtime/async.cjs +310 -0
- package/dist/runtime/async.d.cts +35 -0
- package/dist/runtime/async.d.ts +35 -0
- package/dist/runtime/async.js +54 -0
- package/package.json +16 -5
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z, ZodTypeAny } from 'zod';
|
|
2
|
+
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
3
|
+
import { c as MDXOptions, B as BaseCollectionEntry, M as MarkdownProps, G as GlobalConfig } from './build-mdx-o0kbHSlp.cjs';
|
|
4
|
+
|
|
5
|
+
declare const metaSchema: z.ZodObject<{
|
|
6
|
+
title: z.ZodOptional<z.ZodString>;
|
|
7
|
+
pages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
8
|
+
description: z.ZodOptional<z.ZodString>;
|
|
9
|
+
root: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
defaultOpen: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
root?: boolean | undefined;
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
icon?: string | undefined;
|
|
16
|
+
pages?: string[] | undefined;
|
|
17
|
+
description?: string | undefined;
|
|
18
|
+
defaultOpen?: boolean | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
root?: boolean | undefined;
|
|
21
|
+
title?: string | undefined;
|
|
22
|
+
icon?: string | undefined;
|
|
23
|
+
pages?: string[] | undefined;
|
|
24
|
+
description?: string | undefined;
|
|
25
|
+
defaultOpen?: boolean | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
declare const frontmatterSchema: z.ZodObject<{
|
|
28
|
+
title: z.ZodString;
|
|
29
|
+
description: z.ZodOptional<z.ZodString>;
|
|
30
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
31
|
+
full: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
_openapi: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
title: string;
|
|
35
|
+
icon?: string | undefined;
|
|
36
|
+
description?: string | undefined;
|
|
37
|
+
full?: boolean | undefined;
|
|
38
|
+
_openapi?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
title: string;
|
|
41
|
+
icon?: string | undefined;
|
|
42
|
+
description?: string | undefined;
|
|
43
|
+
full?: boolean | undefined;
|
|
44
|
+
_openapi?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
|
|
47
|
+
interface TransformContext {
|
|
48
|
+
path: string;
|
|
49
|
+
source: string;
|
|
50
|
+
/**
|
|
51
|
+
* Compile MDX to JavaScript
|
|
52
|
+
*/
|
|
53
|
+
buildMDX: (source: string, options?: ProcessorOptions) => Promise<string>;
|
|
54
|
+
}
|
|
55
|
+
interface BaseCollection<Schema> {
|
|
56
|
+
/**
|
|
57
|
+
* Directories to scan
|
|
58
|
+
*/
|
|
59
|
+
dir: string | string[];
|
|
60
|
+
/**
|
|
61
|
+
* what files to include/exclude (glob patterns)
|
|
62
|
+
*
|
|
63
|
+
* Include all files if not specified
|
|
64
|
+
*/
|
|
65
|
+
files?: string[];
|
|
66
|
+
schema?: Schema | ((ctx: TransformContext) => Schema);
|
|
67
|
+
}
|
|
68
|
+
interface MetaCollection<Schema extends ZodTypeAny = ZodTypeAny> extends BaseCollection<Schema> {
|
|
69
|
+
type: 'meta';
|
|
70
|
+
}
|
|
71
|
+
interface DocCollection<Schema extends ZodTypeAny = ZodTypeAny, Async extends boolean = boolean> extends BaseCollection<Schema> {
|
|
72
|
+
type: 'doc';
|
|
73
|
+
mdxOptions?: MDXOptions;
|
|
74
|
+
/**
|
|
75
|
+
* Load files with async
|
|
76
|
+
*/
|
|
77
|
+
async?: Async;
|
|
78
|
+
}
|
|
79
|
+
declare function defineCollections<T extends 'doc' | 'meta', Schema extends ZodTypeAny = ZodTypeAny, Async extends boolean = false>(options: {
|
|
80
|
+
type: T;
|
|
81
|
+
} & (T extends 'doc' ? DocCollection<Schema, Async> : MetaCollection<Schema>)): {
|
|
82
|
+
_doc: 'collections';
|
|
83
|
+
type: T;
|
|
84
|
+
_type: {
|
|
85
|
+
async: Async;
|
|
86
|
+
runtime: T extends 'doc' ? Async extends true ? z.infer<Schema> & BaseCollectionEntry & {
|
|
87
|
+
load: () => Promise<MarkdownProps>;
|
|
88
|
+
} : Omit<MarkdownProps, keyof z.infer<Schema>> & z.infer<Schema> & BaseCollectionEntry : typeof options extends MetaCollection ? z.infer<Schema> & BaseCollectionEntry : never;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
declare function defineDocs<DocData extends ZodTypeAny = typeof frontmatterSchema, MetaData extends ZodTypeAny = typeof metaSchema, DocAsync extends boolean = false>(options?: {
|
|
92
|
+
/**
|
|
93
|
+
* The directory to scan files
|
|
94
|
+
*
|
|
95
|
+
* @defaultValue 'content/docs'
|
|
96
|
+
*/
|
|
97
|
+
dir?: string | string[];
|
|
98
|
+
docs?: Partial<DocCollection<DocData, DocAsync>>;
|
|
99
|
+
meta?: Partial<MetaCollection<MetaData>>;
|
|
100
|
+
}): {
|
|
101
|
+
docs: ReturnType<typeof defineCollections<'doc', DocData, DocAsync>>;
|
|
102
|
+
meta: ReturnType<typeof defineCollections<'meta', MetaData, false>>;
|
|
103
|
+
};
|
|
104
|
+
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
105
|
+
|
|
106
|
+
export { type BaseCollection as B, type DocCollection as D, type MetaCollection as M, type TransformContext as T, defineDocs as a, defineConfig as b, defineCollections as d, frontmatterSchema as f, metaSchema as m };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z, ZodTypeAny } from 'zod';
|
|
2
|
+
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
3
|
+
import { c as MDXOptions, B as BaseCollectionEntry, M as MarkdownProps, G as GlobalConfig } from './build-mdx-o0kbHSlp.js';
|
|
4
|
+
|
|
5
|
+
declare const metaSchema: z.ZodObject<{
|
|
6
|
+
title: z.ZodOptional<z.ZodString>;
|
|
7
|
+
pages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
8
|
+
description: z.ZodOptional<z.ZodString>;
|
|
9
|
+
root: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
defaultOpen: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
root?: boolean | undefined;
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
icon?: string | undefined;
|
|
16
|
+
pages?: string[] | undefined;
|
|
17
|
+
description?: string | undefined;
|
|
18
|
+
defaultOpen?: boolean | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
root?: boolean | undefined;
|
|
21
|
+
title?: string | undefined;
|
|
22
|
+
icon?: string | undefined;
|
|
23
|
+
pages?: string[] | undefined;
|
|
24
|
+
description?: string | undefined;
|
|
25
|
+
defaultOpen?: boolean | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
declare const frontmatterSchema: z.ZodObject<{
|
|
28
|
+
title: z.ZodString;
|
|
29
|
+
description: z.ZodOptional<z.ZodString>;
|
|
30
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
31
|
+
full: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
_openapi: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
title: string;
|
|
35
|
+
icon?: string | undefined;
|
|
36
|
+
description?: string | undefined;
|
|
37
|
+
full?: boolean | undefined;
|
|
38
|
+
_openapi?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
title: string;
|
|
41
|
+
icon?: string | undefined;
|
|
42
|
+
description?: string | undefined;
|
|
43
|
+
full?: boolean | undefined;
|
|
44
|
+
_openapi?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
|
|
47
|
+
interface TransformContext {
|
|
48
|
+
path: string;
|
|
49
|
+
source: string;
|
|
50
|
+
/**
|
|
51
|
+
* Compile MDX to JavaScript
|
|
52
|
+
*/
|
|
53
|
+
buildMDX: (source: string, options?: ProcessorOptions) => Promise<string>;
|
|
54
|
+
}
|
|
55
|
+
interface BaseCollection<Schema> {
|
|
56
|
+
/**
|
|
57
|
+
* Directories to scan
|
|
58
|
+
*/
|
|
59
|
+
dir: string | string[];
|
|
60
|
+
/**
|
|
61
|
+
* what files to include/exclude (glob patterns)
|
|
62
|
+
*
|
|
63
|
+
* Include all files if not specified
|
|
64
|
+
*/
|
|
65
|
+
files?: string[];
|
|
66
|
+
schema?: Schema | ((ctx: TransformContext) => Schema);
|
|
67
|
+
}
|
|
68
|
+
interface MetaCollection<Schema extends ZodTypeAny = ZodTypeAny> extends BaseCollection<Schema> {
|
|
69
|
+
type: 'meta';
|
|
70
|
+
}
|
|
71
|
+
interface DocCollection<Schema extends ZodTypeAny = ZodTypeAny, Async extends boolean = boolean> extends BaseCollection<Schema> {
|
|
72
|
+
type: 'doc';
|
|
73
|
+
mdxOptions?: MDXOptions;
|
|
74
|
+
/**
|
|
75
|
+
* Load files with async
|
|
76
|
+
*/
|
|
77
|
+
async?: Async;
|
|
78
|
+
}
|
|
79
|
+
declare function defineCollections<T extends 'doc' | 'meta', Schema extends ZodTypeAny = ZodTypeAny, Async extends boolean = false>(options: {
|
|
80
|
+
type: T;
|
|
81
|
+
} & (T extends 'doc' ? DocCollection<Schema, Async> : MetaCollection<Schema>)): {
|
|
82
|
+
_doc: 'collections';
|
|
83
|
+
type: T;
|
|
84
|
+
_type: {
|
|
85
|
+
async: Async;
|
|
86
|
+
runtime: T extends 'doc' ? Async extends true ? z.infer<Schema> & BaseCollectionEntry & {
|
|
87
|
+
load: () => Promise<MarkdownProps>;
|
|
88
|
+
} : Omit<MarkdownProps, keyof z.infer<Schema>> & z.infer<Schema> & BaseCollectionEntry : typeof options extends MetaCollection ? z.infer<Schema> & BaseCollectionEntry : never;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
declare function defineDocs<DocData extends ZodTypeAny = typeof frontmatterSchema, MetaData extends ZodTypeAny = typeof metaSchema, DocAsync extends boolean = false>(options?: {
|
|
92
|
+
/**
|
|
93
|
+
* The directory to scan files
|
|
94
|
+
*
|
|
95
|
+
* @defaultValue 'content/docs'
|
|
96
|
+
*/
|
|
97
|
+
dir?: string | string[];
|
|
98
|
+
docs?: Partial<DocCollection<DocData, DocAsync>>;
|
|
99
|
+
meta?: Partial<MetaCollection<MetaData>>;
|
|
100
|
+
}): {
|
|
101
|
+
docs: ReturnType<typeof defineCollections<'doc', DocData, DocAsync>>;
|
|
102
|
+
meta: ReturnType<typeof defineCollections<'meta', MetaData, false>>;
|
|
103
|
+
};
|
|
104
|
+
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
105
|
+
|
|
106
|
+
export { type BaseCollection as B, type DocCollection as D, type MetaCollection as M, type TransformContext as T, defineDocs as a, defineConfig as b, defineCollections as d, frontmatterSchema as f, metaSchema as m };
|
package/dist/index.cjs
CHANGED
|
@@ -21,36 +21,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
createMDXSource: () => createMDXSource,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
resolveFiles: () => resolveFiles,
|
|
25
|
+
toRuntime: () => toRuntime
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
|
-
// src/runtime/resolve-files.ts
|
|
30
|
-
function resolveFiles({
|
|
31
|
-
docs,
|
|
32
|
-
meta,
|
|
33
|
-
rootDir = ""
|
|
34
|
-
}) {
|
|
35
|
-
const outputs = [];
|
|
36
|
-
for (const entry of docs) {
|
|
37
|
-
if (!entry._file.path.startsWith(rootDir)) continue;
|
|
38
|
-
outputs.push({
|
|
39
|
-
type: "page",
|
|
40
|
-
path: entry._file.path,
|
|
41
|
-
data: entry
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
for (const entry of meta) {
|
|
45
|
-
outputs.push({
|
|
46
|
-
type: "meta",
|
|
47
|
-
path: entry._file.path,
|
|
48
|
-
data: entry
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return outputs;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
29
|
// src/runtime/index.ts
|
|
55
30
|
function toRuntime(type, file, info) {
|
|
56
31
|
if (type === "doc") {
|
|
@@ -68,19 +43,6 @@ function toRuntime(type, file, info) {
|
|
|
68
43
|
_file: info
|
|
69
44
|
};
|
|
70
45
|
}
|
|
71
|
-
function toRuntimeAsync(frontmatter, load, info) {
|
|
72
|
-
return {
|
|
73
|
-
async load() {
|
|
74
|
-
const { default: body, ...res } = await load();
|
|
75
|
-
return {
|
|
76
|
-
body,
|
|
77
|
-
...res
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
...frontmatter,
|
|
81
|
-
_file: info
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
46
|
function createMDXSource(docs, meta = []) {
|
|
85
47
|
return {
|
|
86
48
|
files: (rootDir) => resolveFiles({
|
|
@@ -90,9 +52,32 @@ function createMDXSource(docs, meta = []) {
|
|
|
90
52
|
})
|
|
91
53
|
};
|
|
92
54
|
}
|
|
55
|
+
function resolveFiles({
|
|
56
|
+
docs,
|
|
57
|
+
meta,
|
|
58
|
+
rootDir = ""
|
|
59
|
+
}) {
|
|
60
|
+
const outputs = [];
|
|
61
|
+
for (const entry of docs) {
|
|
62
|
+
if (!entry._file.path.startsWith(rootDir)) continue;
|
|
63
|
+
outputs.push({
|
|
64
|
+
type: "page",
|
|
65
|
+
path: entry._file.path,
|
|
66
|
+
data: entry
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
for (const entry of meta) {
|
|
70
|
+
outputs.push({
|
|
71
|
+
type: "meta",
|
|
72
|
+
path: entry._file.path,
|
|
73
|
+
data: entry
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return outputs;
|
|
77
|
+
}
|
|
93
78
|
// Annotate the CommonJS export names for ESM import in node:
|
|
94
79
|
0 && (module.exports = {
|
|
95
80
|
createMDXSource,
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
resolveFiles,
|
|
82
|
+
toRuntime
|
|
98
83
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
2
|
-
import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-
|
|
1
|
+
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
+
import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-o0kbHSlp.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import 'mdx/types';
|
|
5
5
|
import 'fumadocs-core/mdx-plugins';
|
|
6
6
|
import 'fumadocs-core/server';
|
|
7
7
|
import '@mdx-js/mdx';
|
|
8
8
|
import 'unified';
|
|
9
|
+
import 'react';
|
|
9
10
|
|
|
10
11
|
declare function toRuntime(type: 'doc' | 'meta', file: Record<string, unknown>, info: FileInfo): unknown;
|
|
11
|
-
declare function toRuntimeAsync(frontmatter: Record<string, unknown>, load: () => Promise<Record<string, unknown>>, info: FileInfo): unknown;
|
|
12
12
|
declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
|
|
13
13
|
pageData: Doc;
|
|
14
14
|
metaData: Meta;
|
|
15
15
|
}>;
|
|
16
|
+
interface ResolveOptions {
|
|
17
|
+
docs: BaseCollectionEntry[];
|
|
18
|
+
meta: BaseCollectionEntry[];
|
|
19
|
+
rootDir?: string;
|
|
20
|
+
}
|
|
21
|
+
declare function resolveFiles({ docs, meta, rootDir, }: ResolveOptions): VirtualFile[];
|
|
16
22
|
|
|
17
|
-
export { createMDXSource,
|
|
23
|
+
export { createMDXSource, resolveFiles, toRuntime };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
2
|
-
import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-
|
|
1
|
+
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
2
|
+
import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-o0kbHSlp.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import 'mdx/types';
|
|
5
5
|
import 'fumadocs-core/mdx-plugins';
|
|
6
6
|
import 'fumadocs-core/server';
|
|
7
7
|
import '@mdx-js/mdx';
|
|
8
8
|
import 'unified';
|
|
9
|
+
import 'react';
|
|
9
10
|
|
|
10
11
|
declare function toRuntime(type: 'doc' | 'meta', file: Record<string, unknown>, info: FileInfo): unknown;
|
|
11
|
-
declare function toRuntimeAsync(frontmatter: Record<string, unknown>, load: () => Promise<Record<string, unknown>>, info: FileInfo): unknown;
|
|
12
12
|
declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
|
|
13
13
|
pageData: Doc;
|
|
14
14
|
metaData: Meta;
|
|
15
15
|
}>;
|
|
16
|
+
interface ResolveOptions {
|
|
17
|
+
docs: BaseCollectionEntry[];
|
|
18
|
+
meta: BaseCollectionEntry[];
|
|
19
|
+
rootDir?: string;
|
|
20
|
+
}
|
|
21
|
+
declare function resolveFiles({ docs, meta, rootDir, }: ResolveOptions): VirtualFile[];
|
|
16
22
|
|
|
17
|
-
export { createMDXSource,
|
|
23
|
+
export { createMDXSource, resolveFiles, toRuntime };
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
// src/runtime/resolve-files.ts
|
|
2
|
-
function resolveFiles({
|
|
3
|
-
docs,
|
|
4
|
-
meta,
|
|
5
|
-
rootDir = ""
|
|
6
|
-
}) {
|
|
7
|
-
const outputs = [];
|
|
8
|
-
for (const entry of docs) {
|
|
9
|
-
if (!entry._file.path.startsWith(rootDir)) continue;
|
|
10
|
-
outputs.push({
|
|
11
|
-
type: "page",
|
|
12
|
-
path: entry._file.path,
|
|
13
|
-
data: entry
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
for (const entry of meta) {
|
|
17
|
-
outputs.push({
|
|
18
|
-
type: "meta",
|
|
19
|
-
path: entry._file.path,
|
|
20
|
-
data: entry
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return outputs;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
1
|
// src/runtime/index.ts
|
|
27
2
|
function toRuntime(type, file, info) {
|
|
28
3
|
if (type === "doc") {
|
|
@@ -40,19 +15,6 @@ function toRuntime(type, file, info) {
|
|
|
40
15
|
_file: info
|
|
41
16
|
};
|
|
42
17
|
}
|
|
43
|
-
function toRuntimeAsync(frontmatter, load, info) {
|
|
44
|
-
return {
|
|
45
|
-
async load() {
|
|
46
|
-
const { default: body, ...res } = await load();
|
|
47
|
-
return {
|
|
48
|
-
body,
|
|
49
|
-
...res
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
...frontmatter,
|
|
53
|
-
_file: info
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
18
|
function createMDXSource(docs, meta = []) {
|
|
57
19
|
return {
|
|
58
20
|
files: (rootDir) => resolveFiles({
|
|
@@ -62,8 +24,31 @@ function createMDXSource(docs, meta = []) {
|
|
|
62
24
|
})
|
|
63
25
|
};
|
|
64
26
|
}
|
|
27
|
+
function resolveFiles({
|
|
28
|
+
docs,
|
|
29
|
+
meta,
|
|
30
|
+
rootDir = ""
|
|
31
|
+
}) {
|
|
32
|
+
const outputs = [];
|
|
33
|
+
for (const entry of docs) {
|
|
34
|
+
if (!entry._file.path.startsWith(rootDir)) continue;
|
|
35
|
+
outputs.push({
|
|
36
|
+
type: "page",
|
|
37
|
+
path: entry._file.path,
|
|
38
|
+
data: entry
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
for (const entry of meta) {
|
|
42
|
+
outputs.push({
|
|
43
|
+
type: "meta",
|
|
44
|
+
path: entry._file.path,
|
|
45
|
+
data: entry
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return outputs;
|
|
49
|
+
}
|
|
65
50
|
export {
|
|
66
51
|
createMDXSource,
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
resolveFiles,
|
|
53
|
+
toRuntime
|
|
69
54
|
};
|
package/dist/loader-mdx.cjs
CHANGED
|
@@ -111,19 +111,20 @@ function getDefaultMDXOptions({
|
|
|
111
111
|
];
|
|
112
112
|
const remarkPlugins = pluginOption(
|
|
113
113
|
(v) => [
|
|
114
|
-
|
|
114
|
+
plugins.remarkGfm,
|
|
115
115
|
[
|
|
116
|
-
|
|
116
|
+
plugins.remarkHeading,
|
|
117
117
|
{
|
|
118
118
|
generateToc: false,
|
|
119
119
|
...remarkHeadingOptions
|
|
120
120
|
}
|
|
121
121
|
],
|
|
122
|
-
remarkImageOptions !== false && [
|
|
123
|
-
|
|
122
|
+
remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
|
|
123
|
+
// Fumadocs 14 compatibility
|
|
124
|
+
"remarkCodeTab" in plugins && remarkCodeTabOptions !== false && plugins.remarkCodeTab,
|
|
124
125
|
...v,
|
|
125
126
|
remarkStructureOptions !== false && [
|
|
126
|
-
|
|
127
|
+
plugins.remarkStructure,
|
|
127
128
|
remarkStructureOptions
|
|
128
129
|
],
|
|
129
130
|
[remarkMdxExport, { values: mdxExports }]
|
|
@@ -132,9 +133,9 @@ function getDefaultMDXOptions({
|
|
|
132
133
|
);
|
|
133
134
|
const rehypePlugins = pluginOption(
|
|
134
135
|
(v) => [
|
|
135
|
-
rehypeCodeOptions !== false && [
|
|
136
|
+
rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
|
|
136
137
|
...v,
|
|
137
|
-
[
|
|
138
|
+
[plugins.rehypeToc]
|
|
138
139
|
],
|
|
139
140
|
mdxOptions.rehypePlugins
|
|
140
141
|
);
|
|
@@ -144,11 +145,11 @@ function getDefaultMDXOptions({
|
|
|
144
145
|
rehypePlugins
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
|
-
var
|
|
148
|
+
var plugins;
|
|
148
149
|
var init_mdx_options = __esm({
|
|
149
150
|
"src/utils/mdx-options.ts"() {
|
|
150
151
|
"use strict";
|
|
151
|
-
|
|
152
|
+
plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
152
153
|
init_remark_exports();
|
|
153
154
|
}
|
|
154
155
|
});
|
|
@@ -163,41 +164,15 @@ var path4 = __toESM(require("path"), 1);
|
|
|
163
164
|
var import_node_querystring = require("querystring");
|
|
164
165
|
var import_gray_matter2 = __toESM(require("gray-matter"), 1);
|
|
165
166
|
|
|
166
|
-
// src/config
|
|
167
|
+
// src/utils/config-cache.ts
|
|
167
168
|
var import_node_crypto = require("crypto");
|
|
168
169
|
var fs = __toESM(require("fs"), 1);
|
|
169
170
|
|
|
170
|
-
// src/
|
|
171
|
+
// src/utils/load-config.ts
|
|
171
172
|
var path = __toESM(require("path"), 1);
|
|
172
173
|
var import_node_url = require("url");
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
|
|
176
|
-
const transformed = await build({
|
|
177
|
-
entryPoints: [{ in: configPath, out: "source.config" }],
|
|
178
|
-
bundle: true,
|
|
179
|
-
outdir: ".source",
|
|
180
|
-
target: "node18",
|
|
181
|
-
write: true,
|
|
182
|
-
platform: "node",
|
|
183
|
-
format: "esm",
|
|
184
|
-
packages: "external",
|
|
185
|
-
outExtension: {
|
|
186
|
-
".js": ".mjs"
|
|
187
|
-
},
|
|
188
|
-
allowOverwrite: true
|
|
189
|
-
});
|
|
190
|
-
if (transformed.errors.length > 0) {
|
|
191
|
-
throw new Error("failed to compile configuration file");
|
|
192
|
-
}
|
|
193
|
-
const loaded = await import(`${url.href}?hash=${Date.now().toString()}`);
|
|
194
|
-
const [err, config] = buildConfig(
|
|
195
|
-
// every call to `loadConfig` will cause the previous cache to be ignored
|
|
196
|
-
loaded
|
|
197
|
-
);
|
|
198
|
-
if (err !== null) throw new Error(err);
|
|
199
|
-
return config;
|
|
200
|
-
}
|
|
174
|
+
|
|
175
|
+
// src/config/build.ts
|
|
201
176
|
function buildConfig(config) {
|
|
202
177
|
const collections = /* @__PURE__ */ new Map();
|
|
203
178
|
let globalConfig;
|
|
@@ -245,7 +220,37 @@ function buildConfig(config) {
|
|
|
245
220
|
];
|
|
246
221
|
}
|
|
247
222
|
|
|
248
|
-
// src/config
|
|
223
|
+
// src/utils/load-config.ts
|
|
224
|
+
async function loadConfig(configPath) {
|
|
225
|
+
const { build } = await import("esbuild");
|
|
226
|
+
const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
|
|
227
|
+
const transformed = await build({
|
|
228
|
+
entryPoints: [{ in: configPath, out: "source.config" }],
|
|
229
|
+
bundle: true,
|
|
230
|
+
outdir: ".source",
|
|
231
|
+
target: "node18",
|
|
232
|
+
write: true,
|
|
233
|
+
platform: "node",
|
|
234
|
+
format: "esm",
|
|
235
|
+
packages: "external",
|
|
236
|
+
outExtension: {
|
|
237
|
+
".js": ".mjs"
|
|
238
|
+
},
|
|
239
|
+
allowOverwrite: true
|
|
240
|
+
});
|
|
241
|
+
if (transformed.errors.length > 0) {
|
|
242
|
+
throw new Error("failed to compile configuration file");
|
|
243
|
+
}
|
|
244
|
+
const loaded = await import(`${url.href}?hash=${Date.now().toString()}`);
|
|
245
|
+
const [err, config] = buildConfig(
|
|
246
|
+
// every call to `loadConfig` will cause the previous cache to be ignored
|
|
247
|
+
loaded
|
|
248
|
+
);
|
|
249
|
+
if (err !== null) throw new Error(err);
|
|
250
|
+
return config;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/utils/config-cache.ts
|
|
249
254
|
var cache = /* @__PURE__ */ new Map();
|
|
250
255
|
async function loadConfigCached(configPath, hash) {
|
|
251
256
|
const cached = cache.get(configPath);
|
package/dist/loader-mdx.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
remarkInclude
|
|
3
|
-
} from "./chunk-PY2KKTR2.js";
|
|
4
1
|
import {
|
|
5
2
|
getConfigHash,
|
|
6
3
|
loadConfigCached
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IU4D6M3A.js";
|
|
5
|
+
import {
|
|
6
|
+
remarkInclude
|
|
7
|
+
} from "./chunk-PY2KKTR2.js";
|
|
8
|
+
import "./chunk-2DJQ3DOD.js";
|
|
8
9
|
|
|
9
10
|
// src/loader-mdx.ts
|
|
10
11
|
import * as path2 from "node:path";
|