fumadocs-core 15.2.8 → 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/README.md +1 -1
- 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 +30 -26
- package/dist/breadcrumb.d.ts.map +1 -0
- package/dist/breadcrumb.js +55 -78
- 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 +51 -0
- package/dist/content/github.d.ts.map +1 -0
- package/dist/content/github.js +30 -0
- package/dist/content/github.js.map +1 -0
- package/dist/content/index.d.ts +23 -0
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +24 -0
- package/dist/content/index.js.map +1 -0
- package/dist/content/mdx/preset-bundler.d.ts +29 -0
- package/dist/content/mdx/preset-bundler.d.ts.map +1 -0
- package/dist/content/mdx/preset-bundler.js +41 -0
- package/dist/content/mdx/preset-bundler.js.map +1 -0
- package/dist/content/mdx/preset-runtime.d.ts +29 -0
- package/dist/content/mdx/preset-runtime.d.ts.map +1 -0
- package/dist/content/mdx/preset-runtime.js +39 -0
- package/dist/content/mdx/preset-runtime.js.map +1 -0
- package/dist/content/toc.d.ts +22 -0
- package/dist/content/toc.d.ts.map +1 -0
- package/dist/content/toc.js +18 -0
- 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 -36
- package/dist/framework/index.d.ts.map +1 -0
- package/dist/framework/index.js +68 -19
- package/dist/framework/index.js.map +1 -0
- package/dist/framework/next.d.ts +15 -6
- package/dist/framework/next.d.ts.map +1 -0
- package/dist/framework/next.js +18 -22
- package/dist/framework/next.js.map +1 -0
- package/dist/framework/react-router.d.ts +15 -6
- package/dist/framework/react-router.d.ts.map +1 -0
- package/dist/framework/react-router.js +42 -43
- package/dist/framework/react-router.js.map +1 -0
- package/dist/framework/tanstack.d.ts +15 -6
- package/dist/framework/tanstack.d.ts.map +1 -0
- package/dist/framework/tanstack.js +54 -44
- package/dist/framework/tanstack.js.map +1 -0
- package/dist/framework/waku.d.ts +17 -0
- package/dist/framework/waku.d.ts.map +1 -0
- package/dist/framework/waku.js +52 -0
- package/dist/framework/waku.js.map +1 -0
- package/dist/highlight/client.d.ts +11 -9
- package/dist/highlight/client.d.ts.map +1 -0
- package/dist/highlight/client.js +24 -100
- package/dist/highlight/client.js.map +1 -0
- package/dist/highlight/index.d.ts +2 -15
- package/dist/highlight/index.js +3 -9
- package/dist/i18n/index.d.ts +2 -12
- package/dist/i18n/index.js +7 -72
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/middleware.d.ts +42 -0
- package/dist/i18n/middleware.d.ts.map +1 -0
- package/dist/i18n/middleware.js +58 -0
- 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 -0
- package/dist/mdx-plugins/codeblock-utils.js +71 -0
- package/dist/mdx-plugins/codeblock-utils.js.map +1 -0
- package/dist/mdx-plugins/index.d.ts +15 -136
- package/dist/mdx-plugins/index.js +18 -936
- package/dist/mdx-plugins/rehype-code.d.ts +2 -0
- package/dist/mdx-plugins/rehype-code.js +5 -0
- package/dist/mdx-plugins/rehype-toc.d.ts +2 -0
- package/dist/mdx-plugins/rehype-toc.js +3 -0
- package/dist/mdx-plugins/remark-admonition.d.ts +2 -0
- package/dist/mdx-plugins/remark-admonition.js +74 -0
- package/dist/mdx-plugins/remark-admonition.js.map +1 -0
- package/dist/mdx-plugins/remark-code-tab.d.ts +2 -0
- package/dist/mdx-plugins/remark-code-tab.js +184 -0
- package/dist/mdx-plugins/remark-code-tab.js.map +1 -0
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -0
- package/dist/mdx-plugins/remark-directive-admonition.js +60 -0
- package/dist/mdx-plugins/remark-directive-admonition.js.map +1 -0
- package/dist/mdx-plugins/remark-gfm.d.ts +2 -0
- package/dist/mdx-plugins/remark-gfm.js +3 -0
- package/dist/mdx-plugins/remark-heading.d.ts +2 -0
- package/dist/mdx-plugins/remark-heading.js +45 -0
- package/dist/mdx-plugins/remark-heading.js.map +1 -0
- package/dist/mdx-plugins/remark-image.d.ts +2 -0
- package/dist/mdx-plugins/remark-image.js +192 -0
- package/dist/mdx-plugins/remark-image.js.map +1 -0
- package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -0
- package/dist/mdx-plugins/remark-mdx-files.js +187 -0
- package/dist/mdx-plugins/remark-mdx-files.js.map +1 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.js +31 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.js.map +1 -0
- package/dist/mdx-plugins/remark-npm.d.ts +2 -0
- package/dist/mdx-plugins/remark-npm.js +68 -0
- package/dist/mdx-plugins/remark-npm.js.map +1 -0
- package/dist/mdx-plugins/remark-steps.d.ts +2 -0
- package/dist/mdx-plugins/remark-steps.js +77 -0
- package/dist/mdx-plugins/remark-steps.js.map +1 -0
- package/dist/mdx-plugins/remark-structure.d.ts +2 -0
- package/dist/mdx-plugins/remark-structure.js +106 -0
- 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 +21 -0
- package/dist/negotiation/index.d.ts.map +1 -0
- package/dist/negotiation/index.js +41 -0
- 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 +45 -0
- package/dist/page-tree/index.d.ts.map +1 -0
- package/dist/page-tree/index.js +3 -0
- 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 -67
- package/dist/search/algolia.js +71 -51
- package/dist/search/algolia.js.map +1 -0
- package/dist/search/client.d.ts +130 -53
- package/dist/search/client.d.ts.map +1 -0
- package/dist/search/client.js +95 -72
- package/dist/search/client.js.map +1 -0
- package/dist/search/index.d.ts +28 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +3 -0
- package/dist/search/orama-cloud.d.ts +72 -67
- package/dist/search/orama-cloud.d.ts.map +1 -0
- package/dist/search/orama-cloud.js +48 -48
- package/dist/search/orama-cloud.js.map +1 -0
- package/dist/search/server.d.ts +6 -128
- package/dist/search/server.js +295 -310
- 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 +18 -0
- package/dist/source/client/index.d.ts.map +1 -0
- package/dist/source/client/index.js +30 -0
- package/dist/source/client/index.js.map +1 -0
- package/dist/source/index.d.ts +3 -263
- package/dist/source/index.js +615 -535
- package/dist/source/index.js.map +1 -0
- package/dist/source/plugins/lucide-icons.d.ts +14 -0
- package/dist/source/plugins/lucide-icons.d.ts.map +1 -0
- package/dist/source/plugins/lucide-icons.js +24 -0
- 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 +29 -0
- package/dist/source/schema.d.ts.map +1 -0
- package/dist/source/schema.js +29 -0
- 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 +42 -26
- package/dist/toc.d.ts.map +1 -0
- package/dist/toc.js +126 -117
- 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 +7 -4
- package/dist/utils/use-effect-event.d.ts.map +1 -0
- package/dist/utils/use-effect-event.js +17 -11
- package/dist/utils/use-effect-event.js.map +1 -0
- package/dist/utils/use-media-query.d.ts +5 -0
- package/dist/utils/use-media-query.d.ts.map +1 -0
- package/dist/utils/use-media-query.js +23 -0
- 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 +145 -76
- package/dist/algolia-NTWLS6J3.js +0 -49
- package/dist/chunk-BUCUQ3WX.js +0 -96
- package/dist/chunk-FVY6EZ3N.js +0 -94
- package/dist/chunk-KAOEMCTI.js +0 -17
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-NNKVN7WA.js +0 -35
- package/dist/chunk-ORHEEQVY.js +0 -26
- package/dist/chunk-WFUH5VBX.js +0 -77
- package/dist/chunk-XMCPKVJQ.js +0 -34
- package/dist/chunk-Y2774T3B.js +0 -58
- package/dist/config-inq6kP6y.d.ts +0 -26
- package/dist/fetch-W5EHIBOE.js +0 -21
- package/dist/get-toc-Cr2URuiP.d.ts +0 -25
- package/dist/orama-cloud-USLSOSXS.js +0 -84
- package/dist/page-tree-BG3wP0gU.d.ts +0 -57
- package/dist/remark-heading-BPCoYwjn.d.ts +0 -31
- package/dist/remark-structure-FIjTA11P.d.ts +0 -48
- package/dist/server/index.d.ts +0 -117
- package/dist/server/index.js +0 -202
- package/dist/sidebar.d.ts +0 -33
- package/dist/sidebar.js +0 -89
- package/dist/static-VESU2S64.js +0 -61
- package/dist/types-Ch8gnVgO.d.ts +0 -8
|
@@ -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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
2
|
+
import { remark } from "remark";
|
|
3
|
+
import remarkGfm from "remark-gfm";
|
|
4
|
+
import remarkRehype from "remark-rehype";
|
|
5
|
+
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/content/index.ts
|
|
8
|
+
function rehypeReact(options = {}) {
|
|
9
|
+
this.compiler = (tree, file) => {
|
|
10
|
+
return toJsxRuntime(tree, {
|
|
11
|
+
development: false,
|
|
12
|
+
filePath: file.path,
|
|
13
|
+
...JsxRuntime,
|
|
14
|
+
...options
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}
|
|
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;
|
|
20
|
+
}
|
|
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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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";
|
|
11
|
+
|
|
12
|
+
//#region src/content/mdx/preset-bundler.d.ts
|
|
13
|
+
type MDXBundlerPresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
|
|
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;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* apply MDX processor presets
|
|
25
|
+
*/
|
|
26
|
+
declare function mdxPreset(options?: MDXBundlerPresetOptions): Promise<ProcessorOptions>;
|
|
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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { t as resolvePlugins } from "../../util-s9piKHsk.js";
|
|
2
|
+
|
|
3
|
+
//#region src/content/mdx/preset-bundler.ts
|
|
4
|
+
/**
|
|
5
|
+
* apply MDX processor presets
|
|
6
|
+
*/
|
|
7
|
+
async function mdxPreset(options = {}) {
|
|
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
|
+
};
|
|
37
|
+
}
|
|
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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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";
|
|
11
|
+
|
|
12
|
+
//#region src/content/mdx/preset-runtime.d.ts
|
|
13
|
+
type MDXRuntimePresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
|
|
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;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* apply MDX processor presets
|
|
25
|
+
*/
|
|
26
|
+
declare function mdxPreset(options?: MDXRuntimePresetOptions): Promise<ProcessorOptions>;
|
|
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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { t as resolvePlugins } from "../../util-s9piKHsk.js";
|
|
2
|
+
|
|
3
|
+
//#region src/content/mdx/preset-runtime.ts
|
|
4
|
+
/**
|
|
5
|
+
* apply MDX processor presets
|
|
6
|
+
*/
|
|
7
|
+
async function mdxPreset(options = {}) {
|
|
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
|
+
};
|
|
35
|
+
}
|
|
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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get Table of Contents from markdown/mdx document (using remark)
|
|
9
|
+
*
|
|
10
|
+
* @param content - Markdown content or file
|
|
11
|
+
*/
|
|
12
|
+
declare function getTableOfContents(content: Compatible): TOCItemType[];
|
|
13
|
+
/**
|
|
14
|
+
* Get Table of Contents from markdown/mdx document (using remark)
|
|
15
|
+
*
|
|
16
|
+
* @param content - Markdown content or file
|
|
17
|
+
* @param remarkPlugins - remark plugins to be applied first
|
|
18
|
+
*/
|
|
19
|
+
declare function getTableOfContents(content: Compatible, remarkPlugins: PluggableList): Promise<TOCItemType[]>;
|
|
20
|
+
//#endregion
|
|
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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "../mdast-utils-mc9-X-PK.js";
|
|
2
|
+
import { remarkHeading } from "../mdx-plugins/remark-heading.js";
|
|
3
|
+
import { remark } from "remark";
|
|
4
|
+
|
|
5
|
+
//#region src/content/toc.ts
|
|
6
|
+
function getTableOfContents(content, remarkPlugins) {
|
|
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 [];
|
|
14
|
+
}
|
|
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"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/page-tree/definitions.d.ts
|
|
4
|
+
interface ID {
|
|
5
|
+
/**
|
|
6
|
+
* ID for the node, unique in all page trees (even across different locales)
|
|
7
|
+
*/
|
|
8
|
+
$id?: string;
|
|
9
|
+
}
|
|
10
|
+
interface Root extends ID {
|
|
11
|
+
name: ReactNode;
|
|
12
|
+
children: Node[];
|
|
13
|
+
/**
|
|
14
|
+
* Another page tree that won't be displayed unless being opened.
|
|
15
|
+
*/
|
|
16
|
+
fallback?: Root;
|
|
17
|
+
}
|
|
18
|
+
type Node = Item | Separator | Folder;
|
|
19
|
+
interface Item extends ID {
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
$ref?: {
|
|
24
|
+
file: string;
|
|
25
|
+
};
|
|
26
|
+
type: 'page';
|
|
27
|
+
name: ReactNode;
|
|
28
|
+
url: string;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the link should be treated as external (e.g. use HTML <a> tag).
|
|
31
|
+
*
|
|
32
|
+
* When unspecified, it depends on the value of `url`.
|
|
33
|
+
*/
|
|
34
|
+
external?: boolean;
|
|
35
|
+
description?: ReactNode;
|
|
36
|
+
icon?: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
interface Separator extends ID {
|
|
39
|
+
type: 'separator';
|
|
40
|
+
name?: ReactNode;
|
|
41
|
+
icon?: ReactNode;
|
|
42
|
+
}
|
|
43
|
+
interface Folder extends ID {
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
$ref?: {
|
|
48
|
+
metaFile?: string;
|
|
49
|
+
};
|
|
50
|
+
type: 'folder';
|
|
51
|
+
name: ReactNode;
|
|
52
|
+
description?: ReactNode;
|
|
53
|
+
root?: boolean;
|
|
54
|
+
defaultOpen?: boolean;
|
|
55
|
+
collapsible?: boolean;
|
|
56
|
+
index?: Item;
|
|
57
|
+
icon?: ReactNode;
|
|
58
|
+
children: Node[];
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { Separator as a, Root as i, Item as n, Node as r, Folder as t };
|
|
62
|
+
//# sourceMappingURL=definitions-DuxDer_c.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions-DuxDer_c.d.ts","names":[],"sources":["../src/page-tree/definitions.ts"],"sourcesContent":[],"mappings":";;;UAEU,EAAA;;AAF6B;AASvC;EACQ,GAAA,CAAA,EAAA,MAAA;;AAKK,UANI,IAAA,SAAa,EAMjB,CAAA;EANiB,IAAA,EACtB,SADsB;EAAE,QAAA,EAEpB,IAFoB,EAAA;EASpB;;;EAA0B,QAAA,CAAA,EAHzB,IAGyB;;AAErB,KAFL,IAAA,GAAO,IAEG,GAFI,SAEJ,GAFgB,MAEhB;AASd,UATS,IAAA,SAAa,EAStB,CAAA;EASQ;;;EAlBgB,IAAA,CAAA,EAAA;IAsBf,IAAA,EAAA,MAAU;EAElB,CAAA;EACA,IAAA,EAAA,MAAA;EAH0B,IAAA,EAb3B,SAa2B;EAAE,GAAA,EAAA,MAAA;EAMpB;;;;;EAgBL,QAAA,CAAA,EAAA,OAAA;EAhBoB,WAAA,CAAA,EAVhB,SAUgB;EAAE,IAAA,CAAA,EATzB,SASyB;;UANjB,SAAA,SAAkB;;SAE1B;SACA;;UAGQ,MAAA,SAAe;;;;;;;;QASxB;gBACQ;;;;UAIN;SACD;YACG"}
|
package/dist/dynamic-link.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { LinkProps } from "./link.js";
|
|
2
|
+
import * as react0 from "react";
|
|
3
3
|
|
|
4
|
+
//#region src/dynamic-link.d.ts
|
|
4
5
|
type DynamicLinkProps = LinkProps;
|
|
5
6
|
/**
|
|
6
7
|
* Extends the default `Link` component
|
|
7
8
|
*
|
|
8
9
|
* It supports dynamic hrefs, which means you can use `/[lang]/my-page` with `dynamicHrefs` enabled
|
|
9
10
|
*/
|
|
10
|
-
declare const DynamicLink:
|
|
11
|
-
|
|
12
|
-
export { DynamicLink,
|
|
11
|
+
declare const DynamicLink: react0.ForwardRefExoticComponent<LinkProps & react0.RefAttributes<HTMLAnchorElement>>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { DynamicLink, DynamicLink as default, DynamicLinkProps };
|
|
14
|
+
//# sourceMappingURL=dynamic-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-link.d.ts","names":[],"sources":["../src/dynamic-link.tsx"],"sourcesContent":[],"mappings":";;;;KAMY,gBAAA,GAAmB;;;AAA/B;AAQA;;AAAwB,cAAX,WAAW,EAAA,MAAA,CAAA,yBAAA,CAAA,SAAA,GAAA,MAAA,CAAA,aAAA,CAAA,iBAAA,CAAA,CAAA"}
|
package/dist/dynamic-link.js
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
Link
|
|
4
|
-
} from "./chunk-NNKVN7WA.js";
|
|
5
|
-
import {
|
|
6
|
-
useParams
|
|
7
|
-
} from "./chunk-FVY6EZ3N.js";
|
|
8
|
-
import "./chunk-MLKGABMK.js";
|
|
1
|
+
'use client';
|
|
9
2
|
|
|
10
|
-
|
|
3
|
+
import { useParams } from "./framework/index.js";
|
|
4
|
+
import Link from "./link.js";
|
|
11
5
|
import { forwardRef, useMemo } from "react";
|
|
12
6
|
import { jsx } from "react/jsx-runtime";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
);
|
|
7
|
+
|
|
8
|
+
//#region src/dynamic-link.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Extends the default `Link` component
|
|
11
|
+
*
|
|
12
|
+
* It supports dynamic hrefs, which means you can use `/[lang]/my-page` with `dynamicHrefs` enabled
|
|
13
|
+
*/
|
|
14
|
+
const DynamicLink = forwardRef(({ href, ...props }, ref) => {
|
|
15
|
+
const params = useParams();
|
|
16
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
17
|
+
ref,
|
|
18
|
+
href: useMemo(() => {
|
|
19
|
+
return href?.replace(/\[.*]/, (key) => {
|
|
20
|
+
const mappedKey = key.slice(1, -1);
|
|
21
|
+
const value = mappedKey in params ? params[mappedKey] : void 0;
|
|
22
|
+
if (!value) return "";
|
|
23
|
+
return typeof value === "string" ? value : value.join("/");
|
|
24
|
+
});
|
|
25
|
+
}, [params, href]),
|
|
26
|
+
...props
|
|
27
|
+
});
|
|
28
|
+
});
|
|
27
29
|
DynamicLink.displayName = "DynamicLink";
|
|
28
30
|
var dynamic_link_default = DynamicLink;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { DynamicLink, dynamic_link_default as default };
|
|
34
|
+
//# sourceMappingURL=dynamic-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-link.js","names":[],"sources":["../src/dynamic-link.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useMemo } from 'react';\nimport Link, { type LinkProps } from './link';\nimport { useParams } from '@/framework';\n\nexport type DynamicLinkProps = LinkProps;\n\n/**\n * Extends the default `Link` component\n *\n * It supports dynamic hrefs, which means you can use `/[lang]/my-page` with `dynamicHrefs` enabled\n */\n\nexport const DynamicLink = forwardRef<HTMLAnchorElement, DynamicLinkProps>(\n ({ href, ...props }, ref) => {\n const params = useParams();\n\n const url = useMemo(() => {\n return href?.replace(/\\[.*]/, (key) => {\n const mappedKey = key.slice(1, -1);\n const value = mappedKey in params ? params[mappedKey] : undefined;\n if (!value) return '';\n\n return typeof value === 'string' ? value : value.join('/');\n });\n }, [params, href]);\n\n return <Link ref={ref} href={url} {...props} />;\n },\n);\n\nDynamicLink.displayName = 'DynamicLink';\n\nexport default DynamicLink;\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,cAAc,YACxB,EAAE,MAAM,GAAG,SAAS,QAAQ;CAC3B,MAAM,SAAS,WAAW;AAY1B,QAAO,oBAAC;EAAU;EAAK,MAVX,cAAc;AACxB,UAAO,MAAM,QAAQ,UAAU,QAAQ;IACrC,MAAM,YAAY,IAAI,MAAM,GAAG,GAAG;IAClC,MAAM,QAAQ,aAAa,SAAS,OAAO,aAAa;AACxD,QAAI,CAAC,MAAO,QAAO;AAEnB,WAAO,OAAO,UAAU,WAAW,QAAQ,MAAM,KAAK,IAAI;KAC1D;KACD,CAAC,QAAQ,KAAK,CAAC;EAEgB,GAAI;GAAS;EAElD;AAED,YAAY,cAAc;AAE1B,2BAAe"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/search/client/fetch.ts
|
|
2
|
+
const cache = /* @__PURE__ */ new Map();
|
|
3
|
+
async function fetchDocs(query, { api = "/api/search", locale, tag }) {
|
|
4
|
+
const url = new URL(api, window.location.origin);
|
|
5
|
+
url.searchParams.set("query", query);
|
|
6
|
+
if (locale) url.searchParams.set("locale", locale);
|
|
7
|
+
if (tag) url.searchParams.set("tag", Array.isArray(tag) ? tag.join(",") : tag);
|
|
8
|
+
const key = url.toString();
|
|
9
|
+
const cached = cache.get(key);
|
|
10
|
+
if (cached) return cached;
|
|
11
|
+
const res = await fetch(url);
|
|
12
|
+
if (!res.ok) throw new Error(await res.text());
|
|
13
|
+
const result = await res.json();
|
|
14
|
+
cache.set(key, result);
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { fetchDocs };
|
|
20
|
+
//# sourceMappingURL=fetch-B5e9CFfN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-B5e9CFfN.js","names":[],"sources":["../src/search/client/fetch.ts"],"sourcesContent":["import type { SortedResult } from '@/search';\n\nexport interface FetchOptions {\n /**\n * API route for search endpoint, support absolute URLs.\n *\n * @defaultValue '/api/search'\n */\n api?: string;\n\n /**\n * Filter results with specific tag(s).\n */\n tag?: string | string[];\n\n /**\n * Filter by locale\n */\n locale?: string;\n}\n\nconst cache = new Map<string, SortedResult[]>();\n\nexport async function fetchDocs(\n query: string,\n { api = '/api/search', locale, tag }: FetchOptions,\n): Promise<SortedResult[]> {\n const url = new URL(api, window.location.origin);\n url.searchParams.set('query', query);\n if (locale) url.searchParams.set('locale', locale);\n if (tag) url.searchParams.set('tag', Array.isArray(tag) ? tag.join(',') : tag);\n\n const key = url.toString();\n const cached = cache.get(key);\n if (cached) return cached;\n\n const res = await fetch(url);\n if (!res.ok) throw new Error(await res.text());\n const result = (await res.json()) as SortedResult[];\n cache.set(key, result);\n return result;\n}\n"],"mappings":";AAqBA,MAAM,wBAAQ,IAAI,KAA6B;AAE/C,eAAsB,UACpB,OACA,EAAE,MAAM,eAAe,QAAQ,OACN;CACzB,MAAM,MAAM,IAAI,IAAI,KAAK,OAAO,SAAS,OAAO;AAChD,KAAI,aAAa,IAAI,SAAS,MAAM;AACpC,KAAI,OAAQ,KAAI,aAAa,IAAI,UAAU,OAAO;AAClD,KAAI,IAAK,KAAI,aAAa,IAAI,OAAO,MAAM,QAAQ,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI;CAE9E,MAAM,MAAM,IAAI,UAAU;CAC1B,MAAM,SAAS,MAAM,IAAI,IAAI;AAC7B,KAAI,OAAQ,QAAO;CAEnB,MAAM,MAAM,MAAM,MAAM,IAAI;AAC5B,KAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,MAAM,IAAI,MAAM,CAAC;CAC9C,MAAM,SAAU,MAAM,IAAI,MAAM;AAChC,OAAM,IAAI,KAAK,OAAO;AACtB,QAAO"}
|
|
@@ -1,48 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { StaticImport } from
|
|
1
|
+
import { ComponentProps, FC, ReactNode } from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import { StaticImport } from "next/dist/shared/lib/get-img-props";
|
|
4
4
|
|
|
5
|
+
//#region src/framework/index.d.ts
|
|
5
6
|
interface ImageProps extends Omit<ComponentProps<'img'>, 'src'> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
sizes?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Next.js Image component has other allowed type for `src`
|
|
10
|
+
*/
|
|
11
|
+
src?: string | StaticImport;
|
|
12
|
+
/**
|
|
13
|
+
* priority of image (from Next.js)
|
|
14
|
+
*/
|
|
15
|
+
priority?: boolean;
|
|
15
16
|
}
|
|
16
17
|
interface LinkProps extends ComponentProps<'a'> {
|
|
17
|
-
|
|
18
|
+
prefetch?: boolean;
|
|
18
19
|
}
|
|
19
20
|
interface Router {
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
push: (url: string) => void;
|
|
22
|
+
refresh: () => void;
|
|
22
23
|
}
|
|
23
24
|
interface Framework {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
usePathname: () => string;
|
|
26
|
+
useParams: () => Record<string, string | string[]>;
|
|
27
|
+
useRouter: () => Router;
|
|
28
|
+
Link?: FC<ComponentProps<'a'> & {
|
|
29
|
+
prefetch?: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
Image?: FC<ImageProps>;
|
|
31
32
|
}
|
|
32
|
-
declare function FrameworkProvider({
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
declare function FrameworkProvider({
|
|
34
|
+
Link,
|
|
35
|
+
useRouter,
|
|
36
|
+
useParams,
|
|
37
|
+
usePathname,
|
|
38
|
+
Image,
|
|
39
|
+
children
|
|
40
|
+
}: Framework & {
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
35
43
|
declare function usePathname(): string;
|
|
36
44
|
declare function useRouter(): Router;
|
|
37
45
|
declare function useParams(): Record<string, string | string[]>;
|
|
38
|
-
declare function Image(props: ImageProps):
|
|
39
|
-
declare function Link(props: LinkProps):
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
children: ReactNode;
|
|
44
|
-
}) => react_jsx_runtime.JSX.Element;
|
|
45
|
-
use: (errorMessage?: string) => Exclude<T, undefined | null>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export { type Framework, FrameworkProvider, Image, type ImageProps, Link, type Router, createContext, useParams, usePathname, useRouter };
|
|
46
|
+
declare function Image(props: ImageProps): react_jsx_runtime0.JSX.Element;
|
|
47
|
+
declare function Link(props: LinkProps): react_jsx_runtime0.JSX.Element;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { Framework, FrameworkProvider, Image, ImageProps, Link, Router, useParams, usePathname, useRouter };
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/framework/index.tsx"],"sourcesContent":[],"mappings":";;;;;UAKiB,UAAA,SAAmB,KAAK;;;AAAzC;;EAMiB,GAAA,CAAA,EAAA,MAAA,GAAA,YAAA;EANmB;;AAYnC;EAMgB,QAAA,CAAM,EAAA,OAAA;AAKvB;UATU,SAAA,SAAkB,cAWT,CAAA,GAAA,CAAA,CAAA;EACA,QAAA,CAAA,EAAA,OAAA;;AAEV,UAVQ,MAAA,CAUR;EAMI,IAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EAAH,OAAA,EAAA,GAAA,GAAA,IAAA;;AAaM,UAxBC,SAAA,CAwBgB;EAC/B,WAAA,EAAA,GAAA,GAAA,MAAA;EACA,SAAA,EAAA,GAAA,GAxBiB,MAwBjB,CAAA,MAAA,EAAA,MAAA,GAAA,MAAA,EAAA,CAAA;EACA,SAAA,EAAA,GAAA,GAxBiB,MAwBjB;EACA,IAAA,CAAA,EAvBO,EAuBP,CAtBE,cAsBF,CAAA,GAAA,CAAA,GAAA;IACA,QAAA,CAAA,EAAA,OAAA;EACA,CAAA,CAAA;EACC,KAAA,CAAA,EApBO,EAoBP,CApBU,UAoBV,CAAA;;AAAmC,iBAPtB,iBAAA,CAOsB;EAAA,IAAA;EAAA,SAAA;EAAA,SAAA;EAAA,WAAA;EAAA,KAAA;EAAA;AAetC,CAfsC,EAAnC,SAAmC,GAAA;EAAA,QAAA,EAAX,SAAW;AAetC,CAAA,CAAA,EAfsC,kBAAA,CAAA,GAAA,CAAA,OAeX;AAIX,iBAJA,WAAA,CAAA,CAIS,EAAA,MAAA;AAIT,iBAJA,SAAA,CAAA,CAIS,EAJA,MAIA;AAIT,iBAJA,SAAA,CAAA,CAIa,EAJJ,MAIc,CAAA,MAAA,EAAA,MAAA,GAAA,MAAA,EAAA,CAAA;AAavB,iBAbA,KAAA,CAaY,KAAS,EAbR,UAaQ,CAAA,EAbE,kBAAA,CAAA,GAAA,CAAA,OAaF;iBAArB,IAAA,QAAY,YAAS,kBAAA,CAAA,GAAA,CAAA"}
|
package/dist/framework/index.js
CHANGED
|
@@ -1,20 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
useRouter
|
|
10
|
-
} from "../chunk-FVY6EZ3N.js";
|
|
11
|
-
import "../chunk-MLKGABMK.js";
|
|
12
|
-
export {
|
|
13
|
-
FrameworkProvider,
|
|
14
|
-
Image,
|
|
15
|
-
Link,
|
|
16
|
-
createContext,
|
|
17
|
-
useParams,
|
|
18
|
-
usePathname,
|
|
19
|
-
useRouter
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createContext, use, useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/framework/index.tsx
|
|
7
|
+
const notImplemented = () => {
|
|
8
|
+
throw new Error("You need to wrap your application inside `FrameworkProvider`.");
|
|
20
9
|
};
|
|
10
|
+
const FrameworkContext = createContext({
|
|
11
|
+
useParams: notImplemented,
|
|
12
|
+
useRouter: notImplemented,
|
|
13
|
+
usePathname: notImplemented
|
|
14
|
+
});
|
|
15
|
+
function FrameworkProvider({ Link: Link$1, useRouter: useRouter$1, useParams: useParams$1, usePathname: usePathname$1, Image: Image$1, children }) {
|
|
16
|
+
return /* @__PURE__ */ jsx(FrameworkContext, {
|
|
17
|
+
value: useMemo(() => ({
|
|
18
|
+
usePathname: usePathname$1,
|
|
19
|
+
useRouter: useRouter$1,
|
|
20
|
+
Link: Link$1,
|
|
21
|
+
Image: Image$1,
|
|
22
|
+
useParams: useParams$1
|
|
23
|
+
}), [
|
|
24
|
+
Link$1,
|
|
25
|
+
usePathname$1,
|
|
26
|
+
useRouter$1,
|
|
27
|
+
useParams$1,
|
|
28
|
+
Image$1
|
|
29
|
+
]),
|
|
30
|
+
children
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function usePathname() {
|
|
34
|
+
return use(FrameworkContext).usePathname();
|
|
35
|
+
}
|
|
36
|
+
function useRouter() {
|
|
37
|
+
return use(FrameworkContext).useRouter();
|
|
38
|
+
}
|
|
39
|
+
function useParams() {
|
|
40
|
+
return use(FrameworkContext).useParams();
|
|
41
|
+
}
|
|
42
|
+
function Image(props) {
|
|
43
|
+
const { Image: Image$1 } = use(FrameworkContext);
|
|
44
|
+
if (!Image$1) {
|
|
45
|
+
const { src, alt, priority, ...rest } = props;
|
|
46
|
+
return /* @__PURE__ */ jsx("img", {
|
|
47
|
+
alt,
|
|
48
|
+
src,
|
|
49
|
+
fetchPriority: priority ? "high" : "auto",
|
|
50
|
+
...rest
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */ jsx(Image$1, { ...props });
|
|
54
|
+
}
|
|
55
|
+
function Link(props) {
|
|
56
|
+
const { Link: Link$1 } = use(FrameworkContext);
|
|
57
|
+
if (!Link$1) {
|
|
58
|
+
const { href, prefetch: _, ...rest } = props;
|
|
59
|
+
return /* @__PURE__ */ jsx("a", {
|
|
60
|
+
href,
|
|
61
|
+
...rest
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return /* @__PURE__ */ jsx(Link$1, { ...props });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { FrameworkProvider, Image, Link, useParams, usePathname, useRouter };
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["Link","usePathname","useRouter","useParams","Image"],"sources":["../../src/framework/index.tsx"],"sourcesContent":["'use client';\nimport type { ComponentProps, FC, ReactNode } from 'react';\nimport { createContext, use, useMemo } from 'react';\nimport type { StaticImport } from 'next/dist/shared/lib/get-img-props';\n\nexport interface ImageProps extends Omit<ComponentProps<'img'>, 'src'> {\n sizes?: string;\n\n /**\n * Next.js Image component has other allowed type for `src`\n */\n src?: string | StaticImport;\n\n /**\n * priority of image (from Next.js)\n */\n priority?: boolean;\n}\n\ninterface LinkProps extends ComponentProps<'a'> {\n prefetch?: boolean;\n}\n\nexport interface Router {\n push: (url: string) => void;\n refresh: () => void;\n}\n\nexport interface Framework {\n usePathname: () => string;\n useParams: () => Record<string, string | string[]>;\n useRouter: () => Router;\n\n Link?: FC<\n ComponentProps<'a'> & {\n prefetch?: boolean;\n }\n >;\n\n Image?: FC<ImageProps>;\n}\n\nconst notImplemented = () => {\n throw new Error('You need to wrap your application inside `FrameworkProvider`.');\n};\n\nconst FrameworkContext = createContext<Framework>({\n useParams: notImplemented,\n useRouter: notImplemented,\n usePathname: notImplemented,\n});\n\nexport function FrameworkProvider({\n Link,\n useRouter,\n useParams,\n usePathname,\n Image,\n children,\n}: Framework & { children: ReactNode }) {\n const framework = useMemo(\n () => ({\n usePathname,\n useRouter,\n Link,\n Image,\n useParams,\n }),\n [Link, usePathname, useRouter, useParams, Image],\n );\n\n return <FrameworkContext value={framework}>{children}</FrameworkContext>;\n}\n\nexport function usePathname() {\n return use(FrameworkContext).usePathname();\n}\n\nexport function useRouter() {\n return use(FrameworkContext).useRouter();\n}\n\nexport function useParams() {\n return use(FrameworkContext).useParams();\n}\n\nexport function Image(props: ImageProps) {\n const { Image } = use(FrameworkContext);\n if (!Image) {\n const { src, alt, priority, ...rest } = props;\n\n return (\n <img alt={alt} src={src as string} fetchPriority={priority ? 'high' : 'auto'} {...rest} />\n );\n }\n\n return <Image {...props} />;\n}\n\nexport function Link(props: LinkProps) {\n const { Link } = use(FrameworkContext);\n if (!Link) {\n const { href, prefetch: _, ...rest } = props;\n return <a href={href} {...rest} />;\n }\n\n return <Link {...props} />;\n}\n"],"mappings":";;;;;;AA0CA,MAAM,uBAAuB;AAC3B,OAAM,IAAI,MAAM,gEAAgE;;AAGlF,MAAM,mBAAmB,cAAyB;CAChD,WAAW;CACX,WAAW;CACX,aAAa;CACd,CAAC;AAEF,SAAgB,kBAAkB,EAChC,cACA,wBACA,wBACA,4BACA,gBACA,YACsC;AAYtC,QAAO,oBAAC;EAAiB,OAXP,eACT;GACL;GACA;GACA;GACA;GACA;GACD,GACD;GAACA;GAAMC;GAAaC;GAAWC;GAAWC;GAAM,CACjD;EAE2C;GAA4B;;AAG1E,SAAgB,cAAc;AAC5B,QAAO,IAAI,iBAAiB,CAAC,aAAa;;AAG5C,SAAgB,YAAY;AAC1B,QAAO,IAAI,iBAAiB,CAAC,WAAW;;AAG1C,SAAgB,YAAY;AAC1B,QAAO,IAAI,iBAAiB,CAAC,WAAW;;AAG1C,SAAgB,MAAM,OAAmB;CACvC,MAAM,EAAE,mBAAU,IAAI,iBAAiB;AACvC,KAAI,CAACA,SAAO;EACV,MAAM,EAAE,KAAK,KAAK,UAAU,GAAG,SAAS;AAExC,SACE,oBAAC;GAAS;GAAU;GAAe,eAAe,WAAW,SAAS;GAAQ,GAAI;IAAQ;;AAI9F,QAAO,oBAACA,WAAM,GAAI,QAAS;;AAG7B,SAAgB,KAAK,OAAkB;CACrC,MAAM,EAAE,iBAAS,IAAI,iBAAiB;AACtC,KAAI,CAACJ,QAAM;EACT,MAAM,EAAE,MAAM,UAAU,GAAG,GAAG,SAAS;AACvC,SAAO,oBAAC;GAAQ;GAAM,GAAI;IAAQ;;AAGpC,QAAO,oBAACA,UAAK,GAAI,QAAS"}
|