fumadocs-core 16.4.1 → 16.4.3
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/advanced-DSlc7qa9.js +80 -0
- package/dist/advanced-DSlc7qa9.js.map +1 -0
- package/dist/algolia-BGWM-DkQ.js +49 -0
- package/dist/algolia-BGWM-DkQ.js.map +1 -0
- package/dist/algolia-FqjcaTcD.d.ts +68 -0
- package/dist/algolia-FqjcaTcD.d.ts.map +1 -0
- package/dist/breadcrumb.d.ts +29 -27
- package/dist/breadcrumb.d.ts.map +1 -0
- package/dist/breadcrumb.js +55 -72
- package/dist/breadcrumb.js.map +1 -0
- package/dist/chunk-C1JLJEPO.js +42 -0
- package/dist/codeblock-utils-Dh1w8ICD.d.ts +37 -0
- package/dist/codeblock-utils-Dh1w8ICD.d.ts.map +1 -0
- package/dist/content/github.d.ts +43 -32
- package/dist/content/github.d.ts.map +1 -0
- package/dist/content/github.js +29 -43
- package/dist/content/github.js.map +1 -0
- package/dist/content/index.d.ts +20 -13
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +17 -23
- package/dist/content/index.js.map +1 -0
- package/dist/content/mdx/preset-bundler.d.ts +22 -24
- package/dist/content/mdx/preset-bundler.d.ts.map +1 -0
- package/dist/content/mdx/preset-bundler.js +38 -69
- package/dist/content/mdx/preset-bundler.js.map +1 -0
- package/dist/content/mdx/preset-runtime.d.ts +22 -24
- package/dist/content/mdx/preset-runtime.d.ts.map +1 -0
- package/dist/content/mdx/preset-runtime.js +36 -68
- package/dist/content/mdx/preset-runtime.js.map +1 -0
- package/dist/content/toc.d.ts +7 -6
- package/dist/content/toc.d.ts.map +1 -0
- package/dist/content/toc.js +15 -19
- package/dist/content/toc.js.map +1 -0
- package/dist/definitions-DJAPG-2U.d.ts +62 -0
- package/dist/definitions-DJAPG-2U.d.ts.map +1 -0
- package/dist/dynamic-link.d.ts +7 -5
- package/dist/dynamic-link.d.ts.map +1 -0
- package/dist/dynamic-link.js +29 -27
- package/dist/dynamic-link.js.map +1 -0
- package/dist/fetch-B1nmMSyw.js +20 -0
- package/dist/fetch-B1nmMSyw.js.map +1 -0
- package/dist/framework/index.d.ts +38 -29
- package/dist/framework/index.d.ts.map +1 -0
- package/dist/framework/index.js +68 -17
- package/dist/framework/index.js.map +1 -0
- package/dist/framework/next.d.ts +15 -10
- package/dist/framework/next.d.ts.map +1 -0
- package/dist/framework/next.js +18 -26
- package/dist/framework/next.js.map +1 -0
- package/dist/framework/react-router.d.ts +15 -10
- package/dist/framework/react-router.d.ts.map +1 -0
- package/dist/framework/react-router.js +42 -55
- package/dist/framework/react-router.js.map +1 -0
- package/dist/framework/tanstack.d.ts +15 -10
- package/dist/framework/tanstack.d.ts.map +1 -0
- package/dist/framework/tanstack.js +54 -69
- package/dist/framework/tanstack.js.map +1 -0
- package/dist/framework/waku.d.ts +15 -10
- package/dist/framework/waku.d.ts.map +1 -0
- package/dist/framework/waku.js +47 -58
- package/dist/framework/waku.js.map +1 -0
- package/dist/highlight/client.d.ts +6 -7
- package/dist/highlight/client.d.ts.map +1 -0
- package/dist/highlight/client.js +22 -14
- package/dist/highlight/client.js.map +1 -0
- package/dist/highlight/index.d.ts +2 -30
- package/dist/highlight/index.js +3 -13
- package/dist/i18n/index.d.ts +2 -39
- package/dist/i18n/index.js +6 -7
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/middleware.d.ts +36 -28
- package/dist/i18n/middleware.d.ts.map +1 -0
- package/dist/i18n/middleware.js +55 -73
- package/dist/i18n/middleware.js.map +1 -0
- package/dist/icon-5lVe3l-0.js +19 -0
- package/dist/icon-5lVe3l-0.js.map +1 -0
- package/dist/index-BhVrX5J1.d.ts +41 -0
- package/dist/index-BhVrX5J1.d.ts.map +1 -0
- package/dist/index-Co_C8NEi.d.ts +380 -0
- package/dist/index-Co_C8NEi.d.ts.map +1 -0
- package/dist/link.d.ts +17 -15
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +29 -9
- package/dist/link.js.map +1 -0
- package/dist/mdast-utils-ix4DsXJP.js +40 -0
- package/dist/mdast-utils-ix4DsXJP.js.map +1 -0
- package/dist/mdx-plugins/codeblock-utils.d.ts +2 -29
- package/dist/mdx-plugins/codeblock-utils.js +71 -9
- package/dist/mdx-plugins/codeblock-utils.js.map +1 -0
- package/dist/mdx-plugins/index.d.ts +15 -20
- package/dist/mdx-plugins/index.js +18 -73
- package/dist/mdx-plugins/rehype-code.d.ts +2 -55
- package/dist/mdx-plugins/rehype-code.js +5 -15
- package/dist/mdx-plugins/rehype-toc.d.ts +2 -14
- package/dist/mdx-plugins/rehype-toc.js +3 -7
- package/dist/mdx-plugins/remark-admonition.d.ts +2 -20
- package/dist/mdx-plugins/remark-admonition.js +74 -8
- package/dist/mdx-plugins/remark-admonition.js.map +1 -0
- package/dist/mdx-plugins/remark-code-tab.d.ts +2 -30
- package/dist/mdx-plugins/remark-code-tab.js +183 -7
- package/dist/mdx-plugins/remark-code-tab.js.map +1 -0
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -27
- package/dist/mdx-plugins/remark-directive-admonition.js +60 -7
- package/dist/mdx-plugins/remark-directive-admonition.js.map +1 -0
- package/dist/mdx-plugins/remark-gfm.d.ts +2 -1
- package/dist/mdx-plugins/remark-gfm.js +3 -7
- package/dist/mdx-plugins/remark-heading.d.ts +2 -31
- package/dist/mdx-plugins/remark-heading.js +45 -8
- package/dist/mdx-plugins/remark-heading.js.map +1 -0
- package/dist/mdx-plugins/remark-image.d.ts +2 -57
- package/dist/mdx-plugins/remark-image.js +192 -7
- package/dist/mdx-plugins/remark-image.js.map +1 -0
- package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -40
- package/dist/mdx-plugins/remark-mdx-files.js +187 -7
- package/dist/mdx-plugins/remark-mdx-files.js.map +1 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -15
- package/dist/mdx-plugins/remark-mdx-mermaid.js +31 -7
- package/dist/mdx-plugins/remark-mdx-mermaid.js.map +1 -0
- package/dist/mdx-plugins/remark-npm.d.ts +2 -31
- package/dist/mdx-plugins/remark-npm.js +68 -8
- package/dist/mdx-plugins/remark-npm.js.map +1 -0
- package/dist/mdx-plugins/remark-steps.d.ts +2 -23
- package/dist/mdx-plugins/remark-steps.js +77 -7
- package/dist/mdx-plugins/remark-steps.js.map +1 -0
- package/dist/mdx-plugins/remark-structure.d.ts +2 -71
- package/dist/mdx-plugins/remark-structure.js +105 -11
- package/dist/mdx-plugins/remark-structure.js.map +1 -0
- package/dist/mixedbread-DSiQfUnN.js +88 -0
- package/dist/mixedbread-DSiQfUnN.js.map +1 -0
- package/dist/negotiation/index.d.ts +6 -4
- package/dist/negotiation/index.d.ts.map +1 -0
- package/dist/negotiation/index.js +41 -11
- package/dist/negotiation/index.js.map +1 -0
- package/dist/normalize-url-3WQZ_H_j.js +16 -0
- package/dist/normalize-url-3WQZ_H_j.js.map +1 -0
- package/dist/orama-cloud-BMDBfk05.js +84 -0
- package/dist/orama-cloud-BMDBfk05.js.map +1 -0
- package/dist/orama-cloud-legacy-CRZzZXWn.js +82 -0
- package/dist/orama-cloud-legacy-CRZzZXWn.js.map +1 -0
- package/dist/page-tree/index.d.ts +23 -11
- package/dist/page-tree/index.d.ts.map +1 -0
- package/dist/page-tree/index.js +3 -17
- package/dist/path-D6M0ZQvO.js +60 -0
- package/dist/path-D6M0ZQvO.js.map +1 -0
- package/dist/rehype-code-Bd52chOe.d.ts +58 -0
- package/dist/rehype-code-Bd52chOe.d.ts.map +1 -0
- package/dist/rehype-code-Dr35mETC.js +241 -0
- package/dist/rehype-code-Dr35mETC.js.map +1 -0
- package/dist/rehype-toc-BJVsblvp.d.ts +18 -0
- package/dist/rehype-toc-BJVsblvp.d.ts.map +1 -0
- package/dist/rehype-toc-Dqgey2tW.js +143 -0
- package/dist/rehype-toc-Dqgey2tW.js.map +1 -0
- package/dist/remark-admonition-Chku_iWO.d.ts +22 -0
- package/dist/remark-admonition-Chku_iWO.d.ts.map +1 -0
- package/dist/remark-code-tab-C0f6BPcw.d.ts +32 -0
- package/dist/remark-code-tab-C0f6BPcw.d.ts.map +1 -0
- package/dist/remark-directive-admonition-CBwJdh9z.d.ts +36 -0
- package/dist/remark-directive-admonition-CBwJdh9z.d.ts.map +1 -0
- package/dist/remark-gfm-B2aZXutO.d.ts +2 -0
- package/dist/remark-heading-CUAe4zIu.d.ts +37 -0
- package/dist/remark-heading-CUAe4zIu.d.ts.map +1 -0
- package/dist/remark-image-DMRnxsRO.d.ts +65 -0
- package/dist/remark-image-DMRnxsRO.d.ts.map +1 -0
- package/dist/remark-mdx-files-B5KMXnfh.d.ts +56 -0
- package/dist/remark-mdx-files-B5KMXnfh.d.ts.map +1 -0
- package/dist/remark-mdx-mermaid-C_4W5gfj.d.ts +17 -0
- package/dist/remark-mdx-mermaid-C_4W5gfj.d.ts.map +1 -0
- package/dist/remark-npm-CykFgJn2.d.ts +36 -0
- package/dist/remark-npm-CykFgJn2.d.ts.map +1 -0
- package/dist/remark-steps-5-DmLVv3.d.ts +28 -0
- package/dist/remark-steps-5-DmLVv3.d.ts.map +1 -0
- package/dist/remark-structure-CszwnaMR.d.ts +77 -0
- package/dist/remark-structure-CszwnaMR.d.ts.map +1 -0
- package/dist/remove-undefined-B7zJF-YS.js +19 -0
- package/dist/remove-undefined-B7zJF-YS.js.map +1 -0
- package/dist/search/algolia.d.ts +3 -69
- package/dist/search/algolia.js +69 -63
- package/dist/search/algolia.js.map +1 -0
- package/dist/search/client.d.ts +143 -114
- package/dist/search/client.d.ts.map +1 -0
- package/dist/search/client.js +98 -91
- package/dist/search/client.js.map +1 -0
- package/dist/search/index.d.ts +20 -18
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +3 -7
- package/dist/search/orama-cloud-legacy.d.ts +81 -0
- package/dist/search/orama-cloud-legacy.d.ts.map +1 -0
- package/dist/search/orama-cloud-legacy.js +50 -0
- package/dist/search/orama-cloud-legacy.js.map +1 -0
- package/dist/search/orama-cloud.d.ts +72 -70
- package/dist/search/orama-cloud.d.ts.map +1 -0
- package/dist/search/orama-cloud.js +46 -54
- package/dist/search/orama-cloud.js.map +1 -0
- package/dist/search/server.d.ts +6 -136
- package/dist/search/server.js +292 -369
- package/dist/search/server.js.map +1 -0
- package/dist/search-DcH54N2x.js +44 -0
- package/dist/search-DcH54N2x.js.map +1 -0
- package/dist/server-BzFuYBxW.d.ts +133 -0
- package/dist/server-BzFuYBxW.d.ts.map +1 -0
- package/dist/shiki-Bdk0JGsB.d.ts +33 -0
- package/dist/shiki-Bdk0JGsB.d.ts.map +1 -0
- package/dist/shiki-DoHr6fEj.js +80 -0
- package/dist/shiki-DoHr6fEj.js.map +1 -0
- package/dist/source/client/index.d.ts +7 -5
- package/dist/source/client/index.d.ts.map +1 -0
- package/dist/source/client/index.js +24 -35
- package/dist/source/client/index.js.map +1 -0
- package/dist/source/index.d.ts +3 -42
- package/dist/source/index.js +599 -752
- package/dist/source/index.js.map +1 -0
- package/dist/source/plugins/lucide-icons.d.ts +7 -7
- package/dist/source/plugins/lucide-icons.d.ts.map +1 -0
- package/dist/source/plugins/lucide-icons.js +21 -20
- package/dist/source/plugins/lucide-icons.js.map +1 -0
- package/dist/source/plugins/slugs.d.ts +3 -0
- package/dist/source/plugins/slugs.js +65 -0
- package/dist/source/plugins/slugs.js.map +1 -0
- package/dist/source/schema.d.ts +17 -14
- package/dist/source/schema.d.ts.map +1 -0
- package/dist/source/schema.js +26 -22
- package/dist/source/schema.js.map +1 -0
- package/dist/static-DAjBQpus.js +51 -0
- package/dist/static-DAjBQpus.js.map +1 -0
- package/dist/toc.d.ts +38 -25
- package/dist/toc.d.ts.map +1 -0
- package/dist/toc.js +123 -136
- package/dist/toc.js.map +1 -0
- package/dist/util-92szu3Vf.js +10 -0
- package/dist/util-92szu3Vf.js.map +1 -0
- package/dist/util-ofJFdM-e.d.ts +8 -0
- package/dist/util-ofJFdM-e.d.ts.map +1 -0
- package/dist/utils/use-effect-event.d.ts +3 -1
- package/dist/utils/use-effect-event.d.ts.map +1 -0
- package/dist/utils/use-effect-event.js +16 -13
- package/dist/utils/use-effect-event.js.map +1 -0
- package/dist/utils/use-media-query.d.ts +3 -1
- package/dist/utils/use-media-query.d.ts.map +1 -0
- package/dist/utils/use-media-query.js +20 -20
- package/dist/utils/use-media-query.js.map +1 -0
- package/dist/utils/use-on-change.d.ts +3 -1
- package/dist/utils/use-on-change.d.ts.map +1 -0
- package/dist/utils/use-on-change.js +23 -7
- package/dist/utils/use-on-change.js.map +1 -0
- package/dist/utils-bAoAH1Rh.js +134 -0
- package/dist/utils-bAoAH1Rh.js.map +1 -0
- package/package.json +72 -65
- package/dist/algolia-IZEDLPHE.js +0 -58
- package/dist/chunk-5PMI7QDD.js +0 -220
- package/dist/chunk-ADBHPKXG.js +0 -78
- package/dist/chunk-APKPSBSB.js +0 -74
- package/dist/chunk-CH7YHH7V.js +0 -222
- package/dist/chunk-EFVXL2PP.js +0 -144
- package/dist/chunk-EMWGTXSW.js +0 -19
- package/dist/chunk-FAEPKD7U.js +0 -20
- package/dist/chunk-FUUVPEA5.js +0 -29
- package/dist/chunk-GINBKBVQ.js +0 -12
- package/dist/chunk-GLRQBLGN.js +0 -59
- package/dist/chunk-JUF4WZ6G.js +0 -117
- package/dist/chunk-K4WNLOVQ.js +0 -75
- package/dist/chunk-L4JKQWCM.js +0 -131
- package/dist/chunk-MA6O2UUE.js +0 -50
- package/dist/chunk-ONG4RVCR.js +0 -8
- package/dist/chunk-OTD7MV33.js +0 -53
- package/dist/chunk-PFNP6PEB.js +0 -11
- package/dist/chunk-SH7BNTG7.js +0 -38
- package/dist/chunk-TWIDBWFG.js +0 -84
- package/dist/chunk-U67V476Y.js +0 -35
- package/dist/chunk-VLSDGCJE.js +0 -47
- package/dist/chunk-W6WTLKRA.js +0 -73
- package/dist/chunk-X2HFD5QJ.js +0 -275
- package/dist/chunk-XJ6ZQNEX.js +0 -91
- package/dist/chunk-XN2LKXFZ.js +0 -101
- package/dist/chunk-XOFXGHS4.js +0 -93
- package/dist/chunk-XZSI7AHE.js +0 -67
- package/dist/chunk-YVVDKJ2H.js +0 -34
- package/dist/chunk-ZMWYLUDP.js +0 -21
- package/dist/definitions-pJ7PybYY.d.ts +0 -60
- package/dist/fetch-IBTWQCJR.js +0 -22
- package/dist/loader-_E2HOdV0.d.ts +0 -333
- package/dist/mixedbread-A3WLENES.js +0 -117
- package/dist/orama-cloud-UZAPMPFV.js +0 -93
- package/dist/static-A2YJ5TXV.js +0 -62
- package/dist/util-bZU2QeJ2.d.ts +0 -6
package/dist/source/index.js
CHANGED
|
@@ -1,789 +1,636 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "../
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
extname,
|
|
8
|
-
joinPath,
|
|
9
|
-
path_exports,
|
|
10
|
-
slash,
|
|
11
|
-
splitPath
|
|
12
|
-
} from "../chunk-XZSI7AHE.js";
|
|
13
|
-
import {
|
|
14
|
-
normalizeUrl
|
|
15
|
-
} from "../chunk-PFNP6PEB.js";
|
|
16
|
-
import {
|
|
17
|
-
visit
|
|
18
|
-
} from "../chunk-L4JKQWCM.js";
|
|
19
|
-
import "../chunk-U67V476Y.js";
|
|
1
|
+
import { t as normalizeUrl } from "../normalize-url-3WQZ_H_j.js";
|
|
2
|
+
import { c as visit } from "../utils-bAoAH1Rh.js";
|
|
3
|
+
import { a as path_exports, i as joinPath, n as dirname, o as slash, r as extname, s as splitPath, t as basename } from "../path-D6M0ZQvO.js";
|
|
4
|
+
import { getSlugs, slugsPlugin } from "./plugins/slugs.js";
|
|
5
|
+
import { t as iconPlugin } from "../icon-5lVe3l-0.js";
|
|
6
|
+
import path from "node:path";
|
|
20
7
|
|
|
21
|
-
|
|
8
|
+
//#region src/source/source.ts
|
|
22
9
|
function multiple(sources) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return out;
|
|
10
|
+
const out = { files: [] };
|
|
11
|
+
for (const [type, source$1] of Object.entries(sources)) for (const file of source$1.files) out.files.push({
|
|
12
|
+
...file,
|
|
13
|
+
data: {
|
|
14
|
+
...file.data,
|
|
15
|
+
type
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return out;
|
|
36
19
|
}
|
|
37
20
|
function source(config) {
|
|
38
|
-
|
|
39
|
-
files: [...config.pages, ...config.metas]
|
|
40
|
-
};
|
|
21
|
+
return { files: [...config.pages, ...config.metas] };
|
|
41
22
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
23
|
+
/**
|
|
24
|
+
* update a source object in-place.
|
|
25
|
+
*/
|
|
26
|
+
function update(source$1) {
|
|
27
|
+
return {
|
|
28
|
+
files(fn) {
|
|
29
|
+
source$1.files = fn(source$1.files);
|
|
30
|
+
return this;
|
|
31
|
+
},
|
|
32
|
+
page(fn) {
|
|
33
|
+
for (let i = 0; i < source$1.files.length; i++) {
|
|
34
|
+
const file = source$1.files[i];
|
|
35
|
+
if (file.type === "page") source$1.files[i] = fn(file);
|
|
36
|
+
}
|
|
37
|
+
return this;
|
|
38
|
+
},
|
|
39
|
+
meta(fn) {
|
|
40
|
+
for (let i = 0; i < source$1.files.length; i++) {
|
|
41
|
+
const file = source$1.files[i];
|
|
42
|
+
if (file.type === "meta") source$1.files[i] = fn(file);
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
},
|
|
46
|
+
build() {
|
|
47
|
+
return source$1;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
66
50
|
}
|
|
67
51
|
|
|
68
|
-
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/source/storage/file-system.ts
|
|
54
|
+
/**
|
|
55
|
+
* In memory file system.
|
|
56
|
+
*/
|
|
69
57
|
var FileSystem = class {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const segments = splitPath(path2);
|
|
125
|
-
for (let i = 0; i < segments.length; i++) {
|
|
126
|
-
const segment = segments.slice(0, i + 1).join("/");
|
|
127
|
-
if (this.folders.has(segment)) continue;
|
|
128
|
-
this.folders.set(segment, []);
|
|
129
|
-
this.folders.get(dirname(segment)).push(segment);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
58
|
+
constructor(inherit) {
|
|
59
|
+
this.files = /* @__PURE__ */ new Map();
|
|
60
|
+
this.folders = /* @__PURE__ */ new Map();
|
|
61
|
+
if (inherit) {
|
|
62
|
+
for (const [k, v] of inherit.folders) this.folders.set(k, v);
|
|
63
|
+
for (const [k, v] of inherit.files) this.files.set(k, v);
|
|
64
|
+
} else this.folders.set("", []);
|
|
65
|
+
}
|
|
66
|
+
read(path$1) {
|
|
67
|
+
return this.files.get(path$1);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* get the direct children of folder (in virtual file path)
|
|
71
|
+
*/
|
|
72
|
+
readDir(path$1) {
|
|
73
|
+
return this.folders.get(path$1);
|
|
74
|
+
}
|
|
75
|
+
write(path$1, file) {
|
|
76
|
+
if (!this.files.has(path$1)) {
|
|
77
|
+
const dir = dirname(path$1);
|
|
78
|
+
this.makeDir(dir);
|
|
79
|
+
this.readDir(dir)?.push(path$1);
|
|
80
|
+
}
|
|
81
|
+
this.files.set(path$1, file);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Delete files at specified path.
|
|
85
|
+
*
|
|
86
|
+
* @param path - the target path.
|
|
87
|
+
* @param [recursive=false] - if set to `true`, it will also delete directories.
|
|
88
|
+
*/
|
|
89
|
+
delete(path$1, recursive = false) {
|
|
90
|
+
if (this.files.delete(path$1)) return true;
|
|
91
|
+
if (recursive) {
|
|
92
|
+
const folder = this.folders.get(path$1);
|
|
93
|
+
if (!folder) return false;
|
|
94
|
+
this.folders.delete(path$1);
|
|
95
|
+
for (const child of folder) this.delete(child);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
getFiles() {
|
|
101
|
+
return Array.from(this.files.keys());
|
|
102
|
+
}
|
|
103
|
+
makeDir(path$1) {
|
|
104
|
+
const segments = splitPath(path$1);
|
|
105
|
+
for (let i = 0; i < segments.length; i++) {
|
|
106
|
+
const segment = segments.slice(0, i + 1).join("/");
|
|
107
|
+
if (this.folders.has(segment)) continue;
|
|
108
|
+
this.folders.set(segment, []);
|
|
109
|
+
this.folders.get(dirname(segment)).push(segment);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
132
112
|
};
|
|
133
113
|
|
|
134
|
-
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/source/storage/content.ts
|
|
135
116
|
function isLocaleValid(locale) {
|
|
136
|
-
|
|
117
|
+
return locale.length > 0 && !/\d+/.test(locale);
|
|
137
118
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return [path2];
|
|
156
|
-
}
|
|
119
|
+
const parsers = {
|
|
120
|
+
dir(path$1) {
|
|
121
|
+
const [locale, ...segs] = path$1.split("/");
|
|
122
|
+
if (locale && segs.length > 0 && isLocaleValid(locale)) return [segs.join("/"), locale];
|
|
123
|
+
return [path$1];
|
|
124
|
+
},
|
|
125
|
+
dot(path$1) {
|
|
126
|
+
const dir = dirname(path$1);
|
|
127
|
+
const parts = basename(path$1).split(".");
|
|
128
|
+
if (parts.length < 3) return [path$1];
|
|
129
|
+
const [locale] = parts.splice(parts.length - 2, 1);
|
|
130
|
+
if (!isLocaleValid(locale)) return [path$1];
|
|
131
|
+
return [joinPath(dir, parts.join(".")), locale];
|
|
132
|
+
},
|
|
133
|
+
none(path$1) {
|
|
134
|
+
return [path$1];
|
|
135
|
+
}
|
|
157
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* @param defaultLanguage - language to use when i18n is not configured.
|
|
139
|
+
* @returns a map of locale and its content storage.
|
|
140
|
+
*
|
|
141
|
+
* in the storage, locale codes are removed from file paths, hence the same file will have same file paths in every storage.
|
|
142
|
+
*/
|
|
158
143
|
function buildContentStorage(loaderConfig, defaultLanguage) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
scan(fallbackLang);
|
|
206
|
-
storage = new FileSystem(storages[fallbackLang]);
|
|
207
|
-
} else {
|
|
208
|
-
storage = new FileSystem();
|
|
209
|
-
}
|
|
210
|
-
for (const { pathWithoutLocale, file } of normalized.get(lang) ?? []) {
|
|
211
|
-
storage.write(pathWithoutLocale, file);
|
|
212
|
-
}
|
|
213
|
-
const context = {
|
|
214
|
-
storage
|
|
215
|
-
};
|
|
216
|
-
for (const plugin of plugins) {
|
|
217
|
-
plugin.transformStorage?.(context);
|
|
218
|
-
}
|
|
219
|
-
storages[lang] = storage;
|
|
220
|
-
}
|
|
221
|
-
for (const lang of i18n.languages) scan(lang);
|
|
222
|
-
return storages;
|
|
144
|
+
const { source: source$1, plugins = [], i18n = {
|
|
145
|
+
defaultLanguage,
|
|
146
|
+
parser: "none",
|
|
147
|
+
languages: [defaultLanguage]
|
|
148
|
+
} } = loaderConfig;
|
|
149
|
+
const parser = parsers[i18n.parser ?? "dot"];
|
|
150
|
+
const storages = {};
|
|
151
|
+
const normalized = /* @__PURE__ */ new Map();
|
|
152
|
+
for (const inputFile of source$1.files) {
|
|
153
|
+
let file;
|
|
154
|
+
if (inputFile.type === "page") file = {
|
|
155
|
+
format: "page",
|
|
156
|
+
path: normalizePath(inputFile.path),
|
|
157
|
+
slugs: inputFile.slugs,
|
|
158
|
+
data: inputFile.data,
|
|
159
|
+
absolutePath: inputFile.absolutePath
|
|
160
|
+
};
|
|
161
|
+
else file = {
|
|
162
|
+
format: "meta",
|
|
163
|
+
path: normalizePath(inputFile.path),
|
|
164
|
+
absolutePath: inputFile.absolutePath,
|
|
165
|
+
data: inputFile.data
|
|
166
|
+
};
|
|
167
|
+
const [pathWithoutLocale, locale = i18n.defaultLanguage] = parser(file.path);
|
|
168
|
+
const list = normalized.get(locale) ?? [];
|
|
169
|
+
list.push({
|
|
170
|
+
pathWithoutLocale,
|
|
171
|
+
file
|
|
172
|
+
});
|
|
173
|
+
normalized.set(locale, list);
|
|
174
|
+
}
|
|
175
|
+
const fallbackLang = i18n.fallbackLanguage !== null ? i18n.fallbackLanguage ?? i18n.defaultLanguage : null;
|
|
176
|
+
function scan(lang) {
|
|
177
|
+
if (storages[lang]) return;
|
|
178
|
+
let storage;
|
|
179
|
+
if (fallbackLang && fallbackLang !== lang) {
|
|
180
|
+
scan(fallbackLang);
|
|
181
|
+
storage = new FileSystem(storages[fallbackLang]);
|
|
182
|
+
} else storage = new FileSystem();
|
|
183
|
+
for (const { pathWithoutLocale, file } of normalized.get(lang) ?? []) storage.write(pathWithoutLocale, file);
|
|
184
|
+
const context = { storage };
|
|
185
|
+
for (const plugin of plugins) plugin.transformStorage?.(context);
|
|
186
|
+
storages[lang] = storage;
|
|
187
|
+
}
|
|
188
|
+
for (const lang of i18n.languages) scan(lang);
|
|
189
|
+
return storages;
|
|
223
190
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
191
|
+
/**
|
|
192
|
+
* @param path - Relative path
|
|
193
|
+
* @returns Normalized path, with no trailing/leading slashes
|
|
194
|
+
* @throws Throws error if path starts with `./` or `../`
|
|
195
|
+
*/
|
|
196
|
+
function normalizePath(path$1) {
|
|
197
|
+
const segments = splitPath(slash(path$1));
|
|
198
|
+
if (segments[0] === "." || segments[0] === "..") throw new Error("It must not start with './' or '../'");
|
|
199
|
+
return segments.join("/");
|
|
229
200
|
}
|
|
230
201
|
|
|
231
|
-
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/source/page-tree/transformer-fallback.ts
|
|
232
204
|
function transformerFallback() {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
205
|
+
const addedFiles = /* @__PURE__ */ new Set();
|
|
206
|
+
return {
|
|
207
|
+
root(root) {
|
|
208
|
+
const isolatedStorage = new FileSystem();
|
|
209
|
+
for (const file of this.storage.getFiles()) {
|
|
210
|
+
if (addedFiles.has(file)) continue;
|
|
211
|
+
const content = this.storage.read(file);
|
|
212
|
+
if (content) isolatedStorage.write(file, content);
|
|
213
|
+
}
|
|
214
|
+
if (isolatedStorage.getFiles().length === 0) return root;
|
|
215
|
+
root.fallback = this.builder.build(isolatedStorage, {
|
|
216
|
+
...this.options,
|
|
217
|
+
id: `fallback-${root.$id ?? ""}`,
|
|
218
|
+
generateFallback: false
|
|
219
|
+
});
|
|
220
|
+
addedFiles.clear();
|
|
221
|
+
return root;
|
|
222
|
+
},
|
|
223
|
+
file(node, file) {
|
|
224
|
+
if (file) addedFiles.add(file);
|
|
225
|
+
return node;
|
|
226
|
+
},
|
|
227
|
+
folder(node, _dir, metaPath) {
|
|
228
|
+
if (metaPath) addedFiles.add(metaPath);
|
|
229
|
+
return node;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
260
232
|
}
|
|
261
233
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/source/page-tree/builder.ts
|
|
236
|
+
const group = /^\((?<name>.+)\)$/;
|
|
237
|
+
const link = /^(?<external>external:)?(?:\[(?<icon>[^\]]+)])?\[(?<name>[^\]]+)]\((?<url>[^)]+)\)$/;
|
|
238
|
+
const separator = /^---(?:\[(?<icon>[^\]]+)])?(?<name>.+)---|^---$/;
|
|
239
|
+
const rest = "...";
|
|
240
|
+
const restReversed = "z...a";
|
|
241
|
+
const extractPrefix = "...";
|
|
242
|
+
const excludePrefix = "!";
|
|
270
243
|
function createPageTreeBuilder(loaderConfig) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
return "_" + nextId++;
|
|
305
|
-
}
|
|
306
|
-
}).root();
|
|
307
|
-
}
|
|
308
|
-
return out;
|
|
309
|
-
}
|
|
310
|
-
};
|
|
244
|
+
const { plugins = [], url, pageTree: defaultOptions = {} } = loaderConfig;
|
|
245
|
+
return {
|
|
246
|
+
build(storage, options = defaultOptions) {
|
|
247
|
+
const key = "";
|
|
248
|
+
return this.buildI18n({ [key]: storage }, options)[key];
|
|
249
|
+
},
|
|
250
|
+
buildI18n(storages, options = defaultOptions) {
|
|
251
|
+
let nextId = 0;
|
|
252
|
+
const out = {};
|
|
253
|
+
const transformers = [];
|
|
254
|
+
if (options.transformers) transformers.push(...options.transformers);
|
|
255
|
+
for (const plugin of plugins) if (plugin.transformPageTree) transformers.push(plugin.transformPageTree);
|
|
256
|
+
if (options.generateFallback ?? true) transformers.push(transformerFallback());
|
|
257
|
+
for (const [locale, storage] of Object.entries(storages)) {
|
|
258
|
+
let rootId = locale.length === 0 ? "root" : locale;
|
|
259
|
+
if (options.id) rootId = `${options.id}-${rootId}`;
|
|
260
|
+
out[locale] = createPageTreeBuilderUtils({
|
|
261
|
+
rootId,
|
|
262
|
+
transformers,
|
|
263
|
+
builder: this,
|
|
264
|
+
options,
|
|
265
|
+
getUrl: url,
|
|
266
|
+
locale,
|
|
267
|
+
storage,
|
|
268
|
+
storages,
|
|
269
|
+
generateNodeId() {
|
|
270
|
+
return "_" + nextId++;
|
|
271
|
+
}
|
|
272
|
+
}).root();
|
|
273
|
+
}
|
|
274
|
+
return out;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
311
277
|
}
|
|
312
278
|
function createFlattenPathResolver(storage) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
279
|
+
const map = /* @__PURE__ */ new Map();
|
|
280
|
+
const files = storage.getFiles();
|
|
281
|
+
for (const file of files) {
|
|
282
|
+
const content = storage.read(file);
|
|
283
|
+
const flattenPath = file.substring(0, file.length - extname(file).length);
|
|
284
|
+
map.set(flattenPath + "." + content.format, file);
|
|
285
|
+
}
|
|
286
|
+
return (name, format) => {
|
|
287
|
+
return map.get(name + "." + format) ?? name;
|
|
288
|
+
};
|
|
323
289
|
}
|
|
324
290
|
function createPageTreeBuilderUtils(ctx) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
file: path2
|
|
482
|
-
} : void 0
|
|
483
|
-
};
|
|
484
|
-
visitedPaths.add(path2);
|
|
485
|
-
for (const transformer of transformers) {
|
|
486
|
-
if (!transformer.file) continue;
|
|
487
|
-
item = transformer.file.call(ctx, item, path2);
|
|
488
|
-
}
|
|
489
|
-
return item;
|
|
490
|
-
},
|
|
491
|
-
root() {
|
|
492
|
-
const folder = this.folder("", true);
|
|
493
|
-
let root = {
|
|
494
|
-
$id: ctx.rootId,
|
|
495
|
-
name: folder.name || "Docs",
|
|
496
|
-
children: folder.children
|
|
497
|
-
};
|
|
498
|
-
for (const transformer of ctx.transformers) {
|
|
499
|
-
if (!transformer.root) continue;
|
|
500
|
-
root = transformer.root.call(ctx, root);
|
|
501
|
-
}
|
|
502
|
-
return root;
|
|
503
|
-
}
|
|
504
|
-
};
|
|
291
|
+
const resolveFlattenPath = createFlattenPathResolver(ctx.storage);
|
|
292
|
+
const visitedPaths = /* @__PURE__ */ new Set();
|
|
293
|
+
function nextNodeId(localId = ctx.generateNodeId()) {
|
|
294
|
+
return `${ctx.rootId}:${localId}`;
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
buildPaths(paths, reversed = false) {
|
|
298
|
+
const items = [];
|
|
299
|
+
const folders = [];
|
|
300
|
+
const sortedPaths = paths.sort((a, b) => a.localeCompare(b) * (reversed ? -1 : 1));
|
|
301
|
+
for (const path$1 of sortedPaths) {
|
|
302
|
+
const fileNode = this.file(path$1);
|
|
303
|
+
if (fileNode) {
|
|
304
|
+
if (basename(path$1, extname(path$1)) === "index") items.unshift(fileNode);
|
|
305
|
+
else items.push(fileNode);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
const dirNode = this.folder(path$1, false);
|
|
309
|
+
if (dirNode) folders.push(dirNode);
|
|
310
|
+
}
|
|
311
|
+
items.push(...folders);
|
|
312
|
+
return items;
|
|
313
|
+
},
|
|
314
|
+
resolveFolderItem(folderPath, item) {
|
|
315
|
+
if (item === rest || item === restReversed) return item;
|
|
316
|
+
let match = separator.exec(item);
|
|
317
|
+
if (match?.groups) {
|
|
318
|
+
let node = {
|
|
319
|
+
$id: nextNodeId(),
|
|
320
|
+
type: "separator",
|
|
321
|
+
icon: match.groups.icon,
|
|
322
|
+
name: match.groups.name
|
|
323
|
+
};
|
|
324
|
+
for (const transformer of ctx.transformers) {
|
|
325
|
+
if (!transformer.separator) continue;
|
|
326
|
+
node = transformer.separator.call(ctx, node);
|
|
327
|
+
}
|
|
328
|
+
return [node];
|
|
329
|
+
}
|
|
330
|
+
match = link.exec(item);
|
|
331
|
+
if (match?.groups) {
|
|
332
|
+
const { icon, url, name, external } = match.groups;
|
|
333
|
+
let node = {
|
|
334
|
+
$id: nextNodeId(),
|
|
335
|
+
type: "page",
|
|
336
|
+
icon,
|
|
337
|
+
name,
|
|
338
|
+
url,
|
|
339
|
+
external: external ? true : void 0
|
|
340
|
+
};
|
|
341
|
+
for (const transformer of ctx.transformers) {
|
|
342
|
+
if (!transformer.file) continue;
|
|
343
|
+
node = transformer.file.call(ctx, node);
|
|
344
|
+
}
|
|
345
|
+
return [node];
|
|
346
|
+
}
|
|
347
|
+
const isExcept = item.startsWith(excludePrefix);
|
|
348
|
+
const isExtract = !isExcept && item.startsWith(extractPrefix);
|
|
349
|
+
let filename = item;
|
|
350
|
+
if (isExcept) filename = item.slice(1);
|
|
351
|
+
else if (isExtract) filename = item.slice(3);
|
|
352
|
+
const path$1 = resolveFlattenPath(joinPath(folderPath, filename), "page");
|
|
353
|
+
if (isExcept) {
|
|
354
|
+
visitedPaths.add(path$1);
|
|
355
|
+
return [];
|
|
356
|
+
}
|
|
357
|
+
const dirNode = this.folder(path$1, false);
|
|
358
|
+
if (dirNode) return isExtract ? dirNode.children : [dirNode];
|
|
359
|
+
const fileNode = this.file(path$1);
|
|
360
|
+
return fileNode ? [fileNode] : [];
|
|
361
|
+
},
|
|
362
|
+
folder(folderPath, isGlobalRoot) {
|
|
363
|
+
const { storage, options, transformers } = ctx;
|
|
364
|
+
const files = storage.readDir(folderPath);
|
|
365
|
+
if (!files) return;
|
|
366
|
+
const metaPath = resolveFlattenPath(joinPath(folderPath, "meta"), "meta");
|
|
367
|
+
const indexPath = resolveFlattenPath(joinPath(folderPath, "index"), "page");
|
|
368
|
+
let meta = storage.read(metaPath);
|
|
369
|
+
if (meta && meta.format !== "meta") meta = void 0;
|
|
370
|
+
const metadata = meta?.data ?? {};
|
|
371
|
+
const { root = isGlobalRoot, pages } = metadata;
|
|
372
|
+
let index;
|
|
373
|
+
let children;
|
|
374
|
+
if (pages) {
|
|
375
|
+
const resolved = pages.flatMap((item) => this.resolveFolderItem(folderPath, item));
|
|
376
|
+
if (!root && !visitedPaths.has(indexPath)) index = this.file(indexPath);
|
|
377
|
+
for (let i = 0; i < resolved.length; i++) {
|
|
378
|
+
const item = resolved[i];
|
|
379
|
+
if (item !== rest && item !== restReversed) continue;
|
|
380
|
+
const items = this.buildPaths(files.filter((file) => !visitedPaths.has(file)), item === restReversed);
|
|
381
|
+
resolved.splice(i, 1, ...items);
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
children = resolved;
|
|
385
|
+
} else {
|
|
386
|
+
if (!root && !visitedPaths.has(indexPath)) index = this.file(indexPath);
|
|
387
|
+
children = this.buildPaths(files.filter((file) => !visitedPaths.has(file)));
|
|
388
|
+
}
|
|
389
|
+
let node = {
|
|
390
|
+
type: "folder",
|
|
391
|
+
name: metadata.title ?? index?.name ?? (() => {
|
|
392
|
+
const folderName = basename(folderPath);
|
|
393
|
+
return pathToName(group.exec(folderName)?.[1] ?? folderName);
|
|
394
|
+
})(),
|
|
395
|
+
icon: metadata.icon ?? index?.icon,
|
|
396
|
+
root: metadata.root,
|
|
397
|
+
defaultOpen: metadata.defaultOpen,
|
|
398
|
+
description: metadata.description,
|
|
399
|
+
collapsible: metadata.collapsible,
|
|
400
|
+
index,
|
|
401
|
+
children,
|
|
402
|
+
$id: nextNodeId(folderPath),
|
|
403
|
+
$ref: !options.noRef && meta ? { metaFile: metaPath } : void 0
|
|
404
|
+
};
|
|
405
|
+
visitedPaths.add(folderPath);
|
|
406
|
+
for (const transformer of transformers) {
|
|
407
|
+
if (!transformer.folder) continue;
|
|
408
|
+
node = transformer.folder.call(ctx, node, folderPath, metaPath);
|
|
409
|
+
}
|
|
410
|
+
return node;
|
|
411
|
+
},
|
|
412
|
+
file(path$1) {
|
|
413
|
+
const { options, getUrl, storage, locale, transformers } = ctx;
|
|
414
|
+
const page = storage.read(path$1);
|
|
415
|
+
if (page?.format !== "page") return;
|
|
416
|
+
const { title, description, icon } = page.data;
|
|
417
|
+
let item = {
|
|
418
|
+
$id: nextNodeId(path$1),
|
|
419
|
+
type: "page",
|
|
420
|
+
name: title ?? pathToName(basename(path$1, extname(path$1))),
|
|
421
|
+
description,
|
|
422
|
+
icon,
|
|
423
|
+
url: getUrl(page.slugs, locale),
|
|
424
|
+
$ref: !options.noRef ? { file: path$1 } : void 0
|
|
425
|
+
};
|
|
426
|
+
visitedPaths.add(path$1);
|
|
427
|
+
for (const transformer of transformers) {
|
|
428
|
+
if (!transformer.file) continue;
|
|
429
|
+
item = transformer.file.call(ctx, item, path$1);
|
|
430
|
+
}
|
|
431
|
+
return item;
|
|
432
|
+
},
|
|
433
|
+
root() {
|
|
434
|
+
const folder = this.folder("", true);
|
|
435
|
+
let root = {
|
|
436
|
+
$id: ctx.rootId,
|
|
437
|
+
name: folder.name || "Docs",
|
|
438
|
+
children: folder.children
|
|
439
|
+
};
|
|
440
|
+
for (const transformer of ctx.transformers) {
|
|
441
|
+
if (!transformer.root) continue;
|
|
442
|
+
root = transformer.root.call(ctx, root);
|
|
443
|
+
}
|
|
444
|
+
return root;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
505
447
|
}
|
|
448
|
+
/**
|
|
449
|
+
* Get item name from file name
|
|
450
|
+
*
|
|
451
|
+
* @param name - file name
|
|
452
|
+
*/
|
|
506
453
|
function pathToName(name) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
return result.join("");
|
|
454
|
+
const result = [];
|
|
455
|
+
for (const c of name) if (result.length === 0) result.push(c.toLocaleUpperCase());
|
|
456
|
+
else if (c === "-") result.push(" ");
|
|
457
|
+
else result.push(c);
|
|
458
|
+
return result.join("");
|
|
514
459
|
}
|
|
515
460
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
pre: 1,
|
|
519
|
-
default: 0,
|
|
520
|
-
post: -1
|
|
521
|
-
};
|
|
522
|
-
function buildPlugins(plugins, sort = true) {
|
|
523
|
-
const flatten = [];
|
|
524
|
-
for (const plugin of plugins) {
|
|
525
|
-
if (Array.isArray(plugin)) flatten.push(...buildPlugins(plugin, false));
|
|
526
|
-
else if (plugin) flatten.push(plugin);
|
|
527
|
-
}
|
|
528
|
-
if (sort)
|
|
529
|
-
return flatten.sort(
|
|
530
|
-
(a, b) => priorityMap[b.enforce ?? "default"] - priorityMap[a.enforce ?? "default"]
|
|
531
|
-
);
|
|
532
|
-
return flatten;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
// src/source/plugins/slugs.ts
|
|
536
|
-
function slugsPlugin(slugsFn) {
|
|
537
|
-
function isIndex(file) {
|
|
538
|
-
return basename(file, extname(file)) === "index";
|
|
539
|
-
}
|
|
540
|
-
return {
|
|
541
|
-
name: "fumadocs:slugs",
|
|
542
|
-
transformStorage({ storage }) {
|
|
543
|
-
const indexFiles = /* @__PURE__ */ new Set();
|
|
544
|
-
const taken = /* @__PURE__ */ new Set();
|
|
545
|
-
const autoIndex = slugsFn === void 0;
|
|
546
|
-
for (const path2 of storage.getFiles()) {
|
|
547
|
-
const file = storage.read(path2);
|
|
548
|
-
if (!file || file.format !== "page" || file.slugs) continue;
|
|
549
|
-
if (isIndex(path2) && autoIndex) {
|
|
550
|
-
indexFiles.add(path2);
|
|
551
|
-
continue;
|
|
552
|
-
}
|
|
553
|
-
file.slugs = slugsFn ? slugsFn({ path: path2 }) : getSlugs(path2);
|
|
554
|
-
const key = file.slugs.join("/");
|
|
555
|
-
if (taken.has(key)) throw new Error("Duplicated slugs");
|
|
556
|
-
taken.add(key);
|
|
557
|
-
}
|
|
558
|
-
for (const path2 of indexFiles) {
|
|
559
|
-
const file = storage.read(path2);
|
|
560
|
-
if (file?.format !== "page") continue;
|
|
561
|
-
file.slugs = getSlugs(path2);
|
|
562
|
-
if (taken.has(file.slugs.join("/"))) file.slugs.push("index");
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
var GroupRegex = /^\(.+\)$/;
|
|
568
|
-
function getSlugs(file) {
|
|
569
|
-
const dir = dirname(file);
|
|
570
|
-
const name = basename(file, extname(file));
|
|
571
|
-
const slugs = [];
|
|
572
|
-
for (const seg of dir.split("/")) {
|
|
573
|
-
if (seg.length > 0 && !GroupRegex.test(seg)) slugs.push(encodeURI(seg));
|
|
574
|
-
}
|
|
575
|
-
if (GroupRegex.test(name))
|
|
576
|
-
throw new Error(`Cannot use folder group in file names: ${file}`);
|
|
577
|
-
if (name !== "index") {
|
|
578
|
-
slugs.push(encodeURI(name));
|
|
579
|
-
}
|
|
580
|
-
return slugs;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
// src/source/loader.ts
|
|
584
|
-
import path from "path";
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/source/loader.ts
|
|
585
463
|
function indexPages(storages, { url }) {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
result.pathToPage.set(path2, page);
|
|
615
|
-
result.pages.set(`${lang}.${page.slugs.join("/")}`, page);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
return result;
|
|
464
|
+
const result = {
|
|
465
|
+
pages: /* @__PURE__ */ new Map(),
|
|
466
|
+
pathToMeta: /* @__PURE__ */ new Map(),
|
|
467
|
+
pathToPage: /* @__PURE__ */ new Map()
|
|
468
|
+
};
|
|
469
|
+
for (const [lang, storage] of Object.entries(storages)) for (const filePath of storage.getFiles()) {
|
|
470
|
+
const item = storage.read(filePath);
|
|
471
|
+
const path$1 = `${lang}.${filePath}`;
|
|
472
|
+
if (item.format === "meta") {
|
|
473
|
+
result.pathToMeta.set(path$1, {
|
|
474
|
+
path: item.path,
|
|
475
|
+
absolutePath: item.absolutePath,
|
|
476
|
+
data: item.data
|
|
477
|
+
});
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
const page = {
|
|
481
|
+
absolutePath: item.absolutePath,
|
|
482
|
+
path: item.path,
|
|
483
|
+
url: url(item.slugs, lang),
|
|
484
|
+
slugs: item.slugs,
|
|
485
|
+
data: item.data,
|
|
486
|
+
locale: lang
|
|
487
|
+
};
|
|
488
|
+
result.pathToPage.set(path$1, page);
|
|
489
|
+
result.pages.set(`${lang}.${page.slugs.join("/")}`, page);
|
|
490
|
+
}
|
|
491
|
+
return result;
|
|
619
492
|
}
|
|
620
493
|
function createGetUrl(baseUrl, i18n) {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
if (urlLocale) paths.unshift(urlLocale);
|
|
632
|
-
return `/${paths.filter((v) => v.length > 0).join("/")}`;
|
|
633
|
-
};
|
|
494
|
+
const baseSlugs = baseUrl.split("/");
|
|
495
|
+
return (slugs, locale) => {
|
|
496
|
+
const hideLocale = i18n?.hideLocale ?? "never";
|
|
497
|
+
let urlLocale;
|
|
498
|
+
if (hideLocale === "never") urlLocale = locale;
|
|
499
|
+
else if (hideLocale === "default-locale" && locale !== i18n?.defaultLanguage) urlLocale = locale;
|
|
500
|
+
const paths = [...baseSlugs, ...slugs];
|
|
501
|
+
if (urlLocale) paths.unshift(urlLocale);
|
|
502
|
+
return `/${paths.filter((v) => v.length > 0).join("/")}`;
|
|
503
|
+
};
|
|
634
504
|
}
|
|
635
505
|
function loader(...args) {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
(entry) => entry.pages.map((page) => ({
|
|
734
|
-
[slug ?? "slug"]: page.slugs,
|
|
735
|
-
[lang ?? "lang"]: entry.language
|
|
736
|
-
}))
|
|
737
|
-
);
|
|
738
|
-
}
|
|
739
|
-
return this.getPages().map((page) => ({
|
|
740
|
-
[slug ?? "slug"]: page.slugs
|
|
741
|
-
}));
|
|
742
|
-
},
|
|
743
|
-
async serializePageTree(tree) {
|
|
744
|
-
const { renderToString } = await import("react-dom/server.edge");
|
|
745
|
-
return visit(tree, (node) => {
|
|
746
|
-
node = { ...node };
|
|
747
|
-
if ("icon" in node && node.icon) {
|
|
748
|
-
node.icon = renderToString(node.icon);
|
|
749
|
-
}
|
|
750
|
-
if (node.name) {
|
|
751
|
-
node.name = renderToString(node.name);
|
|
752
|
-
}
|
|
753
|
-
if ("children" in node) {
|
|
754
|
-
node.children = [...node.children];
|
|
755
|
-
}
|
|
756
|
-
return node;
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
};
|
|
506
|
+
const loaderConfig = args.length === 2 ? resolveConfig(args[0], args[1]) : resolveConfig(args[0].source, args[0]);
|
|
507
|
+
const { i18n } = loaderConfig;
|
|
508
|
+
const defaultLanguage = i18n?.defaultLanguage ?? "";
|
|
509
|
+
const storages = buildContentStorage(loaderConfig, defaultLanguage);
|
|
510
|
+
const walker = indexPages(storages, loaderConfig);
|
|
511
|
+
const builder = createPageTreeBuilder(loaderConfig);
|
|
512
|
+
let pageTrees;
|
|
513
|
+
function getPageTrees() {
|
|
514
|
+
return pageTrees ??= builder.buildI18n(storages);
|
|
515
|
+
}
|
|
516
|
+
return {
|
|
517
|
+
_i18n: i18n,
|
|
518
|
+
get pageTree() {
|
|
519
|
+
const trees = getPageTrees();
|
|
520
|
+
return i18n ? trees : trees[defaultLanguage];
|
|
521
|
+
},
|
|
522
|
+
set pageTree(v) {
|
|
523
|
+
if (i18n) pageTrees = v;
|
|
524
|
+
else {
|
|
525
|
+
pageTrees ??= {};
|
|
526
|
+
pageTrees[defaultLanguage] = v;
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
getPageByHref(href, { dir = "", language = defaultLanguage } = {}) {
|
|
530
|
+
const [value, hash] = href.split("#", 2);
|
|
531
|
+
let target;
|
|
532
|
+
if (value.startsWith("./")) {
|
|
533
|
+
const path$1 = joinPath(dir, value);
|
|
534
|
+
target = walker.pathToPage.get(`${language}.${path$1}`);
|
|
535
|
+
} else target = this.getPages(language).find((item) => item.url === value);
|
|
536
|
+
if (target) return {
|
|
537
|
+
page: target,
|
|
538
|
+
hash
|
|
539
|
+
};
|
|
540
|
+
},
|
|
541
|
+
resolveHref(href, parent) {
|
|
542
|
+
if (href.startsWith("./")) {
|
|
543
|
+
const target = this.getPageByHref(href, {
|
|
544
|
+
dir: path.dirname(parent.path),
|
|
545
|
+
language: parent.locale
|
|
546
|
+
});
|
|
547
|
+
if (target) return target.hash ? `${target.page.url}#${target.hash}` : target.page.url;
|
|
548
|
+
}
|
|
549
|
+
return href;
|
|
550
|
+
},
|
|
551
|
+
getPages(language) {
|
|
552
|
+
const pages = [];
|
|
553
|
+
for (const [key, value] of walker.pages.entries()) if (language === void 0 || key.startsWith(`${language}.`)) pages.push(value);
|
|
554
|
+
return pages;
|
|
555
|
+
},
|
|
556
|
+
getLanguages() {
|
|
557
|
+
const list = [];
|
|
558
|
+
if (!i18n) return list;
|
|
559
|
+
for (const language of i18n.languages) list.push({
|
|
560
|
+
language,
|
|
561
|
+
pages: this.getPages(language)
|
|
562
|
+
});
|
|
563
|
+
return list;
|
|
564
|
+
},
|
|
565
|
+
getPage(slugs = [], language = defaultLanguage) {
|
|
566
|
+
let page = walker.pages.get(`${language}.${slugs.join("/")}`);
|
|
567
|
+
if (page) return page;
|
|
568
|
+
page = walker.pages.get(`${language}.${slugs.map(decodeURI).join("/")}`);
|
|
569
|
+
if (page) return page;
|
|
570
|
+
},
|
|
571
|
+
getNodeMeta(node, language = defaultLanguage) {
|
|
572
|
+
const ref = node.$ref?.metaFile;
|
|
573
|
+
if (!ref) return;
|
|
574
|
+
return walker.pathToMeta.get(`${language}.${ref}`);
|
|
575
|
+
},
|
|
576
|
+
getNodePage(node, language = defaultLanguage) {
|
|
577
|
+
const ref = node.$ref?.file;
|
|
578
|
+
if (!ref) return;
|
|
579
|
+
return walker.pathToPage.get(`${language}.${ref}`);
|
|
580
|
+
},
|
|
581
|
+
getPageTree(locale = defaultLanguage) {
|
|
582
|
+
const trees = getPageTrees();
|
|
583
|
+
return trees[locale] ?? trees[defaultLanguage];
|
|
584
|
+
},
|
|
585
|
+
generateParams(slug, lang) {
|
|
586
|
+
if (i18n) return this.getLanguages().flatMap((entry) => entry.pages.map((page) => ({
|
|
587
|
+
[slug ?? "slug"]: page.slugs,
|
|
588
|
+
[lang ?? "lang"]: entry.language
|
|
589
|
+
})));
|
|
590
|
+
return this.getPages().map((page) => ({ [slug ?? "slug"]: page.slugs }));
|
|
591
|
+
},
|
|
592
|
+
async serializePageTree(tree) {
|
|
593
|
+
const { renderToString } = await import("react-dom/server.edge");
|
|
594
|
+
return visit(tree, (node) => {
|
|
595
|
+
node = { ...node };
|
|
596
|
+
if ("icon" in node && node.icon) node.icon = renderToString(node.icon);
|
|
597
|
+
if (node.name) node.name = renderToString(node.name);
|
|
598
|
+
if ("children" in node) node.children = [...node.children];
|
|
599
|
+
return node;
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
};
|
|
760
603
|
}
|
|
761
|
-
function resolveConfig(
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
}
|
|
778
|
-
return config;
|
|
604
|
+
function resolveConfig(source$1, { slugs, icon, plugins = [], baseUrl, url, ...base }) {
|
|
605
|
+
let config = {
|
|
606
|
+
...base,
|
|
607
|
+
url: url ? (...args) => normalizeUrl(url(...args)) : createGetUrl(baseUrl, base.i18n),
|
|
608
|
+
source: source$1,
|
|
609
|
+
plugins: buildPlugins([
|
|
610
|
+
icon && iconPlugin(icon),
|
|
611
|
+
...typeof plugins === "function" ? plugins({ typedPlugin: (plugin) => plugin }) : plugins,
|
|
612
|
+
slugsPlugin(slugs)
|
|
613
|
+
])
|
|
614
|
+
};
|
|
615
|
+
for (const plugin of config.plugins ?? []) {
|
|
616
|
+
const result = plugin.config?.(config);
|
|
617
|
+
if (result) config = result;
|
|
618
|
+
}
|
|
619
|
+
return config;
|
|
779
620
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
getSlugs,
|
|
785
|
-
loader,
|
|
786
|
-
multiple,
|
|
787
|
-
source,
|
|
788
|
-
update
|
|
621
|
+
const priorityMap = {
|
|
622
|
+
pre: 1,
|
|
623
|
+
default: 0,
|
|
624
|
+
post: -1
|
|
789
625
|
};
|
|
626
|
+
function buildPlugins(plugins, sort = true) {
|
|
627
|
+
const flatten = [];
|
|
628
|
+
for (const plugin of plugins) if (Array.isArray(plugin)) flatten.push(...buildPlugins(plugin, false));
|
|
629
|
+
else if (plugin) flatten.push(plugin);
|
|
630
|
+
if (sort) return flatten.sort((a, b) => priorityMap[b.enforce ?? "default"] - priorityMap[a.enforce ?? "default"]);
|
|
631
|
+
return flatten;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
//#endregion
|
|
635
|
+
export { FileSystem, path_exports as PathUtils, createGetUrl, getSlugs, loader, multiple, source, update };
|
|
636
|
+
//# sourceMappingURL=index.js.map
|