@hanzo/docs-core 16.5.0 → 16.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -3
- package/dist/{advanced-BRT5Ij43.js → advanced-BH0syJ-M.js} +3 -4
- package/dist/{algolia-CQPXCnjV.js → algolia-C7Crg8-5.js} +2 -3
- package/dist/breadcrumb.d.ts +2 -3
- package/dist/breadcrumb.js +3 -4
- package/dist/{chunk-B-ezknvj.js → chunk-CaR5F9JI.js} +3 -3
- package/dist/content/github.d.ts +1 -2
- package/dist/content/github.js +1 -2
- package/dist/content/index.d.ts +3 -4
- package/dist/content/index.js +1 -2
- package/dist/content/mdx/preset-bundler.d.ts +9 -10
- package/dist/content/mdx/preset-bundler.js +2 -3
- package/dist/content/mdx/preset-runtime.d.ts +9 -10
- package/dist/content/mdx/preset-runtime.js +2 -3
- package/dist/content/toc.d.ts +1 -3
- package/dist/content/toc.js +4 -5
- package/dist/create-i18n-Cv3Cocbs.d.ts +51 -0
- package/dist/{definitions-DuxDer_c.d.ts → definitions-DSNTbAwC.d.ts} +1 -2
- package/dist/dynamic-link.d.ts +3 -4
- package/dist/dynamic-link.js +1 -3
- package/dist/{fetch-B5e9CFfN.js → fetch-HotVeLLF.js} +1 -2
- package/dist/framework/index.d.ts +5 -6
- package/dist/framework/index.js +18 -19
- package/dist/framework/next.d.ts +3 -4
- package/dist/framework/next.js +1 -2
- package/dist/framework/react-router.d.ts +3 -4
- package/dist/framework/react-router.js +1 -2
- package/dist/framework/tanstack.d.ts +3 -4
- package/dist/framework/tanstack.js +1 -2
- package/dist/framework/waku.d.ts +3 -4
- package/dist/framework/waku.js +1 -2
- package/dist/hast-utils-BmGqqmvo.js +15 -0
- package/dist/highlight/client.d.ts +2 -4
- package/dist/highlight/client.js +7 -13
- package/dist/highlight/config.d.ts +15 -0
- package/dist/highlight/config.js +18 -0
- package/dist/highlight/core/client.d.ts +31 -0
- package/dist/highlight/core/client.js +68 -0
- package/dist/highlight/core/index.d.ts +27 -0
- package/dist/highlight/core/index.js +69 -0
- package/dist/highlight/index.d.ts +34 -2
- package/dist/highlight/index.js +57 -2
- package/dist/i18n/index.d.ts +39 -1
- package/dist/i18n/index.js +1 -2
- package/dist/i18n/middleware.d.ts +2 -3
- package/dist/i18n/middleware.js +1 -2
- package/dist/{icon-BWwSDabM.js → icon-OtPFhyk1.js} +1 -2
- package/dist/link.d.ts +3 -4
- package/dist/link.js +1 -2
- package/dist/{mdast-utils-mc9-X-PK.js → mdast-utils-gJMY143g.js} +1 -2
- package/dist/mdx-plugins/codeblock-utils.d.ts +35 -1
- package/dist/mdx-plugins/codeblock-utils.js +1 -2
- package/dist/mdx-plugins/index.d.ts +18 -15
- package/dist/mdx-plugins/index.js +7 -5
- package/dist/mdx-plugins/rehype-code.core.d.ts +38 -0
- package/dist/mdx-plugins/rehype-code.core.js +104 -0
- package/dist/mdx-plugins/rehype-code.d.ts +18 -2
- package/dist/mdx-plugins/rehype-code.js +24 -3
- package/dist/mdx-plugins/rehype-toc.d.ts +16 -1
- package/dist/mdx-plugins/rehype-toc.js +127 -1
- package/dist/mdx-plugins/remark-admonition.d.ts +20 -1
- package/dist/mdx-plugins/remark-admonition.js +2 -3
- package/dist/mdx-plugins/remark-code-tab.d.ts +30 -1
- package/dist/mdx-plugins/remark-code-tab.js +4 -5
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +34 -1
- package/dist/mdx-plugins/remark-directive-admonition.js +1 -2
- package/dist/mdx-plugins/remark-feedback-block.d.ts +51 -0
- package/dist/mdx-plugins/remark-feedback-block.js +47 -0
- package/dist/mdx-plugins/remark-gfm.d.ts +2 -2
- package/dist/mdx-plugins/remark-heading.d.ts +35 -1
- package/dist/mdx-plugins/remark-heading.js +2 -3
- package/dist/mdx-plugins/remark-image.d.ts +63 -1
- package/dist/mdx-plugins/remark-image.js +1 -2
- package/dist/mdx-plugins/remark-mdx-files.d.ts +55 -2
- package/dist/mdx-plugins/remark-mdx-files.js +103 -13
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +15 -1
- package/dist/mdx-plugins/remark-mdx-mermaid.js +1 -2
- package/dist/mdx-plugins/remark-npm.d.ts +34 -1
- package/dist/mdx-plugins/remark-npm.js +1 -2
- package/dist/mdx-plugins/remark-steps.d.ts +26 -1
- package/dist/mdx-plugins/remark-steps.js +1 -2
- package/dist/mdx-plugins/remark-structure.d.ts +75 -1
- package/dist/mdx-plugins/remark-structure.js +7 -8
- package/dist/{mixedbread-DlByNYSd.js → mixedbread-Bx9drx9S.js} +6 -5
- package/dist/negotiation/index.d.ts +1 -2
- package/dist/negotiation/index.js +1 -2
- package/dist/{normalize-url-ChLsV26G.js → normalize-url-DUHbcuVM.js} +1 -2
- package/dist/{orama-cloud-DH3g37zc.js → orama-cloud-ByznDyOk.js} +6 -7
- package/dist/orama-cloud-legacy-BbgJnf5f.js +81 -0
- package/dist/page-tree/index.d.ts +3 -45
- package/dist/page-tree/index.js +1 -1
- package/dist/{index-2U6Tl4--.d.ts → path-B77y3W0_.d.ts} +111 -98
- package/dist/{path-DHIjrDBP.js → path-D0Bwm6Fs.js} +2 -3
- package/dist/{remove-undefined-Cfs4o_mM.js → remove-undefined-CJm9cyrC.js} +1 -2
- package/dist/search/algolia.d.ts +66 -2
- package/dist/search/algolia.js +1 -2
- package/dist/search/client.d.ts +30 -7
- package/dist/search/client.js +27 -22
- package/dist/search/index.d.ts +1 -2
- package/dist/search/index.js +41 -1
- package/dist/search/orama-cloud-legacy.d.ts +77 -0
- package/dist/search/orama-cloud-legacy.js +49 -0
- package/dist/search/orama-cloud.d.ts +5 -9
- package/dist/search/orama-cloud.js +1 -2
- package/dist/search/server.d.ts +87 -4
- package/dist/search/server.js +7 -8
- package/dist/source/client/index.d.ts +13 -11
- package/dist/source/client/index.js +22 -13
- package/dist/source/index.d.ts +5 -3
- package/dist/source/index.js +428 -333
- package/dist/source/plugins/lucide-icons.d.ts +5 -4
- package/dist/source/plugins/lucide-icons.js +2 -3
- package/dist/source/plugins/slugs.d.ts +24 -2
- package/dist/source/plugins/slugs.js +2 -3
- package/dist/source/plugins/status-badges.d.ts +52 -0
- package/dist/source/plugins/status-badges.js +54 -0
- package/dist/source/schema.d.ts +1 -3
- package/dist/source/schema.js +1 -2
- package/dist/{static-Dq8pA8Ay.js → static-DTxK4eHk.js} +5 -6
- package/dist/toc.d.ts +1 -2
- package/dist/toc.js +1 -2
- package/dist/{rehype-code-sM9Tq-r7.js → transformer-icon-BYedaeE8.js} +1 -96
- package/dist/transformer-icon-D7-6aFzt.d.ts +18 -0
- package/dist/types-BSnJn7kF.d.ts +6 -0
- package/dist/{util-CK2ykiif.d.ts → util-C60LmklF.d.ts} +1 -2
- package/dist/{util-s9piKHsk.js → util-De0ALHOx.js} +1 -2
- package/dist/utils/use-media-query.d.ts +1 -2
- package/dist/utils/use-media-query.js +1 -2
- package/dist/utils/use-on-change.d.ts +1 -2
- package/dist/utils/use-on-change.js +1 -2
- package/dist/{utils-DUvi2WkD.js → utils-Bc53B3CJ.js} +8 -7
- package/dist/utils-IgHyYnrz.d.ts +45 -0
- package/package.json +68 -38
- package/dist/advanced-BRT5Ij43.js.map +0 -1
- package/dist/algolia-CQPXCnjV.js.map +0 -1
- package/dist/algolia-Cc1y6qWl.d.ts +0 -68
- package/dist/algolia-Cc1y6qWl.d.ts.map +0 -1
- package/dist/breadcrumb.d.ts.map +0 -1
- package/dist/breadcrumb.js.map +0 -1
- package/dist/codeblock-utils-DDnYb8gi.d.ts +0 -37
- package/dist/codeblock-utils-DDnYb8gi.d.ts.map +0 -1
- package/dist/content/github.d.ts.map +0 -1
- package/dist/content/github.js.map +0 -1
- package/dist/content/index.d.ts.map +0 -1
- package/dist/content/index.js.map +0 -1
- package/dist/content/mdx/preset-bundler.d.ts.map +0 -1
- package/dist/content/mdx/preset-bundler.js.map +0 -1
- package/dist/content/mdx/preset-runtime.d.ts.map +0 -1
- package/dist/content/mdx/preset-runtime.js.map +0 -1
- package/dist/content/toc.d.ts.map +0 -1
- package/dist/content/toc.js.map +0 -1
- package/dist/definitions-DuxDer_c.d.ts.map +0 -1
- package/dist/dynamic-link.d.ts.map +0 -1
- package/dist/dynamic-link.js.map +0 -1
- package/dist/fetch-B5e9CFfN.js.map +0 -1
- package/dist/framework/index.d.ts.map +0 -1
- package/dist/framework/index.js.map +0 -1
- package/dist/framework/next.d.ts.map +0 -1
- package/dist/framework/next.js.map +0 -1
- package/dist/framework/react-router.d.ts.map +0 -1
- package/dist/framework/react-router.js.map +0 -1
- package/dist/framework/tanstack.d.ts.map +0 -1
- package/dist/framework/tanstack.js.map +0 -1
- package/dist/framework/waku.d.ts.map +0 -1
- package/dist/framework/waku.js.map +0 -1
- package/dist/highlight/client.d.ts.map +0 -1
- package/dist/highlight/client.js.map +0 -1
- package/dist/i18n/index.js.map +0 -1
- package/dist/i18n/middleware.d.ts.map +0 -1
- package/dist/i18n/middleware.js.map +0 -1
- package/dist/icon-BWwSDabM.js.map +0 -1
- package/dist/index-2U6Tl4--.d.ts.map +0 -1
- package/dist/index-Bw-DCOra.d.ts +0 -41
- package/dist/index-Bw-DCOra.d.ts.map +0 -1
- package/dist/link.d.ts.map +0 -1
- package/dist/link.js.map +0 -1
- package/dist/mdast-utils-mc9-X-PK.js.map +0 -1
- package/dist/mdx-plugins/codeblock-utils.js.map +0 -1
- package/dist/mdx-plugins/remark-admonition.js.map +0 -1
- package/dist/mdx-plugins/remark-code-tab.js.map +0 -1
- package/dist/mdx-plugins/remark-directive-admonition.js.map +0 -1
- package/dist/mdx-plugins/remark-heading.js.map +0 -1
- package/dist/mdx-plugins/remark-image.js.map +0 -1
- package/dist/mdx-plugins/remark-mdx-files.js.map +0 -1
- package/dist/mdx-plugins/remark-mdx-mermaid.js.map +0 -1
- package/dist/mdx-plugins/remark-npm.js.map +0 -1
- package/dist/mdx-plugins/remark-steps.js.map +0 -1
- package/dist/mdx-plugins/remark-structure.js.map +0 -1
- package/dist/mixedbread-DlByNYSd.js.map +0 -1
- package/dist/negotiation/index.d.ts.map +0 -1
- package/dist/negotiation/index.js.map +0 -1
- package/dist/normalize-url-ChLsV26G.js.map +0 -1
- package/dist/orama-cloud-DH3g37zc.js.map +0 -1
- package/dist/page-tree/index.d.ts.map +0 -1
- package/dist/path-DHIjrDBP.js.map +0 -1
- package/dist/rehype-code-sM9Tq-r7.js.map +0 -1
- package/dist/rehype-code-vVWG4-ej.d.ts +0 -58
- package/dist/rehype-code-vVWG4-ej.d.ts.map +0 -1
- package/dist/rehype-toc-DJvSyE0o.d.ts +0 -18
- package/dist/rehype-toc-DJvSyE0o.d.ts.map +0 -1
- package/dist/rehype-toc-DVwJcwvA.js +0 -143
- package/dist/rehype-toc-DVwJcwvA.js.map +0 -1
- package/dist/remark-admonition-DOwBWzsH.d.ts +0 -22
- package/dist/remark-admonition-DOwBWzsH.d.ts.map +0 -1
- package/dist/remark-code-tab-CXsYlims.d.ts +0 -32
- package/dist/remark-code-tab-CXsYlims.d.ts.map +0 -1
- package/dist/remark-directive-admonition-BCm_yiU9.d.ts +0 -36
- package/dist/remark-directive-admonition-BCm_yiU9.d.ts.map +0 -1
- package/dist/remark-gfm-CeWpMwyk.d.ts +0 -2
- package/dist/remark-heading-CXvCY0go.d.ts +0 -37
- package/dist/remark-heading-CXvCY0go.d.ts.map +0 -1
- package/dist/remark-image-CvUis4R1.d.ts +0 -65
- package/dist/remark-image-CvUis4R1.d.ts.map +0 -1
- package/dist/remark-mdx-files-DOYafA4x.d.ts +0 -42
- package/dist/remark-mdx-files-DOYafA4x.d.ts.map +0 -1
- package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts +0 -17
- package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts.map +0 -1
- package/dist/remark-npm-Bo08HqcQ.d.ts +0 -36
- package/dist/remark-npm-Bo08HqcQ.d.ts.map +0 -1
- package/dist/remark-steps-CHJN-rtm.d.ts +0 -28
- package/dist/remark-steps-CHJN-rtm.d.ts.map +0 -1
- package/dist/remark-structure-DGuWR82i.d.ts +0 -77
- package/dist/remark-structure-DGuWR82i.d.ts.map +0 -1
- package/dist/remove-undefined-Cfs4o_mM.js.map +0 -1
- package/dist/search/algolia.js.map +0 -1
- package/dist/search/client.d.ts.map +0 -1
- package/dist/search/client.js.map +0 -1
- package/dist/search/index.d.ts.map +0 -1
- package/dist/search/orama-cloud.d.ts.map +0 -1
- package/dist/search/orama-cloud.js.map +0 -1
- package/dist/search/server.js.map +0 -1
- package/dist/search-D6ChCLhY.js +0 -44
- package/dist/search-D6ChCLhY.js.map +0 -1
- package/dist/server-DmY4lGBs.d.ts +0 -133
- package/dist/server-DmY4lGBs.d.ts.map +0 -1
- package/dist/shiki-B5wNmyIZ.js +0 -80
- package/dist/shiki-B5wNmyIZ.js.map +0 -1
- package/dist/shiki-Dq3XIYAT.d.ts +0 -33
- package/dist/shiki-Dq3XIYAT.d.ts.map +0 -1
- package/dist/source/client/index.d.ts.map +0 -1
- package/dist/source/client/index.js.map +0 -1
- package/dist/source/index.js.map +0 -1
- package/dist/source/plugins/lucide-icons.d.ts.map +0 -1
- package/dist/source/plugins/lucide-icons.js.map +0 -1
- package/dist/source/plugins/slugs.js.map +0 -1
- package/dist/source/schema.d.ts.map +0 -1
- package/dist/source/schema.js.map +0 -1
- package/dist/static-Dq8pA8Ay.js.map +0 -1
- package/dist/toc.d.ts.map +0 -1
- package/dist/toc.js.map +0 -1
- package/dist/util-CK2ykiif.d.ts.map +0 -1
- package/dist/util-s9piKHsk.js.map +0 -1
- package/dist/utils/use-effect-event.d.ts +0 -11
- package/dist/utils/use-effect-event.d.ts.map +0 -1
- package/dist/utils/use-effect-event.js +0 -19
- package/dist/utils/use-effect-event.js.map +0 -1
- package/dist/utils/use-media-query.d.ts.map +0 -1
- package/dist/utils/use-media-query.js.map +0 -1
- package/dist/utils/use-on-change.d.ts.map +0 -1
- package/dist/utils/use-on-change.js.map +0 -1
- package/dist/utils-DUvi2WkD.js.map +0 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { parseCodeBlockAttributes } from "./codeblock-utils.js";
|
|
2
|
+
import { t as transformerIcon } from "../transformer-icon-BYedaeE8.js";
|
|
3
|
+
import rehypeShikiFromHighlighter from "@shikijs/rehype/core";
|
|
4
|
+
import { transformerNotationDiff, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight } from "@shikijs/transformers";
|
|
5
|
+
|
|
6
|
+
//#region src/mdx-plugins/rehype-code.core.ts
|
|
7
|
+
function rehypeCodeDefaultOptions(config) {
|
|
8
|
+
return {
|
|
9
|
+
lazy: true,
|
|
10
|
+
...config.defaultThemes,
|
|
11
|
+
defaultColor: false,
|
|
12
|
+
defaultLanguage: "plaintext",
|
|
13
|
+
transformers: [
|
|
14
|
+
transformerNotationHighlight({ matchAlgorithm: "v3" }),
|
|
15
|
+
transformerNotationWordHighlight({ matchAlgorithm: "v3" }),
|
|
16
|
+
transformerNotationDiff({ matchAlgorithm: "v3" }),
|
|
17
|
+
transformerNotationFocus({ matchAlgorithm: "v3" })
|
|
18
|
+
],
|
|
19
|
+
parseMetaString(meta) {
|
|
20
|
+
const parsed = parseCodeBlockAttributes(meta, ["title", "tab"]);
|
|
21
|
+
const data = parsed.attributes;
|
|
22
|
+
parsed.rest = parseLineNumber(parsed.rest, data);
|
|
23
|
+
data.__parsed_raw = parsed.rest;
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function parseLineNumber(str, data) {
|
|
29
|
+
return str.replace(/lineNumbers=(\d+)|lineNumbers/, (_, ...args) => {
|
|
30
|
+
data["data-line-numbers"] = true;
|
|
31
|
+
if (args[0] !== void 0) data["data-line-numbers-start"] = Number(args[0]);
|
|
32
|
+
return "";
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function createRehypeCode(configFactory) {
|
|
36
|
+
return function rehypeCode(_options) {
|
|
37
|
+
const { config, options } = typeof configFactory === "function" ? configFactory(_options) : {
|
|
38
|
+
config: configFactory,
|
|
39
|
+
options: {
|
|
40
|
+
...rehypeCodeDefaultOptions(configFactory),
|
|
41
|
+
..._options
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const transformers = options.transformers ? [...options.transformers] : [];
|
|
45
|
+
transformers.unshift({
|
|
46
|
+
name: "rehype-code:pre-process",
|
|
47
|
+
preprocess(code, { meta }) {
|
|
48
|
+
if (meta && "__parsed_raw" in meta) {
|
|
49
|
+
meta.__raw = meta.__parsed_raw;
|
|
50
|
+
delete meta.__parsed_raw;
|
|
51
|
+
}
|
|
52
|
+
if (meta && options.filterMetaString) meta.__raw = options.filterMetaString(meta.__raw ?? "");
|
|
53
|
+
return code.replace(/\n$/, "");
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (options.icon !== false) transformers.push(transformerIcon(options.icon));
|
|
57
|
+
if (options.tab !== false) transformers.push(transformerTab());
|
|
58
|
+
const transformer = Promise.resolve(config.createHighlighter()).then(async (highlighter) => {
|
|
59
|
+
if ("themes" in options) await highlighter.loadTheme(...Object.values(options.themes).filter(Boolean));
|
|
60
|
+
else await highlighter.loadTheme(options.theme);
|
|
61
|
+
const langs = options.langs ?? (options.lazy ? [
|
|
62
|
+
"js",
|
|
63
|
+
"jsx",
|
|
64
|
+
"ts",
|
|
65
|
+
"tsx"
|
|
66
|
+
] : Object.keys(highlighter.getBundledLanguages()));
|
|
67
|
+
await highlighter.loadLanguage(...langs);
|
|
68
|
+
return rehypeShikiFromHighlighter(highlighter, {
|
|
69
|
+
...options,
|
|
70
|
+
transformers
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return async (tree, file) => {
|
|
74
|
+
await (await transformer)(tree, file, () => {});
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function transformerTab() {
|
|
79
|
+
return {
|
|
80
|
+
name: "rehype-code:tab",
|
|
81
|
+
root(root) {
|
|
82
|
+
const value = this.options.meta?.tab;
|
|
83
|
+
if (typeof value !== "string") return root;
|
|
84
|
+
console.warn("[Hanzo Docs] For `tab=\"value\" in codeblocks, please use `remarkCodeTab` plugin instead.");
|
|
85
|
+
return {
|
|
86
|
+
type: "root",
|
|
87
|
+
children: [{
|
|
88
|
+
type: "mdxJsxFlowElement",
|
|
89
|
+
name: "Tab",
|
|
90
|
+
data: { _codeblock: true },
|
|
91
|
+
attributes: [{
|
|
92
|
+
type: "mdxJsxAttribute",
|
|
93
|
+
name: "value",
|
|
94
|
+
value
|
|
95
|
+
}],
|
|
96
|
+
children: root.children
|
|
97
|
+
}]
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
export { createRehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-D7-6aFzt.js";
|
|
2
|
+
import { RehypeCodeOptionsCommon, transformerTab } from "./rehype-code.core.js";
|
|
3
|
+
import * as unified from "unified";
|
|
4
|
+
import * as hast from "hast";
|
|
5
|
+
|
|
6
|
+
//#region src/mdx-plugins/rehype-code.d.ts
|
|
7
|
+
type RehypeCodeOptions = RehypeCodeOptionsCommon & {
|
|
8
|
+
/**
|
|
9
|
+
* The regex engine to use.
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue 'js'
|
|
12
|
+
*/
|
|
13
|
+
engine?: 'js' | 'oniguruma';
|
|
14
|
+
};
|
|
15
|
+
declare const rehypeCodeDefaultOptions: RehypeCodeOptions;
|
|
16
|
+
declare const rehypeCode: (this: unified.Processor, _options: Partial<RehypeCodeOptions> | undefined) => unified.Transformer<hast.Root, hast.Root>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { type CodeBlockIcon, RehypeCodeOptions, rehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
1
|
+
import { configDefault, configWASM } from "../highlight/index.js";
|
|
2
|
+
import { t as transformerIcon } from "../transformer-icon-BYedaeE8.js";
|
|
3
|
+
import { createRehypeCode, rehypeCodeDefaultOptions as rehypeCodeDefaultOptions$1, transformerTab } from "./rehype-code.core.js";
|
|
4
4
|
|
|
5
|
+
//#region src/mdx-plugins/rehype-code.ts
|
|
6
|
+
const rehypeCodeDefaultOptions = {
|
|
7
|
+
engine: "js",
|
|
8
|
+
...rehypeCodeDefaultOptions$1(configDefault)
|
|
9
|
+
};
|
|
10
|
+
const rehypeCode = createRehypeCode((_options) => {
|
|
11
|
+
const options = {
|
|
12
|
+
...rehypeCodeDefaultOptions,
|
|
13
|
+
..._options
|
|
14
|
+
};
|
|
15
|
+
if (options.engine === "oniguruma") return {
|
|
16
|
+
config: configWASM,
|
|
17
|
+
options
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
config: configDefault,
|
|
21
|
+
options
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
5
26
|
export { rehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Processor, Transformer } from "unified";
|
|
2
|
+
import { Root } from "hast";
|
|
3
|
+
|
|
4
|
+
//#region src/mdx-plugins/rehype-toc.d.ts
|
|
5
|
+
interface RehypeTocOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Export generated toc as a variable
|
|
8
|
+
*
|
|
9
|
+
* @defaultValue true
|
|
10
|
+
*/
|
|
11
|
+
exportToc?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare function rehypeToc(this: Processor, {
|
|
14
|
+
exportToc
|
|
15
|
+
}?: RehypeTocOptions): Transformer<Root, Root>;
|
|
16
|
+
//#endregion
|
|
2
17
|
export { RehypeTocOptions, rehypeToc };
|
|
@@ -1,3 +1,129 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as visit } from "../hast-utils-BmGqqmvo.js";
|
|
2
|
+
import { toEstree } from "hast-util-to-estree";
|
|
2
3
|
|
|
4
|
+
//#region src/mdx-plugins/rehype-toc.ts
|
|
5
|
+
const TocOnlyTag = "[toc]";
|
|
6
|
+
const NoTocTag = "[!toc]";
|
|
7
|
+
function rehypeToc({ exportToc = true } = {}) {
|
|
8
|
+
return (tree) => {
|
|
9
|
+
const output = [];
|
|
10
|
+
visit(tree, [
|
|
11
|
+
"h1",
|
|
12
|
+
"h2",
|
|
13
|
+
"h3",
|
|
14
|
+
"h4",
|
|
15
|
+
"h5",
|
|
16
|
+
"h6"
|
|
17
|
+
], (element) => {
|
|
18
|
+
const id = element.properties.id;
|
|
19
|
+
if (typeof id !== "string") return "skip";
|
|
20
|
+
let isTocOnly = false;
|
|
21
|
+
const last = element.children.at(-1);
|
|
22
|
+
if (last?.type === "text" && last.value.endsWith(TocOnlyTag)) {
|
|
23
|
+
isTocOnly = true;
|
|
24
|
+
last.value = last.value.substring(0, last.value.length - 5).trimEnd();
|
|
25
|
+
} else if (last?.type === "text" && last.value.endsWith(NoTocTag)) {
|
|
26
|
+
last.value = last.value.substring(0, last.value.length - 6).trimEnd();
|
|
27
|
+
return "skip";
|
|
28
|
+
}
|
|
29
|
+
const estree = toEstree(element, {
|
|
30
|
+
elementAttributeNameCase: "react",
|
|
31
|
+
stylePropertyNameCase: "dom"
|
|
32
|
+
});
|
|
33
|
+
if (estree.body[0].type === "ExpressionStatement") output.push({
|
|
34
|
+
title: estree.body[0].expression,
|
|
35
|
+
depth: Number(element.tagName.slice(1)),
|
|
36
|
+
url: `#${id}`
|
|
37
|
+
});
|
|
38
|
+
if (isTocOnly) Object.assign(element, {
|
|
39
|
+
type: "comment",
|
|
40
|
+
value: ""
|
|
41
|
+
});
|
|
42
|
+
return "skip";
|
|
43
|
+
});
|
|
44
|
+
const declaration = {
|
|
45
|
+
type: "VariableDeclaration",
|
|
46
|
+
kind: "const",
|
|
47
|
+
declarations: [{
|
|
48
|
+
type: "VariableDeclarator",
|
|
49
|
+
id: {
|
|
50
|
+
type: "Identifier",
|
|
51
|
+
name: "toc"
|
|
52
|
+
},
|
|
53
|
+
init: {
|
|
54
|
+
type: "ArrayExpression",
|
|
55
|
+
elements: output.map((item) => ({
|
|
56
|
+
type: "ObjectExpression",
|
|
57
|
+
properties: [
|
|
58
|
+
{
|
|
59
|
+
type: "Property",
|
|
60
|
+
method: false,
|
|
61
|
+
shorthand: false,
|
|
62
|
+
computed: false,
|
|
63
|
+
key: {
|
|
64
|
+
type: "Identifier",
|
|
65
|
+
name: "depth"
|
|
66
|
+
},
|
|
67
|
+
value: {
|
|
68
|
+
type: "Literal",
|
|
69
|
+
value: item.depth
|
|
70
|
+
},
|
|
71
|
+
kind: "init"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: "Property",
|
|
75
|
+
method: false,
|
|
76
|
+
shorthand: false,
|
|
77
|
+
computed: false,
|
|
78
|
+
key: {
|
|
79
|
+
type: "Identifier",
|
|
80
|
+
name: "url"
|
|
81
|
+
},
|
|
82
|
+
value: {
|
|
83
|
+
type: "Literal",
|
|
84
|
+
value: item.url
|
|
85
|
+
},
|
|
86
|
+
kind: "init"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: "Property",
|
|
90
|
+
method: false,
|
|
91
|
+
shorthand: false,
|
|
92
|
+
computed: false,
|
|
93
|
+
key: {
|
|
94
|
+
type: "Identifier",
|
|
95
|
+
name: "title"
|
|
96
|
+
},
|
|
97
|
+
value: {
|
|
98
|
+
type: "JSXFragment",
|
|
99
|
+
openingFragment: { type: "JSXOpeningFragment" },
|
|
100
|
+
closingFragment: { type: "JSXClosingFragment" },
|
|
101
|
+
children: item.title.children
|
|
102
|
+
},
|
|
103
|
+
kind: "init"
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}))
|
|
107
|
+
}
|
|
108
|
+
}]
|
|
109
|
+
};
|
|
110
|
+
tree.children.push({
|
|
111
|
+
type: "mdxjsEsm",
|
|
112
|
+
value: "",
|
|
113
|
+
data: { estree: {
|
|
114
|
+
type: "Program",
|
|
115
|
+
body: [exportToc ? {
|
|
116
|
+
type: "ExportNamedDeclaration",
|
|
117
|
+
declaration,
|
|
118
|
+
attributes: [],
|
|
119
|
+
specifiers: []
|
|
120
|
+
} : declaration],
|
|
121
|
+
sourceType: "module",
|
|
122
|
+
comments: []
|
|
123
|
+
} }
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
3
129
|
export { rehypeToc };
|
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transformer } from "unified";
|
|
2
|
+
import { Root } from "mdast";
|
|
3
|
+
|
|
4
|
+
//#region src/mdx-plugins/remark-admonition.d.ts
|
|
5
|
+
interface RemarkAdmonitionOptions {
|
|
6
|
+
tag?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Map type to another type
|
|
9
|
+
*/
|
|
10
|
+
typeMap?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Remark Plugin to support Admonition syntax
|
|
14
|
+
*
|
|
15
|
+
* Useful when Migrating from Docusaurus
|
|
16
|
+
*
|
|
17
|
+
* @deprecated Use `remarkDirectiveAdmonition` with `remark-directive` configured instead.
|
|
18
|
+
*/
|
|
19
|
+
declare function remarkAdmonition(options?: RemarkAdmonitionOptions): Transformer<Root, Root>;
|
|
20
|
+
//#endregion
|
|
2
21
|
export { RemarkAdmonitionOptions, remarkAdmonition };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as flattenNode } from "../mdast-utils-
|
|
1
|
+
import { t as flattenNode } from "../mdast-utils-gJMY143g.js";
|
|
2
2
|
import { visit } from "unist-util-visit";
|
|
3
3
|
|
|
4
4
|
//#region src/mdx-plugins/remark-admonition.ts
|
|
@@ -70,5 +70,4 @@ function remarkAdmonition(options = {}) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
//#endregion
|
|
73
|
-
export { remarkAdmonition };
|
|
74
|
-
//# sourceMappingURL=remark-admonition.js.map
|
|
73
|
+
export { remarkAdmonition };
|
|
@@ -1,2 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Processor, Transformer } from "unified";
|
|
2
|
+
import { Code, Root } from "mdast";
|
|
3
|
+
import { MdxJsxFlowElement } from "mdast-util-mdx-jsx";
|
|
4
|
+
|
|
5
|
+
//#region src/mdx-plugins/remark-code-tab.d.ts
|
|
6
|
+
type TabType = keyof typeof Types;
|
|
7
|
+
interface RemarkCodeTabOptions {
|
|
8
|
+
Tabs?: TabType;
|
|
9
|
+
/**
|
|
10
|
+
* Parse MDX in tab values
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue false
|
|
13
|
+
*/
|
|
14
|
+
parseMdx?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare module 'mdast' {
|
|
17
|
+
interface CodeData {
|
|
18
|
+
tab?: string;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
declare const Types: {
|
|
22
|
+
CodeBlockTabs: {
|
|
23
|
+
convert(processor: Processor, nodes: Code[], withMdx?: boolean, withParent?: boolean): MdxJsxFlowElement;
|
|
24
|
+
};
|
|
25
|
+
Tabs: {
|
|
26
|
+
convert(processor: Processor, nodes: Code[], withMdx?: boolean, withParent?: boolean): MdxJsxFlowElement;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
declare function remarkCodeTab(this: Processor, options?: RemarkCodeTabOptions): Transformer<Root, Root>;
|
|
30
|
+
//#endregion
|
|
2
31
|
export { RemarkCodeTabOptions, remarkCodeTab };
|
|
@@ -25,7 +25,7 @@ const Types = {
|
|
|
25
25
|
Tabs: { convert(processor, nodes, withMdx = false, withParent = true) {
|
|
26
26
|
const tabs = Array.from(processTabValue(nodes).entries());
|
|
27
27
|
if (!withMdx) {
|
|
28
|
-
const children
|
|
28
|
+
const children = tabs.map(([name, codes]) => {
|
|
29
29
|
return {
|
|
30
30
|
type: "mdxJsxFlowElement",
|
|
31
31
|
name: "Tab",
|
|
@@ -37,7 +37,7 @@ const Types = {
|
|
|
37
37
|
children: codes
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
|
-
if (!withParent) return createFragment(children
|
|
40
|
+
if (!withParent) return createFragment(children);
|
|
41
41
|
return {
|
|
42
42
|
type: "mdxJsxFlowElement",
|
|
43
43
|
name: "Tabs",
|
|
@@ -64,7 +64,7 @@ const Types = {
|
|
|
64
64
|
} }
|
|
65
65
|
}
|
|
66
66
|
}],
|
|
67
|
-
children
|
|
67
|
+
children
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
const children = [{
|
|
@@ -180,5 +180,4 @@ function createFragment(children) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
//#endregion
|
|
183
|
-
export { remarkCodeTab };
|
|
184
|
-
//# sourceMappingURL=remark-code-tab.js.map
|
|
183
|
+
export { remarkCodeTab };
|
|
@@ -1,2 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transformer } from "unified";
|
|
2
|
+
import { Root } from "mdast";
|
|
3
|
+
|
|
4
|
+
//#region src/mdx-plugins/remark-directive-admonition.d.ts
|
|
5
|
+
interface RemarkDirectiveAdmonitionOptions {
|
|
6
|
+
/**
|
|
7
|
+
* the tag names of Callout component.
|
|
8
|
+
*/
|
|
9
|
+
tags?: {
|
|
10
|
+
CalloutContainer?: string;
|
|
11
|
+
CalloutTitle?: string;
|
|
12
|
+
CalloutDescription?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* All supported admonition types and their linked Callout type.
|
|
16
|
+
*
|
|
17
|
+
* When specified, all defaults will be cleared.
|
|
18
|
+
*/
|
|
19
|
+
types?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Remark Plugin to support Admonition syntax in Docusaurus, useful for migrating from Docusaurus.
|
|
23
|
+
*
|
|
24
|
+
* Requires [`remark-directive`](https://github.com/remarkjs/remark-directive) to be configured.
|
|
25
|
+
*/
|
|
26
|
+
declare function remarkDirectiveAdmonition({
|
|
27
|
+
tags: {
|
|
28
|
+
CalloutContainer,
|
|
29
|
+
CalloutTitle,
|
|
30
|
+
CalloutDescription
|
|
31
|
+
},
|
|
32
|
+
types
|
|
33
|
+
}?: RemarkDirectiveAdmonitionOptions): Transformer<Root, Root>;
|
|
34
|
+
//#endregion
|
|
2
35
|
export { RemarkDirectiveAdmonitionOptions, remarkDirectiveAdmonition };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Transformer } from "unified";
|
|
2
|
+
import { Root, RootContent } from "mdast";
|
|
3
|
+
|
|
4
|
+
//#region src/mdx-plugins/remark-feedback-block.d.ts
|
|
5
|
+
interface RemarkFeedbackBlockOptions {
|
|
6
|
+
/**
|
|
7
|
+
* generate block ID, default to using MD5.
|
|
8
|
+
*/
|
|
9
|
+
generateHash?: (ctx: {
|
|
10
|
+
body: string;
|
|
11
|
+
}) => string;
|
|
12
|
+
/**
|
|
13
|
+
* @defaultValue FeedbackBlock
|
|
14
|
+
*/
|
|
15
|
+
tagName?: string;
|
|
16
|
+
/**
|
|
17
|
+
* determine how the node should be resolved into a feedback block.
|
|
18
|
+
*
|
|
19
|
+
* scan paragraph, list, and image nodes by default.
|
|
20
|
+
*
|
|
21
|
+
* @returns
|
|
22
|
+
* - `true`: convert the node into a feedback block.
|
|
23
|
+
* - `false`: skip the current node and look into its children.
|
|
24
|
+
* - `skip`: skip the current node and its children.
|
|
25
|
+
*/
|
|
26
|
+
resolve?: (node: RootContent) => boolean | 'skip';
|
|
27
|
+
/**
|
|
28
|
+
* generate & include the block body to `<FeedbackBlock body="..." />` as string
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue true
|
|
31
|
+
*/
|
|
32
|
+
generateBody?: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface FeedbackBlockProps {
|
|
35
|
+
id: string;
|
|
36
|
+
/** the text body of block, only exists when `generateBody` is enabled. */
|
|
37
|
+
body?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generate MDX `<FeedbackBlock />` elements with an unique `id` for every block-like element.
|
|
41
|
+
*
|
|
42
|
+
* Note: the uniqueness is only guaranteed per MDX file/page.
|
|
43
|
+
*/
|
|
44
|
+
declare function remarkFeedbackBlock({
|
|
45
|
+
generateHash,
|
|
46
|
+
tagName,
|
|
47
|
+
resolve,
|
|
48
|
+
generateBody
|
|
49
|
+
}?: RemarkFeedbackBlockOptions): Transformer<Root, Root>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { FeedbackBlockProps, RemarkFeedbackBlockOptions, remarkFeedbackBlock };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { t as flattenNode } from "../mdast-utils-gJMY143g.js";
|
|
2
|
+
import { visit } from "unist-util-visit";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
//#region src/mdx-plugins/remark-feedback-block.ts
|
|
6
|
+
/**
|
|
7
|
+
* Generate MDX `<FeedbackBlock />` elements with an unique `id` for every block-like element.
|
|
8
|
+
*
|
|
9
|
+
* Note: the uniqueness is only guaranteed per MDX file/page.
|
|
10
|
+
*/
|
|
11
|
+
function remarkFeedbackBlock({ generateHash = ({ body }) => createHash("md5").update(body).digest("hex").substring(0, 16), tagName = "FeedbackBlock", resolve = (node) => node.type === "paragraph" || node.type === "image" || node.type === "list", generateBody = true } = {}) {
|
|
12
|
+
return (tree) => {
|
|
13
|
+
const counts = /* @__PURE__ */ new Map();
|
|
14
|
+
visit(tree, (node, index, parent) => {
|
|
15
|
+
if (node.type === "root") return;
|
|
16
|
+
const resolved = resolve(node);
|
|
17
|
+
if (resolved === false) return;
|
|
18
|
+
if (resolved === "skip") return "skip";
|
|
19
|
+
const text = flattenNode(node).trim();
|
|
20
|
+
if (text.length === 0 || !parent || typeof index !== "number") return;
|
|
21
|
+
let id = generateHash({ body: text });
|
|
22
|
+
const count = counts.get(id) ?? 0;
|
|
23
|
+
if (count > 0) id = `${id}-${count}`;
|
|
24
|
+
counts.set(id, count + 1);
|
|
25
|
+
const wrapper = {
|
|
26
|
+
type: "mdxJsxFlowElement",
|
|
27
|
+
name: tagName,
|
|
28
|
+
attributes: [{
|
|
29
|
+
type: "mdxJsxAttribute",
|
|
30
|
+
name: "id",
|
|
31
|
+
value: id
|
|
32
|
+
}],
|
|
33
|
+
children: [node]
|
|
34
|
+
};
|
|
35
|
+
if (generateBody) wrapper.attributes.push({
|
|
36
|
+
type: "mdxJsxAttribute",
|
|
37
|
+
name: "body",
|
|
38
|
+
value: text
|
|
39
|
+
});
|
|
40
|
+
parent.children[index] = wrapper;
|
|
41
|
+
return "skip";
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { remarkFeedbackBlock };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { RemarkGfmOptions, remarkGfm };
|
|
1
|
+
import remarkGfm, { Options as RemarkGfmOptions } from "remark-gfm";
|
|
2
|
+
export { type RemarkGfmOptions, remarkGfm };
|
|
@@ -1,2 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transformer } from "unified";
|
|
2
|
+
import { Heading, Root } from "mdast";
|
|
3
|
+
|
|
4
|
+
//#region src/mdx-plugins/remark-heading.d.ts
|
|
5
|
+
declare module 'mdast' {
|
|
6
|
+
interface HeadingData extends Data {
|
|
7
|
+
hProperties?: {
|
|
8
|
+
id?: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
interface RemarkHeadingOptions {
|
|
13
|
+
slug?: (root: Root, heading: Heading, text: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Allow custom headings ids
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue true
|
|
18
|
+
*/
|
|
19
|
+
customId?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Attach an array of `TOCItemType` to `file.data.toc`
|
|
22
|
+
*
|
|
23
|
+
* @defaultValue true
|
|
24
|
+
*/
|
|
25
|
+
generateToc?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Add heading ids and extract TOC
|
|
29
|
+
*/
|
|
30
|
+
declare function remarkHeading({
|
|
31
|
+
slug: defaultSlug,
|
|
32
|
+
customId,
|
|
33
|
+
generateToc
|
|
34
|
+
}?: RemarkHeadingOptions): Transformer<Root, Root>;
|
|
35
|
+
//#endregion
|
|
2
36
|
export { RemarkHeadingOptions, remarkHeading };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as flattenNode } from "../mdast-utils-
|
|
1
|
+
import { t as flattenNode } from "../mdast-utils-gJMY143g.js";
|
|
2
2
|
import Slugger from "github-slugger";
|
|
3
3
|
import { visit } from "unist-util-visit";
|
|
4
4
|
|
|
@@ -41,5 +41,4 @@ function remarkHeading({ slug: defaultSlug, customId = true, generateToc = true
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
//#endregion
|
|
44
|
-
export { remarkHeading };
|
|
45
|
-
//# sourceMappingURL=remark-heading.js.map
|
|
44
|
+
export { remarkHeading };
|
|
@@ -1,2 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transformer } from "unified";
|
|
2
|
+
import { Root } from "mdast";
|
|
3
|
+
|
|
4
|
+
//#region src/mdx-plugins/remark-image.d.ts
|
|
5
|
+
type ExternalImageOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* timeout for fetching remote images (in milliseconds)
|
|
8
|
+
*/
|
|
9
|
+
timeout?: number;
|
|
10
|
+
} | boolean;
|
|
11
|
+
interface RemarkImageOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Directory or base URL to resolve absolute image paths
|
|
14
|
+
*/
|
|
15
|
+
publicDir?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Preferred placeholder type, only available with `useImport` + local images.
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue 'blur'
|
|
20
|
+
*/
|
|
21
|
+
placeholder?: 'blur' | 'none';
|
|
22
|
+
/**
|
|
23
|
+
* Define how to handle errors when fetching image size.
|
|
24
|
+
*
|
|
25
|
+
* - `error` (default): throw an error.
|
|
26
|
+
* - `ignore`: do absolutely nothing (Next.js Image component may complain).
|
|
27
|
+
* - `hide`: remove that image element.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue 'error'
|
|
30
|
+
*/
|
|
31
|
+
onError?: 'error' | 'hide' | 'ignore' | ((error: Error) => void);
|
|
32
|
+
/**
|
|
33
|
+
* Import images in the file, and let bundlers handle it.
|
|
34
|
+
*
|
|
35
|
+
* ```tsx
|
|
36
|
+
* import MyImage from "./public/img.png";
|
|
37
|
+
*
|
|
38
|
+
* <img src={MyImage} />
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* When disabled, `placeholder` will be ignored.
|
|
42
|
+
*
|
|
43
|
+
* @defaultValue true
|
|
44
|
+
*/
|
|
45
|
+
useImport?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Fetch image size of external URLs
|
|
48
|
+
*
|
|
49
|
+
* @defaultValue true
|
|
50
|
+
*/
|
|
51
|
+
external?: ExternalImageOptions;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Turn images into Next.js Image compatible usage.
|
|
55
|
+
*/
|
|
56
|
+
declare function remarkImage({
|
|
57
|
+
placeholder,
|
|
58
|
+
external,
|
|
59
|
+
useImport,
|
|
60
|
+
onError,
|
|
61
|
+
publicDir
|
|
62
|
+
}?: RemarkImageOptions): Transformer<Root, Root>;
|
|
63
|
+
//#endregion
|
|
2
64
|
export { RemarkImageOptions, remarkImage };
|