@vezham/docs-core 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/advanced-Ct13khZr.js +79 -0
- package/dist/algolia-C0E5qQhM.d.ts +66 -0
- package/dist/breadcrumb.d.ts +46 -0
- package/dist/breadcrumb.js +59 -0
- package/dist/build-doc-4OvfjVN2.js +85 -0
- package/dist/client-kQ39Ub0-.d.ts +247 -0
- package/dist/codeblock-utils-CyP8qsYv.d.ts +29 -0
- package/dist/content/github.d.ts +41 -0
- package/dist/content/github.js +28 -0
- package/dist/content/md/frontmatter.d.ts +15 -0
- package/dist/content/md/frontmatter.js +24 -0
- package/dist/content/md.d.ts +24 -0
- package/dist/content/md.js +43 -0
- package/dist/content/mdx/preset-bundler.d.ts +29 -0
- package/dist/content/mdx/preset-bundler.js +39 -0
- package/dist/content/mdx/preset-runtime.d.ts +26 -0
- package/dist/content/mdx/preset-runtime.js +36 -0
- package/dist/content/toc.d.ts +19 -0
- package/dist/content/toc.js +14 -0
- package/dist/definitions-CFOhwE1k.d.ts +72 -0
- package/dist/dynamic-CTsodhTH.js +905 -0
- package/dist/dynamic-link.d.ts +12 -0
- package/dist/dynamic-link.js +31 -0
- package/dist/endpoint-MyoBU5IC.js +28 -0
- package/dist/framework/astro.d.ts +21 -0
- package/dist/framework/astro.js +52 -0
- package/dist/framework/index.d.ts +40 -0
- package/dist/framework/index.js +66 -0
- package/dist/framework/next.d.ts +10 -0
- package/dist/framework/next.js +19 -0
- package/dist/framework/react-router.d.ts +10 -0
- package/dist/framework/react-router.js +43 -0
- package/dist/framework/tanstack.d.ts +13 -0
- package/dist/framework/tanstack.js +54 -0
- package/dist/framework/waku.d.ts +10 -0
- package/dist/framework/waku.js +46 -0
- package/dist/highlight/client.d.ts +11 -0
- package/dist/highlight/client.js +15 -0
- package/dist/highlight/index.d.ts +31 -0
- package/dist/highlight/index.js +30 -0
- package/dist/highlight/shiki/full.d.ts +7 -0
- package/dist/highlight/shiki/full.js +23 -0
- package/dist/highlight/shiki/index.d.ts +2 -0
- package/dist/highlight/shiki/index.js +27 -0
- package/dist/highlight/shiki/react.d.ts +23 -0
- package/dist/highlight/shiki/react.js +50 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +63 -0
- package/dist/i18n/middleware.d.ts +34 -0
- package/dist/i18n/middleware.js +3855 -0
- package/dist/icon-BILaoXeg.js +17 -0
- package/dist/index-B-0R0VbS.d.ts +18 -0
- package/dist/index-BM36H-xw.d.ts +36 -0
- package/dist/index-BMEUQz-F.d.ts +21 -0
- package/dist/index-DAYtLGbx.d.ts +16 -0
- package/dist/index-DIwKCYOz.d.ts +513 -0
- package/dist/index-DydiXvgS.d.ts +90 -0
- package/dist/index-E8Qh_yQs.d.ts +49 -0
- package/dist/is-equal-LdLqRs0o.js +8 -0
- package/dist/link.d.ts +17 -0
- package/dist/link.js +23 -0
- package/dist/mdx-plugins/codeblock-utils.d.ts +2 -0
- package/dist/mdx-plugins/codeblock-utils.js +68 -0
- package/dist/mdx-plugins/index.d.ts +20 -0
- package/dist/mdx-plugins/index.js +18 -0
- package/dist/mdx-plugins/rehype-code.core.d.ts +3 -0
- package/dist/mdx-plugins/rehype-code.core.js +3 -0
- package/dist/mdx-plugins/rehype-code.d.ts +4 -0
- package/dist/mdx-plugins/rehype-code.js +24 -0
- package/dist/mdx-plugins/rehype-toc.d.ts +2 -0
- package/dist/mdx-plugins/rehype-toc.js +139 -0
- package/dist/mdx-plugins/remark-admonition.d.ts +2 -0
- package/dist/mdx-plugins/remark-admonition.js +71 -0
- package/dist/mdx-plugins/remark-block-id.d.ts +37 -0
- package/dist/mdx-plugins/remark-block-id.js +41 -0
- package/dist/mdx-plugins/remark-code-tab.d.ts +2 -0
- package/dist/mdx-plugins/remark-code-tab.js +190 -0
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -0
- package/dist/mdx-plugins/remark-directive-admonition.js +57 -0
- package/dist/mdx-plugins/remark-feedback-block.d.ts +2 -0
- package/dist/mdx-plugins/remark-feedback-block.js +54 -0
- package/dist/mdx-plugins/remark-gfm.d.ts +2 -0
- package/dist/mdx-plugins/remark-gfm.js +2 -0
- package/dist/mdx-plugins/remark-heading.d.ts +2 -0
- package/dist/mdx-plugins/remark-heading.js +46 -0
- package/dist/mdx-plugins/remark-image.d.ts +2 -0
- package/dist/mdx-plugins/remark-image.js +167 -0
- package/dist/mdx-plugins/remark-llms.d.ts +2 -0
- package/dist/mdx-plugins/remark-llms.js +338 -0
- package/dist/mdx-plugins/remark-llms.runtime.d.ts +10 -0
- package/dist/mdx-plugins/remark-llms.runtime.js +24 -0
- package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -0
- package/dist/mdx-plugins/remark-mdx-files.js +182 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.js +28 -0
- package/dist/mdx-plugins/remark-npm.d.ts +2 -0
- package/dist/mdx-plugins/remark-npm.js +76 -0
- package/dist/mdx-plugins/remark-steps.d.ts +2 -0
- package/dist/mdx-plugins/remark-steps.js +93 -0
- package/dist/mdx-plugins/remark-structure.d.ts +2 -0
- package/dist/mdx-plugins/remark-structure.js +118 -0
- package/dist/mdx-plugins/stringifier.d.ts +2 -0
- package/dist/mdx-plugins/stringifier.js +91 -0
- package/dist/mdx-plugins/transformer-icon.d.ts +2 -0
- package/dist/mdx-plugins/transformer-icon.js +145 -0
- package/dist/negotiation/index.d.ts +17 -0
- package/dist/negotiation/index.js +378 -0
- package/dist/page-tree/index.d.ts +3 -0
- package/dist/page-tree/index.js +2 -0
- package/dist/path-1H5VzYiT.js +75 -0
- package/dist/rehype-code-D-RFJb9W.d.ts +14 -0
- package/dist/rehype-code.core-BUwNuchP.js +548 -0
- package/dist/rehype-code.core-BjH1uHWj.d.ts +115 -0
- package/dist/rehype-toc-K51AGb5U.d.ts +43 -0
- package/dist/remark-admonition-BwTcmI_S.d.ts +20 -0
- package/dist/remark-code-tab-DE_4bdnu.d.ts +34 -0
- package/dist/remark-directive-admonition-BLiJ5l43.d.ts +27 -0
- package/dist/remark-feedback-block-BxtINXN-.d.ts +45 -0
- package/dist/remark-gfm-DpVfAX1x.d.ts +2 -0
- package/dist/remark-heading-DEIzTkU5.d.ts +33 -0
- package/dist/remark-image-BI2S9LOb.d.ts +57 -0
- package/dist/remark-llms-bD3WvU2V.d.ts +73 -0
- package/dist/remark-mdx-files-Buvxc-sa.d.ts +54 -0
- package/dist/remark-mdx-mermaid-C1bCHHc6.d.ts +15 -0
- package/dist/remark-npm-BbpvkJaT.d.ts +31 -0
- package/dist/remark-steps-DqVEo0iq.d.ts +23 -0
- package/dist/remark-structure-CnHwvNZr.d.ts +87 -0
- package/dist/remove-markdown-DfKNMl9w.js +40 -0
- package/dist/remove-undefined-CzMSKybq.js +24 -0
- package/dist/rolldown-runtime-DC62tzP2.js +33 -0
- package/dist/search/algolia.d.ts +2 -0
- package/dist/search/algolia.js +75 -0
- package/dist/search/client/algolia.d.ts +2 -0
- package/dist/search/client/algolia.js +53 -0
- package/dist/search/client/fetch.d.ts +2 -0
- package/dist/search/client/fetch.js +28 -0
- package/dist/search/client/flexsearch-static.d.ts +2 -0
- package/dist/search/client/flexsearch-static.js +42 -0
- package/dist/search/client/mixedbread.d.ts +2 -0
- package/dist/search/client/mixedbread.js +65 -0
- package/dist/search/client/orama-cloud-legacy.d.ts +2 -0
- package/dist/search/client/orama-cloud-legacy.js +84 -0
- package/dist/search/client/orama-cloud.d.ts +2 -0
- package/dist/search/client/orama-cloud.js +86 -0
- package/dist/search/client/orama-static.d.ts +2 -0
- package/dist/search/client/orama-static.js +75 -0
- package/dist/search/client.d.ts +2 -0
- package/dist/search/client.js +97 -0
- package/dist/search/flexsearch.d.ts +56 -0
- package/dist/search/flexsearch.js +128 -0
- package/dist/search/index.d.ts +2 -0
- package/dist/search/index.js +74 -0
- package/dist/search/mixedbread.d.ts +49 -0
- package/dist/search/mixedbread.js +77 -0
- package/dist/search/orama-cloud-legacy.d.ts +75 -0
- package/dist/search/orama-cloud-legacy.js +48 -0
- package/dist/search/orama-cloud.d.ts +75 -0
- package/dist/search/orama-cloud.js +50 -0
- package/dist/search/server.d.ts +2 -0
- package/dist/search/server.js +237 -0
- package/dist/server-CCqACwlF.d.ts +165 -0
- package/dist/server.browser.d.ts +13 -0
- package/dist/server.browser.js +22 -0
- package/dist/server.d.ts +42 -0
- package/dist/server.js +398 -0
- package/dist/source/client/index.d.ts +2 -0
- package/dist/source/client/index.js +37 -0
- package/dist/source/dynamic.d.ts +2 -0
- package/dist/source/dynamic.js +2 -0
- package/dist/source/index.d.ts +2 -0
- package/dist/source/index.js +5 -0
- package/dist/source/llms.d.ts +2 -0
- package/dist/source/llms.js +74 -0
- package/dist/source/plugins/lucide-icons.d.ts +11 -0
- package/dist/source/plugins/lucide-icons.js +21 -0
- package/dist/source/plugins/slugs.d.ts +2 -0
- package/dist/source/plugins/slugs.js +75 -0
- package/dist/source/plugins/status-badges.d.ts +50 -0
- package/dist/source/plugins/status-badges.js +52 -0
- package/dist/source/schema.d.ts +30 -0
- package/dist/source/schema.js +28 -0
- package/dist/stringifier-B_QUcUyo.d.ts +63 -0
- package/dist/toc-CtW5lwA1.d.ts +64 -0
- package/dist/toc.d.ts +2 -0
- package/dist/toc.js +245 -0
- package/dist/transformer-icon-DlrneIS3.d.ts +17 -0
- package/dist/types-D89QoQR-.d.ts +4 -0
- package/dist/url-BVHvi3_K.js +29 -0
- package/dist/util-BDsqOxh3.d.ts +6 -0
- package/dist/util-DjBr9b3w.js +8 -0
- package/dist/utils/use-media-query.d.ts +4 -0
- package/dist/utils/use-media-query.js +20 -0
- package/dist/utils/use-on-change.d.ts +9 -0
- package/dist/utils/use-on-change.js +17 -0
- package/dist/utils-Bvy3V-fv.js +59 -0
- package/dist/utils-Cgs-6U-z.js +39 -0
- package/dist/utils-DEVq3cEC.js +151 -0
- package/dist/utils-Yx0IL9eW.js +48 -0
- package/package.json +251 -0
|
@@ -0,0 +1,28 @@
|
|
|
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 customize 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);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { getGithubLastEdit };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/content/md/frontmatter.d.ts
|
|
2
|
+
interface Output {
|
|
3
|
+
/**
|
|
4
|
+
* The matter section, including the delimiter.
|
|
5
|
+
*/
|
|
6
|
+
matter: string;
|
|
7
|
+
content: string;
|
|
8
|
+
data: unknown;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* parse frontmatter, it supports only yaml format
|
|
12
|
+
*/
|
|
13
|
+
declare function frontmatter(input: string): Output;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { frontmatter };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { parse } from "yaml";
|
|
2
|
+
//#region src/content/md/frontmatter.ts
|
|
3
|
+
/**
|
|
4
|
+
* Inspired by https://github.com/jonschlinkert/gray-matter
|
|
5
|
+
*/
|
|
6
|
+
const regex = /^---\r?\n(.+?)\r?\n---\r?\n?/s;
|
|
7
|
+
/**
|
|
8
|
+
* parse frontmatter, it supports only yaml format
|
|
9
|
+
*/
|
|
10
|
+
function frontmatter(input) {
|
|
11
|
+
const output = {
|
|
12
|
+
matter: "",
|
|
13
|
+
data: {},
|
|
14
|
+
content: input
|
|
15
|
+
};
|
|
16
|
+
const match = regex.exec(input);
|
|
17
|
+
if (!match) return output;
|
|
18
|
+
output.matter = match[0];
|
|
19
|
+
output.content = input.slice(match[0].length);
|
|
20
|
+
output.data = parse(match[1]) ?? {};
|
|
21
|
+
return output;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { frontmatter };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { Options } from "remark-rehype";
|
|
3
|
+
import { Compatible } from "vfile";
|
|
4
|
+
import { Components } from "hast-util-to-jsx-runtime";
|
|
5
|
+
import { PluggableList } from "unified";
|
|
6
|
+
//#region src/content/md.d.ts
|
|
7
|
+
interface MarkdownRendererOptions {
|
|
8
|
+
remarkPlugins?: PluggableList;
|
|
9
|
+
rehypePlugins?: PluggableList;
|
|
10
|
+
remarkRehypeOptions?: Options;
|
|
11
|
+
}
|
|
12
|
+
interface MarkdownRenderer {
|
|
13
|
+
Markdown: FC<MarkdownProps>;
|
|
14
|
+
MarkdownServer: FC<Omit<MarkdownProps, 'async'>>;
|
|
15
|
+
}
|
|
16
|
+
interface MarkdownProps {
|
|
17
|
+
async?: boolean;
|
|
18
|
+
components?: Components;
|
|
19
|
+
children: Compatible;
|
|
20
|
+
}
|
|
21
|
+
declare function createMarkdownRenderer({ rehypePlugins, remarkPlugins, remarkRehypeOptions }?: MarkdownRendererOptions): MarkdownRenderer;
|
|
22
|
+
declare function Markdown(props: MarkdownProps & MarkdownRendererOptions): import("react").ReactNode | Promise<import("react").ReactNode>;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { Markdown, MarkdownProps, MarkdownRenderer, MarkdownRendererOptions, createMarkdownRenderer };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { use, useMemo } from "react";
|
|
2
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
3
|
+
import { remark } from "remark";
|
|
4
|
+
import remarkRehype from "remark-rehype";
|
|
5
|
+
import { VFile } from "vfile";
|
|
6
|
+
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
7
|
+
//#region src/content/md.ts
|
|
8
|
+
function createMarkdownRenderer({ rehypePlugins = [], remarkPlugins = [], remarkRehypeOptions } = {}) {
|
|
9
|
+
const processor = remark().use(remarkPlugins).use(remarkRehype, remarkRehypeOptions).use(rehypePlugins);
|
|
10
|
+
const promises = {};
|
|
11
|
+
function render(tree, file, props) {
|
|
12
|
+
return toJsxRuntime(tree, {
|
|
13
|
+
development: false,
|
|
14
|
+
filePath: file.path,
|
|
15
|
+
components: props.components,
|
|
16
|
+
...JsxRuntime
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function parse(file) {
|
|
20
|
+
return processor.parse(file);
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
Markdown(props) {
|
|
24
|
+
const { async = false, children } = props;
|
|
25
|
+
const file = new VFile(children);
|
|
26
|
+
const id = `${file.path}:${file.value}`;
|
|
27
|
+
if (async) {
|
|
28
|
+
promises[id] ??= processor.run(parse(file), file);
|
|
29
|
+
return render(use(promises[id]), file, props);
|
|
30
|
+
}
|
|
31
|
+
return render(useMemo(() => processor.runSync(parse(file), file), [id]), file, props);
|
|
32
|
+
},
|
|
33
|
+
async MarkdownServer(props) {
|
|
34
|
+
const file = new VFile(props.children);
|
|
35
|
+
return render(await processor.run(parse(file), file), file, props);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function Markdown(props) {
|
|
40
|
+
return createMarkdownRenderer(props).MarkdownServer(props);
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { Markdown, createMarkdownRenderer };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { t as RehypeCodeOptions } from "../../rehype-code-D-RFJb9W.js";
|
|
2
|
+
import { t as RemarkImageOptions } from "../../remark-image-BI2S9LOb.js";
|
|
3
|
+
import { r as StructureOptions } from "../../remark-structure-CnHwvNZr.js";
|
|
4
|
+
import { t as RemarkHeadingOptions } from "../../remark-heading-DEIzTkU5.js";
|
|
5
|
+
import { t as RemarkCodeTabOptions } from "../../remark-code-tab-DE_4bdnu.js";
|
|
6
|
+
import { t as RemarkNpmOptions } from "../../remark-npm-BbpvkJaT.js";
|
|
7
|
+
import "../../index-DAYtLGbx.js";
|
|
8
|
+
import { t as ResolvePlugins } from "../../util-BDsqOxh3.js";
|
|
9
|
+
import { Pluggable } from "unified";
|
|
10
|
+
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
11
|
+
//#region src/content/mdx/preset-bundler.d.ts
|
|
12
|
+
type MDXBundlerPresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
|
|
13
|
+
rehypePlugins?: ResolvePlugins;
|
|
14
|
+
remarkPlugins?: ResolvePlugins;
|
|
15
|
+
/** @private for `remark-include` */
|
|
16
|
+
_include?: Pluggable;
|
|
17
|
+
remarkStructureOptions?: StructureOptions | false;
|
|
18
|
+
remarkHeadingOptions?: RemarkHeadingOptions | false;
|
|
19
|
+
remarkImageOptions?: RemarkImageOptions | false;
|
|
20
|
+
remarkCodeTabOptions?: RemarkCodeTabOptions | false;
|
|
21
|
+
remarkNpmOptions?: RemarkNpmOptions | false;
|
|
22
|
+
rehypeCodeOptions?: RehypeCodeOptions | false;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* apply MDX processor presets
|
|
26
|
+
*/
|
|
27
|
+
declare function mdxPreset(options?: MDXBundlerPresetOptions): Promise<ProcessorOptions>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { MDXBundlerPresetOptions, mdxPreset };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { t as resolvePlugins } from "../../util-DjBr9b3w.js";
|
|
2
|
+
//#region src/content/mdx/preset-bundler.ts
|
|
3
|
+
/**
|
|
4
|
+
* apply MDX processor presets
|
|
5
|
+
*/
|
|
6
|
+
async function mdxPreset(options = {}) {
|
|
7
|
+
const { rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, remarkNpmOptions, _include, ...mdxOptions } = options;
|
|
8
|
+
const remarkPlugins = await resolvePlugins((v) => [
|
|
9
|
+
import("remark-gfm").then((mod) => mod.default),
|
|
10
|
+
remarkHeadingOptions !== false && import("../../mdx-plugins/remark-heading.js").then((mod) => [mod.remarkHeading, {
|
|
11
|
+
generateToc: false,
|
|
12
|
+
...remarkHeadingOptions
|
|
13
|
+
}]),
|
|
14
|
+
_include ?? false,
|
|
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
|
+
//#endregion
|
|
39
|
+
export { mdxPreset };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { t as RehypeCodeOptions } from "../../rehype-code-D-RFJb9W.js";
|
|
2
|
+
import { t as RemarkImageOptions } from "../../remark-image-BI2S9LOb.js";
|
|
3
|
+
import { r as StructureOptions } from "../../remark-structure-CnHwvNZr.js";
|
|
4
|
+
import { t as RemarkHeadingOptions } from "../../remark-heading-DEIzTkU5.js";
|
|
5
|
+
import { t as RemarkCodeTabOptions } from "../../remark-code-tab-DE_4bdnu.js";
|
|
6
|
+
import { t as RemarkNpmOptions } from "../../remark-npm-BbpvkJaT.js";
|
|
7
|
+
import "../../index-DAYtLGbx.js";
|
|
8
|
+
import { t as ResolvePlugins } from "../../util-BDsqOxh3.js";
|
|
9
|
+
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
10
|
+
//#region src/content/mdx/preset-runtime.d.ts
|
|
11
|
+
type MDXRuntimePresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
|
|
12
|
+
rehypePlugins?: ResolvePlugins;
|
|
13
|
+
remarkPlugins?: ResolvePlugins;
|
|
14
|
+
remarkStructureOptions?: StructureOptions | false;
|
|
15
|
+
remarkHeadingOptions?: RemarkHeadingOptions | false;
|
|
16
|
+
remarkImageOptions?: RemarkImageOptions | false;
|
|
17
|
+
remarkCodeTabOptions?: RemarkCodeTabOptions | false;
|
|
18
|
+
remarkNpmOptions?: RemarkNpmOptions | false;
|
|
19
|
+
rehypeCodeOptions?: RehypeCodeOptions | false;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* apply MDX processor presets
|
|
23
|
+
*/
|
|
24
|
+
declare function mdxPreset(options?: MDXRuntimePresetOptions): Promise<ProcessorOptions>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { MDXRuntimePresetOptions, mdxPreset };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { t as resolvePlugins } from "../../util-DjBr9b3w.js";
|
|
2
|
+
//#region src/content/mdx/preset-runtime.ts
|
|
3
|
+
/**
|
|
4
|
+
* apply MDX processor presets
|
|
5
|
+
*/
|
|
6
|
+
async function mdxPreset(options = {}) {
|
|
7
|
+
const { rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, remarkNpmOptions, outputFormat = "function-body", ...mdxOptions } = options;
|
|
8
|
+
const remarkPlugins = await resolvePlugins((v) => [
|
|
9
|
+
import("remark-gfm").then((mod) => mod.default),
|
|
10
|
+
remarkHeadingOptions !== false && import("../../mdx-plugins/remark-heading.js").then((mod) => [mod.remarkHeading, {
|
|
11
|
+
generateToc: false,
|
|
12
|
+
...remarkHeadingOptions
|
|
13
|
+
}]),
|
|
14
|
+
remarkImageOptions !== false && import("../../mdx-plugins/remark-image.js").then((mod) => [mod.remarkImage, remarkImageOptions]),
|
|
15
|
+
remarkCodeTabOptions !== false && import("../../mdx-plugins/remark-code-tab.js").then((mod) => [mod.remarkCodeTab, remarkCodeTabOptions]),
|
|
16
|
+
remarkNpmOptions !== false && import("../../mdx-plugins/remark-npm.js").then((mod) => [mod.remarkNpm, remarkNpmOptions]),
|
|
17
|
+
...v,
|
|
18
|
+
remarkStructureOptions !== false && import("../../mdx-plugins/remark-structure.js").then((mod) => [mod.remarkStructure, {
|
|
19
|
+
exportAs: "structuredData",
|
|
20
|
+
...remarkStructureOptions
|
|
21
|
+
}])
|
|
22
|
+
], mdxOptions.remarkPlugins);
|
|
23
|
+
const rehypePlugins = await resolvePlugins((v) => [
|
|
24
|
+
rehypeCodeOptions !== false && import("../../mdx-plugins/rehype-code.js").then((mod) => [mod.rehypeCode, rehypeCodeOptions]),
|
|
25
|
+
...v,
|
|
26
|
+
import("../../mdx-plugins/rehype-toc.js").then((mod) => mod.rehypeToc)
|
|
27
|
+
], mdxOptions.rehypePlugins);
|
|
28
|
+
return {
|
|
29
|
+
...mdxOptions,
|
|
30
|
+
outputFormat,
|
|
31
|
+
remarkPlugins,
|
|
32
|
+
rehypePlugins
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { mdxPreset };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { c as TOCItemType } from "../toc-CtW5lwA1.js";
|
|
2
|
+
import { Compatible } from "vfile";
|
|
3
|
+
import { PluggableList } from "unified";
|
|
4
|
+
//#region src/content/toc.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Get Table of Contents from markdown/mdx document (using remark)
|
|
7
|
+
*
|
|
8
|
+
* @param content - Markdown content or file
|
|
9
|
+
*/
|
|
10
|
+
declare function getTableOfContents(content: Compatible): TOCItemType[];
|
|
11
|
+
/**
|
|
12
|
+
* Get Table of Contents from markdown/mdx document (using remark)
|
|
13
|
+
*
|
|
14
|
+
* @param content - Markdown content or file
|
|
15
|
+
* @param remarkPlugins - remark plugins to be applied first
|
|
16
|
+
*/
|
|
17
|
+
declare function getTableOfContents(content: Compatible, remarkPlugins: PluggableList): Promise<TOCItemType[]>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { getTableOfContents };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { remarkHeading } from "../mdx-plugins/remark-heading.js";
|
|
2
|
+
import { remark } from "remark";
|
|
3
|
+
//#region src/content/toc.ts
|
|
4
|
+
function getTableOfContents(content, remarkPlugins) {
|
|
5
|
+
if (remarkPlugins) return remark().use(remarkPlugins).use(remarkHeading).process(content).then((result) => {
|
|
6
|
+
if ("toc" in result.data) return result.data.toc;
|
|
7
|
+
return [];
|
|
8
|
+
});
|
|
9
|
+
const result = remark().use(remarkHeading).processSync(content);
|
|
10
|
+
if ("toc" in result.data) return result.data.toc;
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getTableOfContents };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/page-tree/definitions.d.ts
|
|
3
|
+
interface ID {
|
|
4
|
+
/**
|
|
5
|
+
* ID for the node, unique in all page trees (even across different locales)
|
|
6
|
+
*/
|
|
7
|
+
$id?: string;
|
|
8
|
+
}
|
|
9
|
+
interface Root extends ID {
|
|
10
|
+
/**
|
|
11
|
+
* @internal folder `$ref`
|
|
12
|
+
*/
|
|
13
|
+
$ref?: Folder['$ref'];
|
|
14
|
+
type?: 'root';
|
|
15
|
+
name: ReactNode;
|
|
16
|
+
description?: ReactNode;
|
|
17
|
+
children: Node[];
|
|
18
|
+
/**
|
|
19
|
+
* Another page tree that won't be displayed unless being opened.
|
|
20
|
+
*/
|
|
21
|
+
fallback?: Root;
|
|
22
|
+
}
|
|
23
|
+
type Node = Item | Separator | Folder;
|
|
24
|
+
interface Item extends ID {
|
|
25
|
+
/**
|
|
26
|
+
* @internal page file path
|
|
27
|
+
*/
|
|
28
|
+
$ref?: string;
|
|
29
|
+
type: 'page';
|
|
30
|
+
name: ReactNode;
|
|
31
|
+
url: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the link should be treated as external (e.g. use HTML <a> tag).
|
|
34
|
+
*
|
|
35
|
+
* When unspecified, it depends on the value of `url`.
|
|
36
|
+
*/
|
|
37
|
+
external?: boolean;
|
|
38
|
+
description?: ReactNode;
|
|
39
|
+
icon?: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
interface Separator extends ID {
|
|
42
|
+
type: 'separator';
|
|
43
|
+
name?: ReactNode;
|
|
44
|
+
icon?: ReactNode;
|
|
45
|
+
}
|
|
46
|
+
interface Folder extends ID {
|
|
47
|
+
/**
|
|
48
|
+
* @internal paths of meta file & folder
|
|
49
|
+
*/
|
|
50
|
+
$ref?: {
|
|
51
|
+
meta?: string;
|
|
52
|
+
folder: string;
|
|
53
|
+
};
|
|
54
|
+
type: 'folder';
|
|
55
|
+
name: ReactNode;
|
|
56
|
+
description?: ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Mark as a root folder, `true` for the default type.
|
|
59
|
+
*
|
|
60
|
+
* A string value specifies its **root type**: root folders of the same type
|
|
61
|
+
* under the same parent scope are interchangeable (e.g. versions), and pages
|
|
62
|
+
* can map to their structural projection in another root.
|
|
63
|
+
*/
|
|
64
|
+
root?: boolean | string;
|
|
65
|
+
defaultOpen?: boolean;
|
|
66
|
+
collapsible?: boolean;
|
|
67
|
+
index?: Item;
|
|
68
|
+
icon?: ReactNode;
|
|
69
|
+
children: Node[];
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { Separator as a, Root as i, Item as n, Node as r, Folder as t };
|