fumadocs-mdx 11.10.1 → 12.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 +126 -218
- package/dist/bin.js +1 -1
- package/dist/{browser-B2G8uAF2.d.cts → browser-D5lvL8vv.d.ts} +51 -4
- package/dist/{browser-DrH7tKRi.d.ts → browser-DjWADqp8.d.cts} +51 -4
- package/dist/bun/index.cjs +274 -230
- package/dist/bun/index.js +8 -8
- package/dist/chunk-ADR6R7HM.js +29 -0
- package/dist/{chunk-UOOPSLFY.js → chunk-AUOOMFAI.js} +27 -21
- package/dist/chunk-FSZMKRVH.js +80 -0
- package/dist/{chunk-766EAFX6.js → chunk-LGYVNESJ.js} +2 -36
- package/dist/chunk-LMG6UWCL.js +167 -0
- package/dist/chunk-QAUWMR5D.js +142 -0
- package/dist/{chunk-QJCCVMBJ.js → chunk-SP7CHRTS.js} +17 -47
- package/dist/{chunk-QVZ7JH4H.js → chunk-U4MQ44TS.js} +1 -1
- package/dist/{chunk-CNKI574E.js → chunk-VXEBLM4X.js} +1 -1
- package/dist/chunk-XMFLD5J6.js +30 -0
- package/dist/chunk-ZLCSVXCD.js +10 -0
- package/dist/{chunk-XXSKWWMB.js → chunk-ZX7TM4AR.js} +4 -2
- package/dist/config/index.cjs +97 -148
- package/dist/config/index.d.cts +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +48 -9
- package/dist/{define-BH4bnHQl.d.ts → define--6HQ1ehX.d.cts} +18 -3
- package/dist/{define-BH4bnHQl.d.cts → define--6HQ1ehX.d.ts} +18 -3
- package/dist/load-UUXLUBHL.js +9 -0
- package/dist/loader-mdx.cjs +336 -305
- package/dist/loader-mdx.js +8 -8
- package/dist/next/index.cjs +152 -242
- package/dist/next/index.js +52 -66
- package/dist/node/loader.cjs +274 -243
- package/dist/node/loader.js +7 -8
- package/dist/postinstall-SCSXM4IM.js +10 -0
- package/dist/{mdx-options-T73E4LQB.js → preset-ZMP6U62C.js} +1 -1
- package/dist/runtime/next/async.cjs +304 -204
- package/dist/runtime/next/async.d.cts +3 -3
- package/dist/runtime/next/async.d.ts +3 -3
- package/dist/runtime/next/async.js +59 -32
- package/dist/runtime/next/index.cjs +32 -21
- package/dist/runtime/next/index.d.cts +11 -7
- package/dist/runtime/next/index.d.ts +11 -7
- package/dist/runtime/next/index.js +2 -1
- package/dist/runtime/vite/browser.d.cts +2 -3
- package/dist/runtime/vite/browser.d.ts +2 -3
- package/dist/runtime/vite/server.cjs +67 -21
- package/dist/runtime/vite/server.d.cts +14 -28
- package/dist/runtime/vite/server.d.ts +14 -28
- package/dist/runtime/vite/server.js +61 -21
- package/dist/shared-0QIuV0XZ.d.ts +70 -0
- package/dist/shared-CqgMnt9h.d.cts +70 -0
- package/dist/{types-DN9KrG7R.d.ts → types-CFlQxTN8.d.ts} +10 -37
- package/dist/{types-DT83Ijs6.d.cts → types-DkGjw-Uo.d.cts} +10 -37
- package/dist/vite/index.cjs +299 -279
- package/dist/vite/index.d.cts +1 -0
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/index.js +15 -20
- package/dist/{watcher-4NDMOH4R.js → watcher-HGOH3APP.js} +1 -1
- package/package.json +16 -16
- package/dist/build-mdx-DnC1jKvn.d.cts +0 -46
- package/dist/build-mdx-DnC1jKvn.d.ts +0 -46
- package/dist/chunk-GBMFGEC7.js +0 -57
- package/dist/chunk-QQWCBFFE.js +0 -40
- package/dist/chunk-SMSNZ6N5.js +0 -155
- package/dist/chunk-SVTXMVLQ.js +0 -139
- package/dist/config/zod-3.cjs +0 -422
- package/dist/config/zod-3.d.cts +0 -53
- package/dist/config/zod-3.d.ts +0 -53
- package/dist/config/zod-3.js +0 -40
- package/dist/postinstall-XV4WSHZP.js +0 -9
package/dist/vite/index.d.cts
CHANGED
package/dist/vite/index.d.ts
CHANGED
package/dist/vite/index.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
entry,
|
|
3
3
|
postInstall
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-ZX7TM4AR.js";
|
|
5
5
|
import "../chunk-6Y5JDZHD.js";
|
|
6
|
+
import "../chunk-LGYVNESJ.js";
|
|
6
7
|
import {
|
|
7
8
|
toVite
|
|
8
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-VXEBLM4X.js";
|
|
9
10
|
import {
|
|
10
|
-
createMdxLoader
|
|
11
|
-
|
|
12
|
-
} from "../chunk-QJCCVMBJ.js";
|
|
13
|
-
import "../chunk-QQWCBFFE.js";
|
|
14
|
-
import "../chunk-SVTXMVLQ.js";
|
|
11
|
+
createMdxLoader
|
|
12
|
+
} from "../chunk-SP7CHRTS.js";
|
|
15
13
|
import {
|
|
16
14
|
ValidationError,
|
|
17
15
|
validate
|
|
18
16
|
} from "../chunk-IQAEAI4P.js";
|
|
19
|
-
import
|
|
17
|
+
import {
|
|
18
|
+
resolvedConfig
|
|
19
|
+
} from "../chunk-XMFLD5J6.js";
|
|
20
20
|
import {
|
|
21
21
|
buildConfig
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-U4MQ44TS.js";
|
|
23
|
+
import "../chunk-QAUWMR5D.js";
|
|
24
|
+
import "../chunk-LMG6UWCL.js";
|
|
23
25
|
import "../chunk-VWJKRQZR.js";
|
|
24
26
|
|
|
25
27
|
// src/vite/index.ts
|
|
@@ -84,18 +86,11 @@ function mdx(config, options = {}) {
|
|
|
84
86
|
},
|
|
85
87
|
async buildStart() {
|
|
86
88
|
if (!generateIndexFile) return;
|
|
89
|
+
const { out = "source.generated.ts", addJsExtension } = typeof generateIndexFile === "object" ? generateIndexFile : {};
|
|
87
90
|
console.log("[Fumadocs MDX] Generating index files");
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
await fs.writeFile(
|
|
91
|
-
path.join(outDir, outFile),
|
|
92
|
-
entry(
|
|
93
|
-
configPath,
|
|
94
|
-
loaded,
|
|
95
|
-
outDir,
|
|
96
|
-
typeof generateIndexFile === "object" ? generateIndexFile.addJsExtension : void 0
|
|
97
|
-
)
|
|
98
|
-
);
|
|
91
|
+
const dir = path.dirname(out);
|
|
92
|
+
await fs.mkdir(dir, { recursive: true });
|
|
93
|
+
await fs.writeFile(out, entry(configPath, loaded, dir, addJsExtension));
|
|
99
94
|
},
|
|
100
95
|
async transform(value, id) {
|
|
101
96
|
const [file, query = ""] = id.split("?");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -18,11 +18,6 @@
|
|
|
18
18
|
"types": "./dist/config/index.d.ts",
|
|
19
19
|
"require": "./dist/config/index.cjs"
|
|
20
20
|
},
|
|
21
|
-
"./config/zod-3": {
|
|
22
|
-
"import": "./dist/config/zod-3.js",
|
|
23
|
-
"types": "./dist/config/zod-3.d.ts",
|
|
24
|
-
"require": "./dist/config/zod-3.cjs"
|
|
25
|
-
},
|
|
26
21
|
"./next": {
|
|
27
22
|
"import": "./dist/next/index.js",
|
|
28
23
|
"types": "./dist/next/index.d.ts",
|
|
@@ -66,10 +61,11 @@
|
|
|
66
61
|
"@mdx-js/mdx": "^3.1.1",
|
|
67
62
|
"@standard-schema/spec": "^1.0.0",
|
|
68
63
|
"chokidar": "^4.0.3",
|
|
69
|
-
"esbuild": "^0.25.
|
|
64
|
+
"esbuild": "^0.25.10",
|
|
70
65
|
"estree-util-value-to-estree": "^3.4.0",
|
|
71
66
|
"js-yaml": "^4.1.0",
|
|
72
|
-
"lru-cache": "^11.2.
|
|
67
|
+
"lru-cache": "^11.2.2",
|
|
68
|
+
"mdast-util-to-markdown": "^2.1.2",
|
|
73
69
|
"picocolors": "^1.1.1",
|
|
74
70
|
"remark-mdx": "^3.1.1",
|
|
75
71
|
"remark-parse": "^11.0.0",
|
|
@@ -77,25 +73,29 @@
|
|
|
77
73
|
"tinyglobby": "^0.2.15",
|
|
78
74
|
"unified": "^11.0.5",
|
|
79
75
|
"unist-util-visit": "^5.0.0",
|
|
80
|
-
"zod": "^4.1.
|
|
76
|
+
"zod": "^4.1.11"
|
|
81
77
|
},
|
|
82
78
|
"devDependencies": {
|
|
83
|
-
"@types/bun": "^1.2.
|
|
79
|
+
"@types/bun": "^1.2.22",
|
|
84
80
|
"@types/js-yaml": "^4.0.9",
|
|
85
81
|
"@types/mdast": "^4.0.3",
|
|
86
82
|
"@types/mdx": "^2.0.13",
|
|
87
|
-
"@types/node": "^24.
|
|
83
|
+
"@types/node": "^24.5.2",
|
|
88
84
|
"@types/react": "^19.1.13",
|
|
85
|
+
"mdast-util-directive": "^3.1.0",
|
|
89
86
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
90
|
-
"next": "^15.5.
|
|
87
|
+
"next": "^15.5.4",
|
|
91
88
|
"react": "^19.1.1",
|
|
92
|
-
"
|
|
89
|
+
"remark": "^15.0.1",
|
|
90
|
+
"remark-directive": "^4.0.0",
|
|
91
|
+
"remark-stringify": "^11.0.0",
|
|
92
|
+
"rollup": "^4.52.2",
|
|
93
93
|
"vfile": "^6.0.3",
|
|
94
|
-
"vite": "^7.1.
|
|
94
|
+
"vite": "^7.1.7",
|
|
95
95
|
"webpack": "^5.101.3",
|
|
96
|
-
"@fumadocs/mdx-remote": "1.4.0",
|
|
97
96
|
"eslint-config-custom": "0.0.0",
|
|
98
|
-
"fumadocs-
|
|
97
|
+
"@fumadocs/mdx-remote": "1.4.0",
|
|
98
|
+
"fumadocs-core": "15.8.0",
|
|
99
99
|
"tsconfig": "0.0.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createProcessor } from '@mdx-js/mdx';
|
|
2
|
-
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
3
|
-
import { TableOfContents } from 'fumadocs-core/server';
|
|
4
|
-
import { FC } from 'react';
|
|
5
|
-
import { MDXProps } from 'mdx/types';
|
|
6
|
-
|
|
7
|
-
declare module 'vfile' {
|
|
8
|
-
interface DataMap {
|
|
9
|
-
extractedReferences: ExtractedReference[];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
interface ExtractedReference {
|
|
13
|
-
href: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type Processor = ReturnType<typeof createProcessor>;
|
|
17
|
-
interface CompilerOptions {
|
|
18
|
-
addDependency: (file: string) => void;
|
|
19
|
-
}
|
|
20
|
-
interface CompiledMDXProperties<Frontmatter = Record<string, unknown>> {
|
|
21
|
-
frontmatter: Frontmatter;
|
|
22
|
-
structuredData: StructuredData;
|
|
23
|
-
toc: TableOfContents;
|
|
24
|
-
default: FC<MDXProps>;
|
|
25
|
-
/**
|
|
26
|
-
* Only available when `lastModifiedTime` is enabled on MDX loader
|
|
27
|
-
*/
|
|
28
|
-
lastModified?: Date;
|
|
29
|
-
extractedReferences?: ExtractedReference[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
declare module 'vfile' {
|
|
33
|
-
interface DataMap {
|
|
34
|
-
/**
|
|
35
|
-
* [Fumadocs MDX] raw frontmatter, you can modify it
|
|
36
|
-
*/
|
|
37
|
-
frontmatter?: Record<string, unknown>;
|
|
38
|
-
/**
|
|
39
|
-
* [Fumadocs MDX] The compiler object from loader
|
|
40
|
-
*/
|
|
41
|
-
_compiler?: CompilerOptions;
|
|
42
|
-
_getProcessor?: (format: 'md' | 'mdx') => Processor;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type { CompiledMDXProperties as C };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createProcessor } from '@mdx-js/mdx';
|
|
2
|
-
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
3
|
-
import { TableOfContents } from 'fumadocs-core/server';
|
|
4
|
-
import { FC } from 'react';
|
|
5
|
-
import { MDXProps } from 'mdx/types';
|
|
6
|
-
|
|
7
|
-
declare module 'vfile' {
|
|
8
|
-
interface DataMap {
|
|
9
|
-
extractedReferences: ExtractedReference[];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
interface ExtractedReference {
|
|
13
|
-
href: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type Processor = ReturnType<typeof createProcessor>;
|
|
17
|
-
interface CompilerOptions {
|
|
18
|
-
addDependency: (file: string) => void;
|
|
19
|
-
}
|
|
20
|
-
interface CompiledMDXProperties<Frontmatter = Record<string, unknown>> {
|
|
21
|
-
frontmatter: Frontmatter;
|
|
22
|
-
structuredData: StructuredData;
|
|
23
|
-
toc: TableOfContents;
|
|
24
|
-
default: FC<MDXProps>;
|
|
25
|
-
/**
|
|
26
|
-
* Only available when `lastModifiedTime` is enabled on MDX loader
|
|
27
|
-
*/
|
|
28
|
-
lastModified?: Date;
|
|
29
|
-
extractedReferences?: ExtractedReference[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
declare module 'vfile' {
|
|
33
|
-
interface DataMap {
|
|
34
|
-
/**
|
|
35
|
-
* [Fumadocs MDX] raw frontmatter, you can modify it
|
|
36
|
-
*/
|
|
37
|
-
frontmatter?: Record<string, unknown>;
|
|
38
|
-
/**
|
|
39
|
-
* [Fumadocs MDX] The compiler object from loader
|
|
40
|
-
*/
|
|
41
|
-
_compiler?: CompilerOptions;
|
|
42
|
-
_getProcessor?: (format: 'md' | 'mdx') => Processor;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type { CompiledMDXProperties as C };
|
package/dist/chunk-GBMFGEC7.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// src/config/zod-4.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var metaSchema = z.object({
|
|
4
|
-
title: z.string().optional(),
|
|
5
|
-
pages: z.array(z.string()).optional(),
|
|
6
|
-
description: z.string().optional(),
|
|
7
|
-
root: z.boolean().optional(),
|
|
8
|
-
defaultOpen: z.boolean().optional(),
|
|
9
|
-
icon: z.string().optional()
|
|
10
|
-
});
|
|
11
|
-
var frontmatterSchema = z.object({
|
|
12
|
-
title: z.string(),
|
|
13
|
-
description: z.string().optional(),
|
|
14
|
-
icon: z.string().optional(),
|
|
15
|
-
full: z.boolean().optional(),
|
|
16
|
-
// Fumadocs OpenAPI generated
|
|
17
|
-
_openapi: z.looseObject({}).optional()
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// src/config/define.ts
|
|
21
|
-
function defineCollections(options) {
|
|
22
|
-
return options;
|
|
23
|
-
}
|
|
24
|
-
function defineDocs(options) {
|
|
25
|
-
if (!options)
|
|
26
|
-
console.warn(
|
|
27
|
-
"[`source.config.ts`] Deprecated: please pass options to `defineDocs()` and specify a `dir`."
|
|
28
|
-
);
|
|
29
|
-
const dir = options?.dir ?? "content/docs";
|
|
30
|
-
return {
|
|
31
|
-
type: "docs",
|
|
32
|
-
dir,
|
|
33
|
-
docs: defineCollections({
|
|
34
|
-
type: "doc",
|
|
35
|
-
dir,
|
|
36
|
-
schema: frontmatterSchema,
|
|
37
|
-
...options?.docs
|
|
38
|
-
}),
|
|
39
|
-
meta: defineCollections({
|
|
40
|
-
type: "meta",
|
|
41
|
-
dir,
|
|
42
|
-
schema: metaSchema,
|
|
43
|
-
...options?.meta
|
|
44
|
-
})
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function defineConfig(config = {}) {
|
|
48
|
-
return config;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export {
|
|
52
|
-
metaSchema,
|
|
53
|
-
frontmatterSchema,
|
|
54
|
-
defineCollections,
|
|
55
|
-
defineDocs,
|
|
56
|
-
defineConfig
|
|
57
|
-
};
|
package/dist/chunk-QQWCBFFE.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
remarkInclude
|
|
3
|
-
} from "./chunk-SVTXMVLQ.js";
|
|
4
|
-
|
|
5
|
-
// src/utils/build-mdx.ts
|
|
6
|
-
import { createProcessor } from "@mdx-js/mdx";
|
|
7
|
-
var cache = /* @__PURE__ */ new Map();
|
|
8
|
-
async function buildMDX(cacheKey, source, options) {
|
|
9
|
-
const { filePath, frontmatter, data, _compiler, ...rest } = options;
|
|
10
|
-
function getProcessor(format) {
|
|
11
|
-
const key = `${cacheKey}:${format}`;
|
|
12
|
-
let processor = cache.get(key);
|
|
13
|
-
if (!processor) {
|
|
14
|
-
processor = createProcessor({
|
|
15
|
-
outputFormat: "program",
|
|
16
|
-
...rest,
|
|
17
|
-
remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
|
|
18
|
-
format
|
|
19
|
-
});
|
|
20
|
-
cache.set(key, processor);
|
|
21
|
-
}
|
|
22
|
-
return processor;
|
|
23
|
-
}
|
|
24
|
-
return getProcessor(
|
|
25
|
-
options.format ?? filePath.endsWith(".mdx") ? "mdx" : "md"
|
|
26
|
-
).process({
|
|
27
|
-
value: source,
|
|
28
|
-
path: filePath,
|
|
29
|
-
data: {
|
|
30
|
-
...data,
|
|
31
|
-
frontmatter,
|
|
32
|
-
_compiler,
|
|
33
|
-
_getProcessor: getProcessor
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
buildMDX
|
|
40
|
-
};
|
package/dist/chunk-SMSNZ6N5.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
// src/utils/mdx-options.ts
|
|
2
|
-
import * as plugins from "fumadocs-core/mdx-plugins";
|
|
3
|
-
|
|
4
|
-
// src/mdx-plugins/remark-postprocess.ts
|
|
5
|
-
import { visit } from "unist-util-visit";
|
|
6
|
-
import { valueToEstree } from "estree-util-value-to-estree";
|
|
7
|
-
function remarkPostprocess({
|
|
8
|
-
injectExports
|
|
9
|
-
}) {
|
|
10
|
-
return (tree, file) => {
|
|
11
|
-
let title;
|
|
12
|
-
const urls = [];
|
|
13
|
-
visit(tree, ["heading", "link"], (node) => {
|
|
14
|
-
if (node.type === "heading" && node.depth === 1) {
|
|
15
|
-
title = flattenNode(node);
|
|
16
|
-
}
|
|
17
|
-
if (node.type !== "link") return;
|
|
18
|
-
urls.push({
|
|
19
|
-
href: node.url
|
|
20
|
-
});
|
|
21
|
-
return "skip";
|
|
22
|
-
});
|
|
23
|
-
if (title) {
|
|
24
|
-
file.data.frontmatter ??= {};
|
|
25
|
-
if (!file.data.frontmatter.title) file.data.frontmatter.title = title;
|
|
26
|
-
}
|
|
27
|
-
file.data.extractedReferences = urls;
|
|
28
|
-
for (const name of injectExports) {
|
|
29
|
-
if (!(name in file.data)) continue;
|
|
30
|
-
tree.children.unshift(getMdastExport(name, file.data[name]));
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function flattenNode(node) {
|
|
35
|
-
if ("children" in node)
|
|
36
|
-
return node.children.map((child) => flattenNode(child)).join("");
|
|
37
|
-
if ("value" in node) return node.value;
|
|
38
|
-
return "";
|
|
39
|
-
}
|
|
40
|
-
function getMdastExport(name, value) {
|
|
41
|
-
return {
|
|
42
|
-
type: "mdxjsEsm",
|
|
43
|
-
value: "",
|
|
44
|
-
data: {
|
|
45
|
-
estree: {
|
|
46
|
-
type: "Program",
|
|
47
|
-
sourceType: "module",
|
|
48
|
-
body: [
|
|
49
|
-
{
|
|
50
|
-
type: "ExportNamedDeclaration",
|
|
51
|
-
attributes: [],
|
|
52
|
-
specifiers: [],
|
|
53
|
-
source: null,
|
|
54
|
-
declaration: {
|
|
55
|
-
type: "VariableDeclaration",
|
|
56
|
-
kind: "let",
|
|
57
|
-
declarations: [
|
|
58
|
-
{
|
|
59
|
-
type: "VariableDeclarator",
|
|
60
|
-
id: {
|
|
61
|
-
type: "Identifier",
|
|
62
|
-
name
|
|
63
|
-
},
|
|
64
|
-
init: valueToEstree(value)
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// src/utils/mdx-options.ts
|
|
76
|
-
function pluginOption(def, options = []) {
|
|
77
|
-
const list = def(Array.isArray(options) ? options : []).filter(
|
|
78
|
-
Boolean
|
|
79
|
-
);
|
|
80
|
-
if (typeof options === "function") {
|
|
81
|
-
return options(list);
|
|
82
|
-
}
|
|
83
|
-
return list;
|
|
84
|
-
}
|
|
85
|
-
function getDefaultMDXOptions({
|
|
86
|
-
valueToExport = [],
|
|
87
|
-
rehypeCodeOptions,
|
|
88
|
-
remarkImageOptions,
|
|
89
|
-
remarkHeadingOptions,
|
|
90
|
-
remarkStructureOptions,
|
|
91
|
-
remarkCodeTabOptions,
|
|
92
|
-
remarkNpmOptions,
|
|
93
|
-
_withoutBundler = false,
|
|
94
|
-
...mdxOptions
|
|
95
|
-
}) {
|
|
96
|
-
const mdxExports = [
|
|
97
|
-
"structuredData",
|
|
98
|
-
"extractedReferences",
|
|
99
|
-
"frontmatter",
|
|
100
|
-
"lastModified",
|
|
101
|
-
...valueToExport
|
|
102
|
-
];
|
|
103
|
-
const remarkPlugins = pluginOption(
|
|
104
|
-
(v) => [
|
|
105
|
-
plugins.remarkGfm,
|
|
106
|
-
[
|
|
107
|
-
plugins.remarkHeading,
|
|
108
|
-
{
|
|
109
|
-
generateToc: false,
|
|
110
|
-
...remarkHeadingOptions
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
remarkImageOptions !== false && [
|
|
114
|
-
plugins.remarkImage,
|
|
115
|
-
{
|
|
116
|
-
...remarkImageOptions,
|
|
117
|
-
useImport: _withoutBundler ? false : remarkImageOptions?.useImport
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
"remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
|
|
121
|
-
plugins.remarkCodeTab,
|
|
122
|
-
remarkCodeTabOptions
|
|
123
|
-
],
|
|
124
|
-
"remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
|
|
125
|
-
...v,
|
|
126
|
-
remarkStructureOptions !== false && [
|
|
127
|
-
plugins.remarkStructure,
|
|
128
|
-
remarkStructureOptions
|
|
129
|
-
],
|
|
130
|
-
[
|
|
131
|
-
remarkPostprocess,
|
|
132
|
-
{ injectExports: mdxExports }
|
|
133
|
-
]
|
|
134
|
-
],
|
|
135
|
-
mdxOptions.remarkPlugins
|
|
136
|
-
);
|
|
137
|
-
const rehypePlugins = pluginOption(
|
|
138
|
-
(v) => [
|
|
139
|
-
rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
|
|
140
|
-
...v,
|
|
141
|
-
plugins.rehypeToc
|
|
142
|
-
],
|
|
143
|
-
mdxOptions.rehypePlugins
|
|
144
|
-
);
|
|
145
|
-
return {
|
|
146
|
-
...mdxOptions,
|
|
147
|
-
outputFormat: _withoutBundler ? "function-body" : mdxOptions.outputFormat,
|
|
148
|
-
remarkPlugins,
|
|
149
|
-
rehypePlugins
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export {
|
|
154
|
-
getDefaultMDXOptions
|
|
155
|
-
};
|
package/dist/chunk-SVTXMVLQ.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fumaMatter
|
|
3
|
-
} from "./chunk-VWJKRQZR.js";
|
|
4
|
-
|
|
5
|
-
// src/mdx-plugins/remark-include.ts
|
|
6
|
-
import { unified } from "unified";
|
|
7
|
-
import { visit } from "unist-util-visit";
|
|
8
|
-
import * as path from "path";
|
|
9
|
-
import * as fs from "fs/promises";
|
|
10
|
-
import remarkParse from "remark-parse";
|
|
11
|
-
import remarkMdx from "remark-mdx";
|
|
12
|
-
import { remarkHeading } from "fumadocs-core/mdx-plugins";
|
|
13
|
-
var baseProcessor = unified().use(remarkHeading);
|
|
14
|
-
function flattenNode(node) {
|
|
15
|
-
if ("children" in node)
|
|
16
|
-
return node.children.map((child) => flattenNode(child)).join("");
|
|
17
|
-
if ("value" in node) return node.value;
|
|
18
|
-
return "";
|
|
19
|
-
}
|
|
20
|
-
function parseSpecifier(specifier) {
|
|
21
|
-
const idx = specifier.lastIndexOf("#");
|
|
22
|
-
if (idx === -1) return { file: specifier };
|
|
23
|
-
return {
|
|
24
|
-
file: specifier.slice(0, idx),
|
|
25
|
-
section: specifier.slice(idx + 1)
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function extractSection(root, section) {
|
|
29
|
-
let nodes;
|
|
30
|
-
for (const node of root.children) {
|
|
31
|
-
if (node.type === "mdxJsxFlowElement" && node.name === "section" && node.attributes.some(
|
|
32
|
-
(attr) => attr.type === "mdxJsxAttribute" && attr.name === "id" && attr.value === section
|
|
33
|
-
)) {
|
|
34
|
-
nodes = node.children;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
if (node.type === "heading" && node.data?.hProperties?.id === section) {
|
|
38
|
-
nodes = [node];
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (!nodes) continue;
|
|
42
|
-
if (node.type === "heading") break;
|
|
43
|
-
nodes.push(node);
|
|
44
|
-
}
|
|
45
|
-
if (nodes)
|
|
46
|
-
return {
|
|
47
|
-
type: "root",
|
|
48
|
-
children: nodes
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function remarkInclude() {
|
|
52
|
-
const TagName = "include";
|
|
53
|
-
async function embedContent(file, heading, params, data) {
|
|
54
|
-
let content;
|
|
55
|
-
try {
|
|
56
|
-
content = (await fs.readFile(file)).toString();
|
|
57
|
-
} catch (e) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
`failed to read file ${file}
|
|
60
|
-
${e instanceof Error ? e.message : String(e)}`,
|
|
61
|
-
{ cause: e }
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
const ext = path.extname(file);
|
|
65
|
-
data._compiler?.addDependency(file);
|
|
66
|
-
if (params.lang || ext !== ".md" && ext !== ".mdx") {
|
|
67
|
-
const lang = params.lang ?? ext.slice(1);
|
|
68
|
-
return {
|
|
69
|
-
type: "code",
|
|
70
|
-
lang,
|
|
71
|
-
meta: params.meta,
|
|
72
|
-
value: content,
|
|
73
|
-
data: {}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const processor = (data._getProcessor ?? getDefaultProcessor)(
|
|
77
|
-
ext === ".mdx" ? "mdx" : "md"
|
|
78
|
-
);
|
|
79
|
-
let parsed = await baseProcessor.run(
|
|
80
|
-
processor.parse(fumaMatter(content).content)
|
|
81
|
-
);
|
|
82
|
-
if (heading) {
|
|
83
|
-
const extracted = extractSection(parsed, heading);
|
|
84
|
-
if (!extracted)
|
|
85
|
-
throw new Error(
|
|
86
|
-
`Cannot find section ${heading} in ${file}, make sure you have encapsulated the section in a <section id="${heading}"> tag.`
|
|
87
|
-
);
|
|
88
|
-
parsed = extracted;
|
|
89
|
-
}
|
|
90
|
-
await update(parsed, path.dirname(file), data);
|
|
91
|
-
return parsed;
|
|
92
|
-
}
|
|
93
|
-
async function update(tree, directory, data) {
|
|
94
|
-
const queue = [];
|
|
95
|
-
visit(
|
|
96
|
-
tree,
|
|
97
|
-
["mdxJsxFlowElement", "mdxJsxTextElement"],
|
|
98
|
-
(_node, _, parent) => {
|
|
99
|
-
const node = _node;
|
|
100
|
-
if (node.name !== TagName) return;
|
|
101
|
-
const params = {};
|
|
102
|
-
const specifier = flattenNode(node);
|
|
103
|
-
if (specifier.length === 0) return "skip";
|
|
104
|
-
for (const attr of node.attributes) {
|
|
105
|
-
if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
|
|
106
|
-
params[attr.name] = attr.value;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const { file: relativePath, section } = parseSpecifier(specifier);
|
|
110
|
-
const file = path.resolve(
|
|
111
|
-
"cwd" in params ? process.cwd() : directory,
|
|
112
|
-
relativePath
|
|
113
|
-
);
|
|
114
|
-
queue.push(
|
|
115
|
-
embedContent(file, section, params, data).then((replace) => {
|
|
116
|
-
Object.assign(
|
|
117
|
-
parent && parent.type === "paragraph" ? parent : node,
|
|
118
|
-
replace
|
|
119
|
-
);
|
|
120
|
-
})
|
|
121
|
-
);
|
|
122
|
-
return "skip";
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
await Promise.all(queue);
|
|
126
|
-
}
|
|
127
|
-
return async (tree, file) => {
|
|
128
|
-
await update(tree, path.dirname(file.path), file.data);
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
function getDefaultProcessor(format) {
|
|
132
|
-
const mdProcessor = unified().use(remarkParse);
|
|
133
|
-
if (format === "md") return mdProcessor;
|
|
134
|
-
return mdProcessor.use(remarkMdx);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export {
|
|
138
|
-
remarkInclude
|
|
139
|
-
};
|