fumadocs-core 16.4.0 → 16.4.2
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-BRT5Ij43.js +80 -0
- package/dist/advanced-BRT5Ij43.js.map +1 -0
- package/dist/algolia-CBBN8R6-.d.ts +68 -0
- package/dist/algolia-CBBN8R6-.d.ts.map +1 -0
- package/dist/algolia-CQPXCnjV.js +49 -0
- package/dist/algolia-CQPXCnjV.js.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-B-ezknvj.js +42 -0
- package/dist/codeblock-utils-lld8UiQo.d.ts +37 -0
- package/dist/codeblock-utils-lld8UiQo.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-DuxDer_c.d.ts +62 -0
- package/dist/definitions-DuxDer_c.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-B5e9CFfN.js +20 -0
- package/dist/fetch-B5e9CFfN.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-Dt7IObrc.js +19 -0
- package/dist/icon-Dt7IObrc.js.map +1 -0
- package/dist/index-2U6Tl4--.d.ts +379 -0
- package/dist/index-2U6Tl4--.d.ts.map +1 -0
- package/dist/index-Bw-DCOra.d.ts +41 -0
- package/dist/index-Bw-DCOra.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-mc9-X-PK.js +40 -0
- package/dist/mdast-utils-mc9-X-PK.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-DlByNYSd.js +88 -0
- package/dist/mixedbread-DlByNYSd.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-DP9-1I-S.js +16 -0
- package/dist/normalize-url-DP9-1I-S.js.map +1 -0
- package/dist/orama-cloud-DH3g37zc.js +84 -0
- package/dist/orama-cloud-DH3g37zc.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-DHIjrDBP.js +60 -0
- package/dist/path-DHIjrDBP.js.map +1 -0
- package/dist/rehype-code-CdiZ1Y6P.js +241 -0
- package/dist/rehype-code-CdiZ1Y6P.js.map +1 -0
- package/dist/rehype-code-vVWG4-ej.d.ts +58 -0
- package/dist/rehype-code-vVWG4-ej.d.ts.map +1 -0
- package/dist/rehype-toc-DJvSyE0o.d.ts +18 -0
- package/dist/rehype-toc-DJvSyE0o.d.ts.map +1 -0
- package/dist/rehype-toc-DVwJcwvA.js +143 -0
- package/dist/rehype-toc-DVwJcwvA.js.map +1 -0
- package/dist/remark-admonition-DOwBWzsH.d.ts +22 -0
- package/dist/remark-admonition-DOwBWzsH.d.ts.map +1 -0
- package/dist/remark-code-tab-CXsYlims.d.ts +32 -0
- package/dist/remark-code-tab-CXsYlims.d.ts.map +1 -0
- package/dist/remark-directive-admonition-BCm_yiU9.d.ts +36 -0
- package/dist/remark-directive-admonition-BCm_yiU9.d.ts.map +1 -0
- package/dist/remark-gfm-CeWpMwyk.d.ts +2 -0
- package/dist/remark-heading-CXvCY0go.d.ts +37 -0
- package/dist/remark-heading-CXvCY0go.d.ts.map +1 -0
- package/dist/remark-image-CvUis4R1.d.ts +65 -0
- package/dist/remark-image-CvUis4R1.d.ts.map +1 -0
- package/dist/remark-mdx-files-B31xFFG4.d.ts +56 -0
- package/dist/remark-mdx-files-B31xFFG4.d.ts.map +1 -0
- package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts +17 -0
- package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts.map +1 -0
- package/dist/remark-npm-BIvIEKT2.d.ts +36 -0
- package/dist/remark-npm-BIvIEKT2.d.ts.map +1 -0
- package/dist/remark-steps-CHJN-rtm.d.ts +28 -0
- package/dist/remark-steps-CHJN-rtm.d.ts.map +1 -0
- package/dist/remark-structure-RZD2gGKp.d.ts +77 -0
- package/dist/remark-structure-RZD2gGKp.d.ts.map +1 -0
- package/dist/remove-undefined-Cfs4o_mM.js +19 -0
- package/dist/remove-undefined-Cfs4o_mM.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 +120 -114
- package/dist/search/client.d.ts.map +1 -0
- package/dist/search/client.js +92 -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.d.ts +70 -68
- 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-D6ChCLhY.js +44 -0
- package/dist/search-D6ChCLhY.js.map +1 -0
- package/dist/server-CPR_fgkH.d.ts +133 -0
- package/dist/server-CPR_fgkH.d.ts.map +1 -0
- package/dist/shiki-4oMYwHED.js +80 -0
- package/dist/shiki-4oMYwHED.js.map +1 -0
- package/dist/shiki-CIBQys54.d.ts +33 -0
- package/dist/shiki-CIBQys54.d.ts.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-Dq8pA8Ay.js +51 -0
- package/dist/static-Dq8pA8Ay.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-CK2ykiif.d.ts +8 -0
- package/dist/util-CK2ykiif.d.ts.map +1 -0
- package/dist/util-s9piKHsk.js +10 -0
- package/dist/util-s9piKHsk.js.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-DUvi2WkD.js +134 -0
- package/dist/utils-DUvi2WkD.js.map +1 -0
- package/package.json +60 -58
- 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/content/github.js
CHANGED
|
@@ -1,44 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const res = await fetch(
|
|
27
|
-
`${baseUrl}/repos/${owner}/${repo}/commits?${params.toString()}`,
|
|
28
|
-
{
|
|
29
|
-
cache: "force-cache",
|
|
30
|
-
...options,
|
|
31
|
-
headers
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
if (!res.ok)
|
|
35
|
-
throw new Error(
|
|
36
|
-
`Failed to fetch last edit time from Git ${await res.text()}`
|
|
37
|
-
);
|
|
38
|
-
const data = await res.json();
|
|
39
|
-
if (data.length === 0) return null;
|
|
40
|
-
return new Date(data[0].commit.committer.date);
|
|
1
|
+
//#region src/content/github.ts
|
|
2
|
+
/**
|
|
3
|
+
* Get the last edit time of a file using GitHub API
|
|
4
|
+
*
|
|
5
|
+
* By default, this will cache the result forever.
|
|
6
|
+
* Set `options.next.revalidate` to customise this.
|
|
7
|
+
*/
|
|
8
|
+
async function getGithubLastEdit({ repo, token, owner, path, sha, baseUrl = "https://api.github.com", options = {}, params: customParams = {} }) {
|
|
9
|
+
const headers = new Headers(options.headers);
|
|
10
|
+
const params = new URLSearchParams();
|
|
11
|
+
params.set("path", path);
|
|
12
|
+
params.set("page", "1");
|
|
13
|
+
params.set("per_page", "1");
|
|
14
|
+
if (sha) params.set("sha", sha);
|
|
15
|
+
for (const [key, value] of Object.entries(customParams)) params.set(key, value);
|
|
16
|
+
if (token) headers.append("authorization", token);
|
|
17
|
+
const res = await fetch(`${baseUrl}/repos/${owner}/${repo}/commits?${params.toString()}`, {
|
|
18
|
+
cache: "force-cache",
|
|
19
|
+
...options,
|
|
20
|
+
headers
|
|
21
|
+
});
|
|
22
|
+
if (!res.ok) throw new Error(`Failed to fetch last edit time from Git ${await res.text()}`);
|
|
23
|
+
const data = await res.json();
|
|
24
|
+
if (data.length === 0) return null;
|
|
25
|
+
return new Date(data[0].commit.committer.date);
|
|
41
26
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { getGithubLastEdit };
|
|
30
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","names":[],"sources":["../../src/content/github.ts"],"sourcesContent":["type Response = {\n commit: {\n committer: {\n date: string;\n };\n };\n}[];\n\nexport interface GetGithubLastCommitOptions {\n /**\n * Repository name, like \"fumadocs\"\n */\n repo: string;\n\n /** Owner of repository */\n owner: string;\n\n /**\n * Path to file\n */\n path: string;\n\n /**\n * GitHub access token\n */\n token?: string;\n\n /**\n * SHA or ref (branch or tag) name.\n */\n sha?: string;\n\n /**\n * Base URL for GitHub API\n * @default \"https://api.github.com\"\n * @link https://docs.github.com/en/get-started/using-github-docs/about-versions-of-github-docs#determining-which-github-product-you-use\n */\n baseUrl?: string;\n\n /**\n * Custom query parameters\n */\n params?: Record<string, string>;\n\n options?: RequestInit;\n}\n\n/**\n * Get the last edit time of a file using GitHub API\n *\n * By default, this will cache the result forever.\n * Set `options.next.revalidate` to customise this.\n */\nexport async function getGithubLastEdit({\n repo,\n token,\n owner,\n path,\n sha,\n baseUrl = 'https://api.github.com',\n options = {},\n params: customParams = {},\n}: GetGithubLastCommitOptions): Promise<Date | null> {\n const headers = new Headers(options.headers);\n const params = new URLSearchParams();\n params.set('path', path);\n params.set('page', '1');\n params.set('per_page', '1');\n\n if (sha) params.set('sha', sha);\n\n for (const [key, value] of Object.entries(customParams)) {\n params.set(key, value);\n }\n\n if (token) {\n headers.append('authorization', token);\n }\n\n const res = await fetch(`${baseUrl}/repos/${owner}/${repo}/commits?${params.toString()}`, {\n cache: 'force-cache',\n ...options,\n headers,\n });\n\n if (!res.ok) throw new Error(`Failed to fetch last edit time from Git ${await res.text()}`);\n const data = (await res.json()) as Response;\n\n if (data.length === 0) return null;\n return new Date(data[0].commit.committer.date);\n}\n"],"mappings":";;;;;;;AAqDA,eAAsB,kBAAkB,EACtC,MACA,OACA,OACA,MACA,KACA,UAAU,0BACV,UAAU,EAAE,EACZ,QAAQ,eAAe,EAAE,IAC0B;CACnD,MAAM,UAAU,IAAI,QAAQ,QAAQ,QAAQ;CAC5C,MAAM,SAAS,IAAI,iBAAiB;AACpC,QAAO,IAAI,QAAQ,KAAK;AACxB,QAAO,IAAI,QAAQ,IAAI;AACvB,QAAO,IAAI,YAAY,IAAI;AAE3B,KAAI,IAAK,QAAO,IAAI,OAAO,IAAI;AAE/B,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,aAAa,CACrD,QAAO,IAAI,KAAK,MAAM;AAGxB,KAAI,MACF,SAAQ,OAAO,iBAAiB,MAAM;CAGxC,MAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,SAAS,MAAM,GAAG,KAAK,WAAW,OAAO,UAAU,IAAI;EACxF,OAAO;EACP,GAAG;EACH;EACD,CAAC;AAEF,KAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,2CAA2C,MAAM,IAAI,MAAM,GAAG;CAC3F,MAAM,OAAQ,MAAM,IAAI,MAAM;AAE9B,KAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,QAAO,IAAI,KAAK,KAAK,GAAG,OAAO,UAAU,KAAK"}
|
package/dist/content/index.d.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { ReactNode } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { PluggableList } from
|
|
1
|
+
import * as react3 from "react";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { Components } from "hast-util-to-jsx-runtime";
|
|
4
|
+
import { Compatible } from "vfile";
|
|
5
|
+
import { PluggableList } from "unified";
|
|
6
6
|
|
|
7
|
+
//#region src/content/index.d.ts
|
|
7
8
|
interface MarkdownProps {
|
|
8
|
-
|
|
9
|
+
components?: Components;
|
|
9
10
|
}
|
|
10
|
-
declare function Markdown({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
declare function Markdown({
|
|
12
|
+
children: content,
|
|
13
|
+
remarkPlugins,
|
|
14
|
+
rehypePlugins,
|
|
15
|
+
...options
|
|
16
|
+
}: MarkdownProps & {
|
|
17
|
+
remarkPlugins?: PluggableList;
|
|
18
|
+
rehypePlugins?: PluggableList;
|
|
19
|
+
children: Compatible;
|
|
20
|
+
}): Promise<react3.ReactElement<unknown, string | react3.JSXElementConstructor<any>> | Iterable<ReactNode> | (string | number | bigint | boolean | react3.ReactPortal | react3.ReactElement<unknown, string | react3.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined)>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Markdown, MarkdownProps };
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/content/index.ts"],"sourcesContent":[],"mappings":";;;;;;;UAqBiB,aAAA;eACF;;AADE,iBAIK,QAAA,CAHP;EAAA,QAAU,EAIb,OAJa;EAAA,aAAA;EAAA,aAAA;EAAA,GAAA;CAAA,EAQtB,aARsB,GAAA;EAGH,aAAQ,CAAA,EAMZ,aANY;EAClB,aAAA,CAAA,EAMM,aANN;EACV,QAAA,EAMU,UANV;CACA,CAAA,EAMD,OANC,CAMD,MAAA,CAAA,YANC,CAAA,OAAA,EAAA,MAAA,GAKoB,MAAA,CACrB,qBANC,CAAA,GAAA,CAAA,CAAA,GAMD,QANC,CAMD,SANC,CAAA,GAAA,CAAA,MAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAMD,MAAA,CAAA,WAAA,GAAA,MAAA,CAAA,YANC,CAAA,OAAA,EAAA,MAAA,GAMD,MAAA,CAAA,qBANC,CAAA,GAAA,CAAA,CAAA,GAMD,QANC,CAMD,SANC,CAAA,GAAA,IAAA,GAAA,SAAA,CAAA,CAAA"}
|
package/dist/content/index.js
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
3
|
-
// src/content/index.ts
|
|
1
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
4
2
|
import { remark } from "remark";
|
|
5
3
|
import remarkGfm from "remark-gfm";
|
|
6
4
|
import remarkRehype from "remark-rehype";
|
|
7
5
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
//#region src/content/index.ts
|
|
9
8
|
function rehypeReact(options = {}) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
this.compiler = (tree, file) => {
|
|
10
|
+
return toJsxRuntime(tree, {
|
|
11
|
+
development: false,
|
|
12
|
+
filePath: file.path,
|
|
13
|
+
...JsxRuntime,
|
|
14
|
+
...options
|
|
15
|
+
});
|
|
16
|
+
};
|
|
18
17
|
}
|
|
19
|
-
async function Markdown({
|
|
20
|
-
|
|
21
|
-
remarkPlugins = [],
|
|
22
|
-
rehypePlugins = [],
|
|
23
|
-
...options
|
|
24
|
-
}) {
|
|
25
|
-
const processor = remark().use(remarkGfm).use(remarkPlugins).use(remarkRehype).use(rehypePlugins).use(rehypeReact, options);
|
|
26
|
-
return (await processor.process(content)).result;
|
|
18
|
+
async function Markdown({ children: content, remarkPlugins = [], rehypePlugins = [], ...options }) {
|
|
19
|
+
return (await remark().use(remarkGfm).use(remarkPlugins).use(remarkRehype).use(rehypePlugins).use(rehypeReact, options).process(content)).result;
|
|
27
20
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { Markdown };
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/content/index.ts"],"sourcesContent":["import { remark } from 'remark';\nimport remarkGfm from 'remark-gfm';\nimport remarkRehype from 'remark-rehype';\nimport type { Compatible } from 'vfile';\nimport { type Components, toJsxRuntime } from 'hast-util-to-jsx-runtime';\nimport type { Root } from 'hast';\nimport * as JsxRuntime from 'react/jsx-runtime';\nimport type { PluggableList, Processor } from 'unified';\nimport type { ReactNode } from 'react';\n\nfunction rehypeReact(this: Processor, options: MarkdownProps = {}) {\n this.compiler = (tree, file) => {\n return toJsxRuntime(tree as Root, {\n development: false,\n filePath: file.path,\n ...JsxRuntime,\n ...options,\n });\n };\n}\n\nexport interface MarkdownProps {\n components?: Components;\n}\n\nexport async function Markdown({\n children: content,\n remarkPlugins = [],\n rehypePlugins = [],\n ...options\n}: MarkdownProps & {\n remarkPlugins?: PluggableList;\n rehypePlugins?: PluggableList;\n children: Compatible;\n}) {\n const processor = remark()\n .use(remarkGfm)\n .use(remarkPlugins)\n .use(remarkRehype)\n .use(rehypePlugins)\n .use(rehypeReact, options);\n\n return (await processor.process(content)).result as ReactNode;\n}\n"],"mappings":";;;;;;;AAUA,SAAS,YAA6B,UAAyB,EAAE,EAAE;AACjE,MAAK,YAAY,MAAM,SAAS;AAC9B,SAAO,aAAa,MAAc;GAChC,aAAa;GACb,UAAU,KAAK;GACf,GAAG;GACH,GAAG;GACJ,CAAC;;;AAQN,eAAsB,SAAS,EAC7B,UAAU,SACV,gBAAgB,EAAE,EAClB,gBAAgB,EAAE,EAClB,GAAG,WAKF;AAQD,SAAQ,MAPU,QAAQ,CACvB,IAAI,UAAU,CACd,IAAI,cAAc,CAClB,IAAI,aAAa,CACjB,IAAI,cAAc,CAClB,IAAI,aAAa,QAAQ,CAEJ,QAAQ,QAAQ,EAAE"}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { RehypeCodeOptions } from
|
|
3
|
-
import { RemarkImageOptions } from
|
|
4
|
-
import { StructureOptions } from
|
|
5
|
-
import { RemarkHeadingOptions } from
|
|
6
|
-
import { RemarkCodeTabOptions } from
|
|
7
|
-
import { RemarkNpmOptions } from
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import 'unified';
|
|
12
|
-
import 'shiki';
|
|
13
|
-
import 'mdast';
|
|
14
|
-
import 'mdast-util-mdx-jsx';
|
|
1
|
+
import "../../remark-gfm-CeWpMwyk.js";
|
|
2
|
+
import { t as RehypeCodeOptions } from "../../rehype-code-vVWG4-ej.js";
|
|
3
|
+
import { t as RemarkImageOptions } from "../../remark-image-CvUis4R1.js";
|
|
4
|
+
import { t as StructureOptions } from "../../remark-structure-RZD2gGKp.js";
|
|
5
|
+
import { t as RemarkHeadingOptions } from "../../remark-heading-CXvCY0go.js";
|
|
6
|
+
import { t as RemarkCodeTabOptions } from "../../remark-code-tab-CXsYlims.js";
|
|
7
|
+
import { t as RemarkNpmOptions } from "../../remark-npm-BIvIEKT2.js";
|
|
8
|
+
import "../../mdx-plugins/index.js";
|
|
9
|
+
import { t as ResolvePlugins } from "../../util-CK2ykiif.js";
|
|
10
|
+
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
15
11
|
|
|
12
|
+
//#region src/content/mdx/preset-bundler.d.ts
|
|
16
13
|
type MDXBundlerPresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
rehypePlugins?: ResolvePlugins;
|
|
15
|
+
remarkPlugins?: ResolvePlugins;
|
|
16
|
+
remarkStructureOptions?: StructureOptions | false;
|
|
17
|
+
remarkHeadingOptions?: RemarkHeadingOptions;
|
|
18
|
+
remarkImageOptions?: RemarkImageOptions | false;
|
|
19
|
+
remarkCodeTabOptions?: RemarkCodeTabOptions | false;
|
|
20
|
+
remarkNpmOptions?: RemarkNpmOptions | false;
|
|
21
|
+
rehypeCodeOptions?: RehypeCodeOptions | false;
|
|
25
22
|
};
|
|
26
23
|
/**
|
|
27
24
|
* apply MDX processor presets
|
|
28
25
|
*/
|
|
29
26
|
declare function mdxPreset(options?: MDXBundlerPresetOptions): Promise<ProcessorOptions>;
|
|
30
|
-
|
|
31
|
-
export {
|
|
27
|
+
//#endregion
|
|
28
|
+
export { MDXBundlerPresetOptions, mdxPreset };
|
|
29
|
+
//# sourceMappingURL=preset-bundler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-bundler.d.ts","names":[],"sources":["../../../src/content/mdx/preset-bundler.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAIY,uBAAA,GAA0B,KACpC,YAAY;kBAGI;kBACA;2BAES;yBACF;uBACF;yBACE;qBACJ;sBACC;AAZtB,CAAA;;;;AAIkB,iBAcI,SAAA,CAdJ,OAAA,CAAA,EAcuB,uBAdvB,CAAA,EAcsD,OAdtD,CAc8D,gBAd9D,CAAA"}
|
|
@@ -1,72 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolvePlugins
|
|
3
|
-
} from "../../chunk-GINBKBVQ.js";
|
|
4
|
-
import "../../chunk-U67V476Y.js";
|
|
1
|
+
import { t as resolvePlugins } from "../../util-s9piKHsk.js";
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
//#region src/content/mdx/preset-bundler.ts
|
|
4
|
+
/**
|
|
5
|
+
* apply MDX processor presets
|
|
6
|
+
*/
|
|
7
7
|
async function mdxPreset(options = {}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]),
|
|
38
|
-
remarkNpmOptions !== false && import("../../mdx-plugins/remark-npm.js").then((mod) => [
|
|
39
|
-
mod.remarkNpm,
|
|
40
|
-
remarkNpmOptions
|
|
41
|
-
]),
|
|
42
|
-
...v,
|
|
43
|
-
remarkStructureOptions !== false && import("../../mdx-plugins/remark-structure.js").then((mod) => [
|
|
44
|
-
mod.remarkStructure,
|
|
45
|
-
{
|
|
46
|
-
exportAs: "structuredData",
|
|
47
|
-
...remarkStructureOptions
|
|
48
|
-
}
|
|
49
|
-
])
|
|
50
|
-
],
|
|
51
|
-
mdxOptions.remarkPlugins
|
|
52
|
-
);
|
|
53
|
-
const rehypePlugins = await resolvePlugins(
|
|
54
|
-
(v) => [
|
|
55
|
-
rehypeCodeOptions !== false && import("../../mdx-plugins/rehype-code.js").then((mod) => [
|
|
56
|
-
mod.rehypeCode,
|
|
57
|
-
rehypeCodeOptions
|
|
58
|
-
]),
|
|
59
|
-
...v,
|
|
60
|
-
import("../../mdx-plugins/rehype-toc.js").then((mod) => mod.rehypeToc)
|
|
61
|
-
],
|
|
62
|
-
mdxOptions.rehypePlugins
|
|
63
|
-
);
|
|
64
|
-
return {
|
|
65
|
-
...mdxOptions,
|
|
66
|
-
remarkPlugins,
|
|
67
|
-
rehypePlugins
|
|
68
|
-
};
|
|
8
|
+
const { rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, remarkNpmOptions, ...mdxOptions } = options;
|
|
9
|
+
const remarkPlugins = await resolvePlugins((v) => [
|
|
10
|
+
import("remark-gfm").then((mod) => mod.default),
|
|
11
|
+
import("../../mdx-plugins/remark-heading.js").then((mod) => [mod.remarkHeading, {
|
|
12
|
+
generateToc: false,
|
|
13
|
+
...remarkHeadingOptions
|
|
14
|
+
}]),
|
|
15
|
+
remarkImageOptions !== false && import("../../mdx-plugins/remark-image.js").then((mod) => [mod.remarkImage, {
|
|
16
|
+
...remarkImageOptions,
|
|
17
|
+
useImport: remarkImageOptions?.useImport ?? true
|
|
18
|
+
}]),
|
|
19
|
+
remarkCodeTabOptions !== false && import("../../mdx-plugins/remark-code-tab.js").then((mod) => [mod.remarkCodeTab, remarkCodeTabOptions]),
|
|
20
|
+
remarkNpmOptions !== false && import("../../mdx-plugins/remark-npm.js").then((mod) => [mod.remarkNpm, remarkNpmOptions]),
|
|
21
|
+
...v,
|
|
22
|
+
remarkStructureOptions !== false && import("../../mdx-plugins/remark-structure.js").then((mod) => [mod.remarkStructure, {
|
|
23
|
+
exportAs: "structuredData",
|
|
24
|
+
...remarkStructureOptions
|
|
25
|
+
}])
|
|
26
|
+
], mdxOptions.remarkPlugins);
|
|
27
|
+
const rehypePlugins = await resolvePlugins((v) => [
|
|
28
|
+
rehypeCodeOptions !== false && import("../../mdx-plugins/rehype-code.js").then((mod) => [mod.rehypeCode, rehypeCodeOptions]),
|
|
29
|
+
...v,
|
|
30
|
+
import("../../mdx-plugins/rehype-toc.js").then((mod) => mod.rehypeToc)
|
|
31
|
+
], mdxOptions.rehypePlugins);
|
|
32
|
+
return {
|
|
33
|
+
...mdxOptions,
|
|
34
|
+
remarkPlugins,
|
|
35
|
+
rehypePlugins
|
|
36
|
+
};
|
|
69
37
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { mdxPreset };
|
|
41
|
+
//# sourceMappingURL=preset-bundler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-bundler.js","names":[],"sources":["../../../src/content/mdx/preset-bundler.ts"],"sourcesContent":["import type { ProcessorOptions } from '@mdx-js/mdx';\nimport type * as Plugins from '@/mdx-plugins';\nimport { resolvePlugins, type ResolvePlugins } from '@/content/mdx/util';\n\nexport type MDXBundlerPresetOptions = Omit<\n NonNullable<ProcessorOptions>,\n 'rehypePlugins' | 'remarkPlugins'\n> & {\n rehypePlugins?: ResolvePlugins;\n remarkPlugins?: ResolvePlugins;\n\n remarkStructureOptions?: Plugins.StructureOptions | false;\n remarkHeadingOptions?: Plugins.RemarkHeadingOptions;\n remarkImageOptions?: Plugins.RemarkImageOptions | false;\n remarkCodeTabOptions?: Plugins.RemarkCodeTabOptions | false;\n remarkNpmOptions?: Plugins.RemarkNpmOptions | false;\n rehypeCodeOptions?: Plugins.RehypeCodeOptions | false;\n};\n\n/**\n * apply MDX processor presets\n */\nexport async function mdxPreset(options: MDXBundlerPresetOptions = {}): Promise<ProcessorOptions> {\n const {\n rehypeCodeOptions,\n remarkImageOptions,\n remarkHeadingOptions,\n remarkStructureOptions,\n remarkCodeTabOptions,\n remarkNpmOptions,\n ...mdxOptions\n } = options;\n\n const remarkPlugins = await resolvePlugins(\n (v) => [\n import('remark-gfm').then((mod) => mod.default),\n import('@/mdx-plugins/remark-heading').then((mod) => [\n mod.remarkHeading,\n {\n generateToc: false,\n ...remarkHeadingOptions,\n },\n ]),\n remarkImageOptions !== false &&\n import('@/mdx-plugins/remark-image').then((mod) => [\n mod.remarkImage,\n {\n ...remarkImageOptions,\n useImport: remarkImageOptions?.useImport ?? true,\n },\n ]),\n remarkCodeTabOptions !== false &&\n import('@/mdx-plugins/remark-code-tab').then((mod) => [\n mod.remarkCodeTab,\n remarkCodeTabOptions,\n ]),\n remarkNpmOptions !== false &&\n import('@/mdx-plugins/remark-npm').then((mod) => [mod.remarkNpm, remarkNpmOptions]),\n ...v,\n remarkStructureOptions !== false &&\n import('@/mdx-plugins/remark-structure').then((mod) => [\n mod.remarkStructure,\n {\n exportAs: 'structuredData',\n ...remarkStructureOptions,\n } satisfies Plugins.StructureOptions,\n ]),\n ],\n mdxOptions.remarkPlugins,\n );\n\n const rehypePlugins = await resolvePlugins(\n (v) => [\n rehypeCodeOptions !== false &&\n import('@/mdx-plugins/rehype-code').then((mod) => [mod.rehypeCode, rehypeCodeOptions]),\n ...v,\n import('@/mdx-plugins/rehype-toc').then((mod) => mod.rehypeToc),\n ],\n mdxOptions.rehypePlugins,\n );\n\n return {\n ...mdxOptions,\n remarkPlugins,\n rehypePlugins,\n };\n}\n"],"mappings":";;;;;;AAsBA,eAAsB,UAAU,UAAmC,EAAE,EAA6B;CAChG,MAAM,EACJ,mBACA,oBACA,sBACA,wBACA,sBACA,kBACA,GAAG,eACD;CAEJ,MAAM,gBAAgB,MAAM,gBACzB,MAAM;EACL,OAAO,cAAc,MAAM,QAAQ,IAAI,QAAQ;EAC/C,OAAO,uCAAgC,MAAM,QAAQ,CACnD,IAAI,eACJ;GACE,aAAa;GACb,GAAG;GACJ,CACF,CAAC;EACF,uBAAuB,SACrB,OAAO,qCAA8B,MAAM,QAAQ,CACjD,IAAI,aACJ;GACE,GAAG;GACH,WAAW,oBAAoB,aAAa;GAC7C,CACF,CAAC;EACJ,yBAAyB,SACvB,OAAO,wCAAiC,MAAM,QAAQ,CACpD,IAAI,eACJ,qBACD,CAAC;EACJ,qBAAqB,SACnB,OAAO,mCAA4B,MAAM,QAAQ,CAAC,IAAI,WAAW,iBAAiB,CAAC;EACrF,GAAG;EACH,2BAA2B,SACzB,OAAO,yCAAkC,MAAM,QAAQ,CACrD,IAAI,iBACJ;GACE,UAAU;GACV,GAAG;GACJ,CACF,CAAC;EACL,EACD,WAAW,cACZ;CAED,MAAM,gBAAgB,MAAM,gBACzB,MAAM;EACL,sBAAsB,SACpB,OAAO,oCAA6B,MAAM,QAAQ,CAAC,IAAI,YAAY,kBAAkB,CAAC;EACxF,GAAG;EACH,OAAO,mCAA4B,MAAM,QAAQ,IAAI,UAAU;EAChE,EACD,WAAW,cACZ;AAED,QAAO;EACL,GAAG;EACH;EACA;EACD"}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { RehypeCodeOptions } from
|
|
3
|
-
import { RemarkImageOptions } from
|
|
4
|
-
import { StructureOptions } from
|
|
5
|
-
import { RemarkHeadingOptions } from
|
|
6
|
-
import { RemarkCodeTabOptions } from
|
|
7
|
-
import { RemarkNpmOptions } from
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import 'unified';
|
|
12
|
-
import 'shiki';
|
|
13
|
-
import 'mdast';
|
|
14
|
-
import 'mdast-util-mdx-jsx';
|
|
1
|
+
import "../../remark-gfm-CeWpMwyk.js";
|
|
2
|
+
import { t as RehypeCodeOptions } from "../../rehype-code-vVWG4-ej.js";
|
|
3
|
+
import { t as RemarkImageOptions } from "../../remark-image-CvUis4R1.js";
|
|
4
|
+
import { t as StructureOptions } from "../../remark-structure-RZD2gGKp.js";
|
|
5
|
+
import { t as RemarkHeadingOptions } from "../../remark-heading-CXvCY0go.js";
|
|
6
|
+
import { t as RemarkCodeTabOptions } from "../../remark-code-tab-CXsYlims.js";
|
|
7
|
+
import { t as RemarkNpmOptions } from "../../remark-npm-BIvIEKT2.js";
|
|
8
|
+
import "../../mdx-plugins/index.js";
|
|
9
|
+
import { t as ResolvePlugins } from "../../util-CK2ykiif.js";
|
|
10
|
+
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
15
11
|
|
|
12
|
+
//#region src/content/mdx/preset-runtime.d.ts
|
|
16
13
|
type MDXRuntimePresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
rehypePlugins?: ResolvePlugins;
|
|
15
|
+
remarkPlugins?: ResolvePlugins;
|
|
16
|
+
remarkStructureOptions?: StructureOptions | false;
|
|
17
|
+
remarkHeadingOptions?: RemarkHeadingOptions;
|
|
18
|
+
remarkImageOptions?: RemarkImageOptions | false;
|
|
19
|
+
remarkCodeTabOptions?: RemarkCodeTabOptions | false;
|
|
20
|
+
remarkNpmOptions?: RemarkNpmOptions | false;
|
|
21
|
+
rehypeCodeOptions?: RehypeCodeOptions | false;
|
|
25
22
|
};
|
|
26
23
|
/**
|
|
27
24
|
* apply MDX processor presets
|
|
28
25
|
*/
|
|
29
26
|
declare function mdxPreset(options?: MDXRuntimePresetOptions): Promise<ProcessorOptions>;
|
|
30
|
-
|
|
31
|
-
export {
|
|
27
|
+
//#endregion
|
|
28
|
+
export { MDXRuntimePresetOptions, mdxPreset };
|
|
29
|
+
//# sourceMappingURL=preset-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-runtime.d.ts","names":[],"sources":["../../../src/content/mdx/preset-runtime.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAIY,uBAAA,GAA0B,KACpC,YAAY;kBAGI;kBACA;2BAES;yBACF;uBACF;yBACE;qBACJ;sBACC;AAZtB,CAAA;;;;AAIkB,iBAcI,SAAA,CAdJ,OAAA,CAAA,EAcuB,uBAdvB,CAAA,EAcsD,OAdtD,CAc8D,gBAd9D,CAAA"}
|
|
@@ -1,71 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolvePlugins
|
|
3
|
-
} from "../../chunk-GINBKBVQ.js";
|
|
4
|
-
import "../../chunk-U67V476Y.js";
|
|
1
|
+
import { t as resolvePlugins } from "../../util-s9piKHsk.js";
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
//#region src/content/mdx/preset-runtime.ts
|
|
4
|
+
/**
|
|
5
|
+
* apply MDX processor presets
|
|
6
|
+
*/
|
|
7
7
|
async function mdxPreset(options = {}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
]),
|
|
36
|
-
remarkNpmOptions !== false && import("../../mdx-plugins/remark-npm.js").then((mod) => [
|
|
37
|
-
mod.remarkNpm,
|
|
38
|
-
remarkNpmOptions
|
|
39
|
-
]),
|
|
40
|
-
...v,
|
|
41
|
-
remarkStructureOptions !== false && import("../../mdx-plugins/remark-structure.js").then((mod) => [
|
|
42
|
-
mod.remarkStructure,
|
|
43
|
-
{
|
|
44
|
-
exportAs: "structuredData",
|
|
45
|
-
...remarkStructureOptions
|
|
46
|
-
}
|
|
47
|
-
])
|
|
48
|
-
],
|
|
49
|
-
mdxOptions.remarkPlugins
|
|
50
|
-
);
|
|
51
|
-
const rehypePlugins = await resolvePlugins(
|
|
52
|
-
(v) => [
|
|
53
|
-
rehypeCodeOptions !== false && import("../../mdx-plugins/rehype-code.js").then((mod) => [
|
|
54
|
-
mod.rehypeCode,
|
|
55
|
-
rehypeCodeOptions
|
|
56
|
-
]),
|
|
57
|
-
...v,
|
|
58
|
-
import("../../mdx-plugins/rehype-toc.js").then((mod) => mod.rehypeToc)
|
|
59
|
-
],
|
|
60
|
-
mdxOptions.rehypePlugins
|
|
61
|
-
);
|
|
62
|
-
return {
|
|
63
|
-
...mdxOptions,
|
|
64
|
-
outputFormat,
|
|
65
|
-
remarkPlugins,
|
|
66
|
-
rehypePlugins
|
|
67
|
-
};
|
|
8
|
+
const { rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, remarkNpmOptions, outputFormat = "function-body", ...mdxOptions } = options;
|
|
9
|
+
const remarkPlugins = await resolvePlugins((v) => [
|
|
10
|
+
import("remark-gfm").then((mod) => mod.default),
|
|
11
|
+
import("../../mdx-plugins/remark-heading.js").then((mod) => [mod.remarkHeading, {
|
|
12
|
+
generateToc: false,
|
|
13
|
+
...remarkHeadingOptions
|
|
14
|
+
}]),
|
|
15
|
+
remarkImageOptions !== false && import("../../mdx-plugins/remark-image.js").then((mod) => [mod.remarkImage, remarkImageOptions]),
|
|
16
|
+
remarkCodeTabOptions !== false && import("../../mdx-plugins/remark-code-tab.js").then((mod) => [mod.remarkCodeTab, remarkCodeTabOptions]),
|
|
17
|
+
remarkNpmOptions !== false && import("../../mdx-plugins/remark-npm.js").then((mod) => [mod.remarkNpm, remarkNpmOptions]),
|
|
18
|
+
...v,
|
|
19
|
+
remarkStructureOptions !== false && import("../../mdx-plugins/remark-structure.js").then((mod) => [mod.remarkStructure, {
|
|
20
|
+
exportAs: "structuredData",
|
|
21
|
+
...remarkStructureOptions
|
|
22
|
+
}])
|
|
23
|
+
], mdxOptions.remarkPlugins);
|
|
24
|
+
const rehypePlugins = await resolvePlugins((v) => [
|
|
25
|
+
rehypeCodeOptions !== false && import("../../mdx-plugins/rehype-code.js").then((mod) => [mod.rehypeCode, rehypeCodeOptions]),
|
|
26
|
+
...v,
|
|
27
|
+
import("../../mdx-plugins/rehype-toc.js").then((mod) => mod.rehypeToc)
|
|
28
|
+
], mdxOptions.rehypePlugins);
|
|
29
|
+
return {
|
|
30
|
+
...mdxOptions,
|
|
31
|
+
outputFormat,
|
|
32
|
+
remarkPlugins,
|
|
33
|
+
rehypePlugins
|
|
34
|
+
};
|
|
68
35
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { mdxPreset };
|
|
39
|
+
//# sourceMappingURL=preset-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-runtime.js","names":[],"sources":["../../../src/content/mdx/preset-runtime.ts"],"sourcesContent":["import type { ProcessorOptions } from '@mdx-js/mdx';\nimport type * as Plugins from '@/mdx-plugins';\nimport { resolvePlugins, type ResolvePlugins } from '@/content/mdx/util';\n\nexport type MDXRuntimePresetOptions = Omit<\n NonNullable<ProcessorOptions>,\n 'rehypePlugins' | 'remarkPlugins'\n> & {\n rehypePlugins?: ResolvePlugins;\n remarkPlugins?: ResolvePlugins;\n\n remarkStructureOptions?: Plugins.StructureOptions | false;\n remarkHeadingOptions?: Plugins.RemarkHeadingOptions;\n remarkImageOptions?: Plugins.RemarkImageOptions | false;\n remarkCodeTabOptions?: Plugins.RemarkCodeTabOptions | false;\n remarkNpmOptions?: Plugins.RemarkNpmOptions | false;\n rehypeCodeOptions?: Plugins.RehypeCodeOptions | false;\n};\n\n/**\n * apply MDX processor presets\n */\nexport async function mdxPreset(options: MDXRuntimePresetOptions = {}): Promise<ProcessorOptions> {\n const {\n rehypeCodeOptions,\n remarkImageOptions,\n remarkHeadingOptions,\n remarkStructureOptions,\n remarkCodeTabOptions,\n remarkNpmOptions,\n outputFormat = 'function-body',\n ...mdxOptions\n } = options;\n\n const remarkPlugins = await resolvePlugins(\n (v) => [\n import('remark-gfm').then((mod) => mod.default),\n import('@/mdx-plugins/remark-heading').then((mod) => [\n mod.remarkHeading,\n {\n generateToc: false,\n ...remarkHeadingOptions,\n },\n ]),\n remarkImageOptions !== false &&\n import('@/mdx-plugins/remark-image').then((mod) => [mod.remarkImage, remarkImageOptions]),\n remarkCodeTabOptions !== false &&\n import('@/mdx-plugins/remark-code-tab').then((mod) => [\n mod.remarkCodeTab,\n remarkCodeTabOptions,\n ]),\n remarkNpmOptions !== false &&\n import('@/mdx-plugins/remark-npm').then((mod) => [mod.remarkNpm, remarkNpmOptions]),\n ...v,\n remarkStructureOptions !== false &&\n import('@/mdx-plugins/remark-structure').then((mod) => [\n mod.remarkStructure,\n {\n exportAs: 'structuredData',\n ...remarkStructureOptions,\n } satisfies Plugins.StructureOptions,\n ]),\n ],\n mdxOptions.remarkPlugins,\n );\n\n const rehypePlugins = await resolvePlugins(\n (v) => [\n rehypeCodeOptions !== false &&\n import('@/mdx-plugins/rehype-code').then((mod) => [mod.rehypeCode, rehypeCodeOptions]),\n ...v,\n import('@/mdx-plugins/rehype-toc').then((mod) => mod.rehypeToc),\n ],\n mdxOptions.rehypePlugins,\n );\n\n return {\n ...mdxOptions,\n outputFormat,\n remarkPlugins,\n rehypePlugins,\n };\n}\n"],"mappings":";;;;;;AAsBA,eAAsB,UAAU,UAAmC,EAAE,EAA6B;CAChG,MAAM,EACJ,mBACA,oBACA,sBACA,wBACA,sBACA,kBACA,eAAe,iBACf,GAAG,eACD;CAEJ,MAAM,gBAAgB,MAAM,gBACzB,MAAM;EACL,OAAO,cAAc,MAAM,QAAQ,IAAI,QAAQ;EAC/C,OAAO,uCAAgC,MAAM,QAAQ,CACnD,IAAI,eACJ;GACE,aAAa;GACb,GAAG;GACJ,CACF,CAAC;EACF,uBAAuB,SACrB,OAAO,qCAA8B,MAAM,QAAQ,CAAC,IAAI,aAAa,mBAAmB,CAAC;EAC3F,yBAAyB,SACvB,OAAO,wCAAiC,MAAM,QAAQ,CACpD,IAAI,eACJ,qBACD,CAAC;EACJ,qBAAqB,SACnB,OAAO,mCAA4B,MAAM,QAAQ,CAAC,IAAI,WAAW,iBAAiB,CAAC;EACrF,GAAG;EACH,2BAA2B,SACzB,OAAO,yCAAkC,MAAM,QAAQ,CACrD,IAAI,iBACJ;GACE,UAAU;GACV,GAAG;GACJ,CACF,CAAC;EACL,EACD,WAAW,cACZ;CAED,MAAM,gBAAgB,MAAM,gBACzB,MAAM;EACL,sBAAsB,SACpB,OAAO,oCAA6B,MAAM,QAAQ,CAAC,IAAI,YAAY,kBAAkB,CAAC;EACxF,GAAG;EACH,OAAO,mCAA4B,MAAM,QAAQ,IAAI,UAAU;EAChE,EACD,WAAW,cACZ;AAED,QAAO;EACL,GAAG;EACH;EACA;EACA;EACD"}
|
package/dist/content/toc.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Compatible } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { TOCItemType } from "../toc.js";
|
|
2
|
+
import { Compatible } from "vfile";
|
|
3
|
+
import { PluggableList } from "unified";
|
|
4
|
+
|
|
5
|
+
//#region src/content/toc.d.ts
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Get Table of Contents from markdown/mdx document (using remark)
|
|
@@ -17,5 +17,6 @@ declare function getTableOfContents(content: Compatible): TOCItemType[];
|
|
|
17
17
|
* @param remarkPlugins - remark plugins to be applied first
|
|
18
18
|
*/
|
|
19
19
|
declare function getTableOfContents(content: Compatible, remarkPlugins: PluggableList): Promise<TOCItemType[]>;
|
|
20
|
-
|
|
20
|
+
//#endregion
|
|
21
21
|
export { getTableOfContents };
|
|
22
|
+
//# sourceMappingURL=toc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc.d.ts","names":[],"sources":["../../src/content/toc.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAWA;AAQA;;AAEiB,iBAVD,kBAAA,CAUC,OAAA,EAV2B,UAU3B,CAAA,EAVwC,WAUxC,EAAA;;;;;;;iBAFD,kBAAA,UACL,2BACM,gBACd,QAAQ"}
|
package/dist/content/toc.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
} from "../chunk-MA6O2UUE.js";
|
|
4
|
-
import "../chunk-VLSDGCJE.js";
|
|
5
|
-
import "../chunk-U67V476Y.js";
|
|
6
|
-
|
|
7
|
-
// src/content/toc.ts
|
|
1
|
+
import "../mdast-utils-mc9-X-PK.js";
|
|
2
|
+
import { remarkHeading } from "../mdx-plugins/remark-heading.js";
|
|
8
3
|
import { remark } from "remark";
|
|
4
|
+
|
|
5
|
+
//#region src/content/toc.ts
|
|
9
6
|
function getTableOfContents(content, remarkPlugins) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if ("toc" in result.data) return result.data.toc;
|
|
18
|
-
return [];
|
|
7
|
+
if (remarkPlugins) return remark().use(remarkPlugins).use(remarkHeading).process(content).then((result$1) => {
|
|
8
|
+
if ("toc" in result$1.data) return result$1.data.toc;
|
|
9
|
+
return [];
|
|
10
|
+
});
|
|
11
|
+
const result = remark().use(remarkHeading).processSync(content);
|
|
12
|
+
if ("toc" in result.data) return result.data.toc;
|
|
13
|
+
return [];
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { getTableOfContents };
|
|
18
|
+
//# sourceMappingURL=toc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc.js","names":["result"],"sources":["../../src/content/toc.ts"],"sourcesContent":["import { remark } from 'remark';\nimport { remarkHeading } from '@/mdx-plugins/remark-heading';\nimport type { PluggableList } from 'unified';\nimport type { Compatible } from 'vfile';\nimport type { TOCItemType } from '@/toc';\n\n/**\n * Get Table of Contents from markdown/mdx document (using remark)\n *\n * @param content - Markdown content or file\n */\nexport function getTableOfContents(content: Compatible): TOCItemType[];\n\n/**\n * Get Table of Contents from markdown/mdx document (using remark)\n *\n * @param content - Markdown content or file\n * @param remarkPlugins - remark plugins to be applied first\n */\nexport function getTableOfContents(\n content: Compatible,\n remarkPlugins: PluggableList,\n): Promise<TOCItemType[]>;\n\nexport function getTableOfContents(\n content: Compatible,\n remarkPlugins?: PluggableList,\n): TOCItemType[] | Promise<TOCItemType[]> {\n if (remarkPlugins) {\n return remark()\n .use(remarkPlugins)\n .use(remarkHeading)\n .process(content)\n .then((result) => {\n if ('toc' in result.data) return result.data.toc as TOCItemType[];\n\n return [];\n });\n }\n\n // compatible with sync usages\n const result = remark().use(remarkHeading).processSync(content);\n\n if ('toc' in result.data) return result.data.toc as TOCItemType[];\n return [];\n}\n"],"mappings":";;;;;AAwBA,SAAgB,mBACd,SACA,eACwC;AACxC,KAAI,cACF,QAAO,QAAQ,CACZ,IAAI,cAAc,CAClB,IAAI,cAAc,CAClB,QAAQ,QAAQ,CAChB,MAAM,aAAW;AAChB,MAAI,SAASA,SAAO,KAAM,QAAOA,SAAO,KAAK;AAE7C,SAAO,EAAE;GACT;CAIN,MAAM,SAAS,QAAQ,CAAC,IAAI,cAAc,CAAC,YAAY,QAAQ;AAE/D,KAAI,SAAS,OAAO,KAAM,QAAO,OAAO,KAAK;AAC7C,QAAO,EAAE"}
|