fumadocs-core 16.5.3 → 16.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{advanced-BH0syJ-M.js → advanced-ZOIuXvBJ.js} +9 -12
- package/dist/{algolia-C7Crg8-5.js → algolia-CfKKhsrI.js} +1 -1
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/content/md.d.ts +30 -0
- package/dist/content/md.js +47 -0
- package/dist/content/mdx/preset-bundler.d.ts +2 -2
- package/dist/content/mdx/preset-bundler.js +1 -1
- package/dist/content/mdx/preset-runtime.d.ts +2 -2
- package/dist/content/mdx/preset-runtime.js +1 -1
- package/dist/create-endpoint-9PZc4Cmz.js +23 -0
- package/dist/{create-i18n-Cv3Cocbs.d.ts → create-i18n-DxSvCSv-.d.ts} +2 -2
- package/dist/highlight/config.d.ts +1 -1
- package/dist/highlight/core/client.d.ts +1 -1
- package/dist/highlight/core/index.d.ts +1 -1
- package/dist/highlight/index.d.ts +1 -1
- package/dist/mdx-plugins/index.d.ts +3 -3
- package/dist/mdx-plugins/index.js +2 -2
- package/dist/mdx-plugins/rehype-code.core.d.ts +2 -2
- package/dist/mdx-plugins/rehype-code.d.ts +1 -1
- package/dist/mdx-plugins/remark-feedback-block.d.ts +1 -1
- package/dist/mdx-plugins/remark-feedback-block.js +11 -3
- package/dist/mdx-plugins/remark-structure.d.ts +65 -20
- package/dist/mdx-plugins/remark-structure.js +96 -50
- package/dist/mixedbread-RiA_24CE.js +58 -0
- package/dist/{orama-cloud-ByznDyOk.js → orama-cloud-cgTJNLo0.js} +9 -13
- package/dist/{orama-cloud-legacy-BbgJnf5f.js → orama-cloud-legacy-Caf8mcU9.js} +5 -9
- package/dist/page-tree/index.d.ts +2 -2
- package/dist/{path-B77y3W0_.d.ts → path-CDjb5iUO.d.ts} +1 -1
- package/dist/{mixedbread-Bx9drx9S.js → remove-markdown-CnXcUR-e.js} +2 -51
- package/dist/search/client.d.ts +9 -4
- package/dist/search/client.js +6 -6
- package/dist/search/index.d.ts +7 -0
- package/dist/search/index.js +48 -20
- package/dist/search/mixedbread.d.ts +56 -0
- package/dist/search/mixedbread.js +79 -0
- package/dist/search/orama-cloud-legacy.d.ts +1 -1
- package/dist/search/orama-cloud.d.ts +1 -1
- package/dist/search/server.d.ts +4 -4
- package/dist/search/server.js +4 -24
- package/dist/source/client/index.d.ts +2 -2
- package/dist/source/index.d.ts +3 -3
- package/dist/source/index.js +2 -2
- package/dist/source/plugins/lucide-icons.d.ts +3 -3
- package/dist/source/plugins/lucide-icons.js +1 -1
- package/dist/source/plugins/slugs.d.ts +3 -3
- package/dist/source/plugins/slugs.js +1 -1
- package/dist/source/plugins/status-badges.d.ts +3 -3
- package/dist/{static-DTxK4eHk.js → static-BUXJwBmr.js} +1 -1
- package/dist/{utils-IgHyYnrz.d.ts → utils-5HX-8dF3.d.ts} +1 -1
- package/package.json +4 -4
- package/dist/content/index.d.ts +0 -22
- package/dist/content/index.js +0 -23
- /package/dist/{definitions-DSNTbAwC.d.ts → definitions-Cw2aM1Af.d.ts} +0 -0
- /package/dist/{fetch-HotVeLLF.js → fetch-D_OY-eAB.js} +0 -0
- /package/dist/{icon-BcFuYa-b.js → icon-CGDZIqYj.js} +0 -0
- /package/dist/{path-D0Bwm6Fs.js → path-CfJghBXy.js} +0 -0
- /package/dist/{remove-undefined-CJm9cyrC.js → remove-undefined-B_oBVupY.js} +0 -0
- /package/dist/{transformer-icon-D7-6aFzt.d.ts → transformer-icon-C8MUuI2T.d.ts} +0 -0
- /package/dist/{types-BSnJn7kF.d.ts → types-Bt4vrwsT.d.ts} +0 -0
- /package/dist/{util-C60LmklF.d.ts → util-C7X6g0ql.d.ts} +0 -0
- /package/dist/{util-De0ALHOx.js → util-bgCahl6-.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContentHighlighter } from "./search/index.js";
|
|
2
|
-
import { t as removeUndefined } from "./remove-undefined-
|
|
2
|
+
import { t as removeUndefined } from "./remove-undefined-B_oBVupY.js";
|
|
3
3
|
import { getByID, search } from "@orama/orama";
|
|
4
4
|
|
|
5
5
|
//#region src/search/orama/search/simple.ts
|
|
@@ -15,9 +15,8 @@ async function searchSimple(db, query, params = {}) {
|
|
|
15
15
|
}
|
|
16
16
|
})).hits.map((hit) => ({
|
|
17
17
|
type: "page",
|
|
18
|
-
content: hit.document.title,
|
|
18
|
+
content: highlighter.highlightMarkdown(hit.document.title),
|
|
19
19
|
breadcrumbs: hit.document.breadcrumbs,
|
|
20
|
-
contentWithHighlights: highlighter.highlight(hit.document.title),
|
|
21
20
|
id: hit.document.url,
|
|
22
21
|
url: hit.document.url
|
|
23
22
|
}));
|
|
@@ -27,24 +26,24 @@ async function searchSimple(db, query, params = {}) {
|
|
|
27
26
|
//#region src/search/orama/search/advanced.ts
|
|
28
27
|
async function searchAdvanced(db, query, tag = [], { mode = "fulltext", ...override } = {}) {
|
|
29
28
|
if (typeof tag === "string") tag = [tag];
|
|
30
|
-
|
|
29
|
+
const params = {
|
|
31
30
|
...override,
|
|
32
31
|
mode,
|
|
33
32
|
where: removeUndefined({
|
|
34
33
|
tags: tag.length > 0 ? { containsAll: tag } : void 0,
|
|
35
34
|
...override.where
|
|
36
35
|
}),
|
|
36
|
+
limit: 10,
|
|
37
37
|
groupBy: {
|
|
38
38
|
properties: ["page_id"],
|
|
39
39
|
maxResult: 8,
|
|
40
40
|
...override.groupBy
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
if (query.length > 0) params
|
|
44
|
-
...params,
|
|
43
|
+
if (query.length > 0) Object.assign(params, {
|
|
45
44
|
term: query,
|
|
46
45
|
properties: mode === "fulltext" ? ["content"] : ["content", "embeddings"]
|
|
47
|
-
};
|
|
46
|
+
});
|
|
48
47
|
const highlighter = createContentHighlighter(query);
|
|
49
48
|
const result = await search(db, params);
|
|
50
49
|
const list = [];
|
|
@@ -55,24 +54,22 @@ async function searchAdvanced(db, query, tag = [], { mode = "fulltext", ...overr
|
|
|
55
54
|
list.push({
|
|
56
55
|
id: pageId,
|
|
57
56
|
type: "page",
|
|
58
|
-
content: page.content,
|
|
57
|
+
content: highlighter.highlightMarkdown(page.content),
|
|
59
58
|
breadcrumbs: page.breadcrumbs,
|
|
60
|
-
contentWithHighlights: highlighter.highlight(page.content),
|
|
61
59
|
url: page.url
|
|
62
60
|
});
|
|
63
61
|
for (const hit of item.result) {
|
|
64
62
|
if (hit.document.type === "page") continue;
|
|
65
63
|
list.push({
|
|
66
64
|
id: hit.document.id.toString(),
|
|
67
|
-
content: hit.document.content,
|
|
65
|
+
content: highlighter.highlightMarkdown(hit.document.content),
|
|
68
66
|
breadcrumbs: hit.document.breadcrumbs,
|
|
69
|
-
contentWithHighlights: highlighter.highlight(hit.document.content),
|
|
70
67
|
type: hit.document.type,
|
|
71
68
|
url: hit.document.url
|
|
72
69
|
});
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
|
-
return list;
|
|
72
|
+
return list.length > 80 ? list.slice(0, 80) : list;
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
//#endregion
|
|
@@ -38,7 +38,7 @@ async function searchDocs(query, { indexName, onSearch, client, locale, tag }) {
|
|
|
38
38
|
return groupResults(result.results[0].hits).flatMap((hit) => {
|
|
39
39
|
if (hit.type === "page") return {
|
|
40
40
|
...hit,
|
|
41
|
-
|
|
41
|
+
content: highlighter.highlightMarkdown(hit.content)
|
|
42
42
|
};
|
|
43
43
|
return [];
|
|
44
44
|
});
|
package/dist/breadcrumb.d.ts
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as react from "react";
|
|
2
|
+
import { FC } from "react";
|
|
3
|
+
import { Options } from "remark-rehype";
|
|
4
|
+
import { Compatible } from "vfile";
|
|
5
|
+
import { Components } from "hast-util-to-jsx-runtime";
|
|
6
|
+
import { PluggableList } from "unified";
|
|
7
|
+
|
|
8
|
+
//#region src/content/md.d.ts
|
|
9
|
+
interface MarkdownRendererOptions {
|
|
10
|
+
remarkPlugins?: PluggableList;
|
|
11
|
+
rehypePlugins?: PluggableList;
|
|
12
|
+
remarkRehypeOptions?: Options;
|
|
13
|
+
}
|
|
14
|
+
interface MarkdownRenderer {
|
|
15
|
+
Markdown: FC<MarkdownProps>;
|
|
16
|
+
MarkdownServer: FC<Omit<MarkdownProps, 'async'>>;
|
|
17
|
+
}
|
|
18
|
+
interface MarkdownProps {
|
|
19
|
+
async?: boolean;
|
|
20
|
+
components?: Components;
|
|
21
|
+
children: Compatible;
|
|
22
|
+
}
|
|
23
|
+
declare function createMarkdownRenderer({
|
|
24
|
+
rehypePlugins,
|
|
25
|
+
remarkPlugins,
|
|
26
|
+
remarkRehypeOptions
|
|
27
|
+
}?: MarkdownRendererOptions): MarkdownRenderer;
|
|
28
|
+
declare function Markdown(props: MarkdownProps & MarkdownRendererOptions): react.ReactNode | Promise<react.ReactNode>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Markdown, MarkdownProps, MarkdownRenderer, MarkdownRendererOptions, createMarkdownRenderer };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { use } 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
|
+
|
|
8
|
+
//#region src/content/md.ts
|
|
9
|
+
function createMarkdownRenderer({ rehypePlugins = [], remarkPlugins = [], remarkRehypeOptions } = {}) {
|
|
10
|
+
const processor = remark().use(remarkPlugins).use(remarkRehype, remarkRehypeOptions).use(rehypePlugins);
|
|
11
|
+
const cache = {};
|
|
12
|
+
const promises = {};
|
|
13
|
+
function render(tree, file, props) {
|
|
14
|
+
return toJsxRuntime(tree, {
|
|
15
|
+
development: false,
|
|
16
|
+
filePath: file.path,
|
|
17
|
+
components: props.components,
|
|
18
|
+
...JsxRuntime
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function parse(file, _props) {
|
|
22
|
+
return processor.parse(file);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
Markdown(props) {
|
|
26
|
+
const { async = false, children } = props;
|
|
27
|
+
const file = new VFile(children);
|
|
28
|
+
const key = String(file.value);
|
|
29
|
+
if (async) {
|
|
30
|
+
promises[key] ??= processor.run(parse(file, props), file);
|
|
31
|
+
return render(use(promises[key]), file, props);
|
|
32
|
+
}
|
|
33
|
+
cache[key] ??= processor.runSync(parse(file, props), file);
|
|
34
|
+
return render(cache[key], file, props);
|
|
35
|
+
},
|
|
36
|
+
async MarkdownServer(props) {
|
|
37
|
+
const file = new VFile(props.children);
|
|
38
|
+
return render(await processor.run(parse(file, props), file), file, props);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function Markdown(props) {
|
|
43
|
+
return createMarkdownRenderer(props).MarkdownServer(props);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { Markdown, createMarkdownRenderer };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../transformer-icon-
|
|
1
|
+
import "../../transformer-icon-C8MUuI2T.js";
|
|
2
2
|
import { RehypeCodeOptions } from "../../mdx-plugins/rehype-code.js";
|
|
3
3
|
import { RemarkImageOptions } from "../../mdx-plugins/remark-image.js";
|
|
4
4
|
import { StructureOptions } from "../../mdx-plugins/remark-structure.js";
|
|
@@ -6,7 +6,7 @@ import { RemarkHeadingOptions } from "../../mdx-plugins/remark-heading.js";
|
|
|
6
6
|
import { RemarkCodeTabOptions } from "../../mdx-plugins/remark-code-tab.js";
|
|
7
7
|
import { RemarkNpmOptions } from "../../mdx-plugins/remark-npm.js";
|
|
8
8
|
import "../../mdx-plugins/index.js";
|
|
9
|
-
import { t as ResolvePlugins } from "../../util-
|
|
9
|
+
import { t as ResolvePlugins } from "../../util-C7X6g0ql.js";
|
|
10
10
|
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
11
11
|
|
|
12
12
|
//#region src/content/mdx/preset-bundler.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../transformer-icon-
|
|
1
|
+
import "../../transformer-icon-C8MUuI2T.js";
|
|
2
2
|
import { RehypeCodeOptions } from "../../mdx-plugins/rehype-code.js";
|
|
3
3
|
import { RemarkImageOptions } from "../../mdx-plugins/remark-image.js";
|
|
4
4
|
import { StructureOptions } from "../../mdx-plugins/remark-structure.js";
|
|
@@ -6,7 +6,7 @@ import { RemarkHeadingOptions } from "../../mdx-plugins/remark-heading.js";
|
|
|
6
6
|
import { RemarkCodeTabOptions } from "../../mdx-plugins/remark-code-tab.js";
|
|
7
7
|
import { RemarkNpmOptions } from "../../mdx-plugins/remark-npm.js";
|
|
8
8
|
import "../../mdx-plugins/index.js";
|
|
9
|
-
import { t as ResolvePlugins } from "../../util-
|
|
9
|
+
import { t as ResolvePlugins } from "../../util-C7X6g0ql.js";
|
|
10
10
|
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
11
11
|
|
|
12
12
|
//#region src/content/mdx/preset-runtime.d.ts
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/search/orama/create-endpoint.ts
|
|
2
|
+
function createEndpoint(server) {
|
|
3
|
+
const { search } = server;
|
|
4
|
+
return {
|
|
5
|
+
...server,
|
|
6
|
+
async staticGET() {
|
|
7
|
+
return Response.json(await server.export());
|
|
8
|
+
},
|
|
9
|
+
async GET(request) {
|
|
10
|
+
const url = new URL(request.url);
|
|
11
|
+
const query = url.searchParams.get("query");
|
|
12
|
+
if (!query) return Response.json([]);
|
|
13
|
+
return Response.json(await search(query, {
|
|
14
|
+
tag: url.searchParams.get("tag")?.split(",") ?? void 0,
|
|
15
|
+
locale: url.searchParams.get("locale") ?? void 0,
|
|
16
|
+
mode: url.searchParams.get("mode") === "vector" ? "vector" : "full"
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { createEndpoint as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as Awaitable } from "./types-
|
|
1
|
+
import { t as Awaitable } from "./types-Bt4vrwsT.js";
|
|
2
2
|
import { I18nConfig } from "./i18n/index.js";
|
|
3
|
-
import { i as LoaderConfig, o as LoaderOutput, u as Page } from "./path-
|
|
3
|
+
import { i as LoaderConfig, o as LoaderOutput, u as Page } from "./path-CDjb5iUO.js";
|
|
4
4
|
import { AdvancedIndex, AdvancedOptions, Dynamic, Index, SearchAPI, SimpleOptions } from "./search/server.js";
|
|
5
5
|
import { Language, Orama, TypedDocument } from "@orama/orama";
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as MakeOptional } from "../../types-
|
|
1
|
+
import { r as MakeOptional } from "../../types-Bt4vrwsT.js";
|
|
2
2
|
import { ResolvedShikiConfig } from "../config.js";
|
|
3
3
|
import { CoreHighlightOptions } from "./index.js";
|
|
4
4
|
import { DependencyList, ReactNode } from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as DistributiveOmit } from "../../types-
|
|
1
|
+
import { n as DistributiveOmit } from "../../types-Bt4vrwsT.js";
|
|
2
2
|
import { ResolvedShikiConfig } from "../config.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import { Components } from "hast-util-to-jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as DistributiveOmit } from "../types-
|
|
1
|
+
import { n as DistributiveOmit } from "../types-Bt4vrwsT.js";
|
|
2
2
|
import { ResolvedShikiConfig } from "./config.js";
|
|
3
3
|
import { CoreHighlightOptions } from "./core/index.js";
|
|
4
4
|
import { ReactNode } from "react";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RemarkGfmOptions, remarkGfm } from "./remark-gfm.js";
|
|
2
|
-
import { r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-
|
|
2
|
+
import { r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-C8MUuI2T.js";
|
|
3
3
|
import { transformerTab } from "./rehype-code.core.js";
|
|
4
4
|
import { RehypeCodeOptions, rehypeCode, rehypeCodeDefaultOptions } from "./rehype-code.js";
|
|
5
5
|
import { RemarkImageOptions, remarkImage } from "./remark-image.js";
|
|
6
|
-
import { StructureOptions, StructuredData,
|
|
6
|
+
import { StringifyOptions, StructureOptions, StructuredData, defaultStringifier, remarkStructure, remarkStructureDefaultOptions, structure } from "./remark-structure.js";
|
|
7
7
|
import { RemarkHeadingOptions, remarkHeading } from "./remark-heading.js";
|
|
8
8
|
import { RemarkAdmonitionOptions, remarkAdmonition } from "./remark-admonition.js";
|
|
9
9
|
import { RemarkDirectiveAdmonitionOptions, remarkDirectiveAdmonition } from "./remark-directive-admonition.js";
|
|
@@ -15,4 +15,4 @@ import { CodeBlockAttributes, CodeBlockTabsOptions, generateCodeBlockTabs, parse
|
|
|
15
15
|
import { RemarkMdxFilesOptions, remarkMdxFiles } from "./remark-mdx-files.js";
|
|
16
16
|
import { RemarkMdxMermaidOptions, remarkMdxMermaid } from "./remark-mdx-mermaid.js";
|
|
17
17
|
import { FeedbackBlockProps, RemarkFeedbackBlockOptions, remarkFeedbackBlock } from "./remark-feedback-block.js";
|
|
18
|
-
export { CodeBlockAttributes, CodeBlockIcon, CodeBlockTabsOptions, FeedbackBlockProps, RehypeCodeOptions, RehypeTocOptions, RemarkAdmonitionOptions, RemarkCodeTabOptions, RemarkDirectiveAdmonitionOptions, RemarkFeedbackBlockOptions, RemarkGfmOptions, RemarkHeadingOptions, RemarkImageOptions, type RemarkMdxFilesOptions, RemarkMdxMermaidOptions, RemarkNpmOptions, RemarkStepsOptions, StructureOptions, StructuredData,
|
|
18
|
+
export { CodeBlockAttributes, CodeBlockIcon, CodeBlockTabsOptions, FeedbackBlockProps, RehypeCodeOptions, RehypeTocOptions, RemarkAdmonitionOptions, RemarkCodeTabOptions, RemarkDirectiveAdmonitionOptions, RemarkFeedbackBlockOptions, RemarkGfmOptions, RemarkHeadingOptions, RemarkImageOptions, type RemarkMdxFilesOptions, RemarkMdxMermaidOptions, RemarkNpmOptions, RemarkStepsOptions, StringifyOptions, StructureOptions, StructuredData, defaultStringifier, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkCodeTab, remarkDirectiveAdmonition, remarkFeedbackBlock, remarkGfm, remarkHeading, remarkImage, remarkMdxFiles, remarkMdxMermaid, remarkNpm, remarkSteps, remarkStructure, remarkStructureDefaultOptions, structure, transformerIcon, transformerTab };
|
|
@@ -6,7 +6,7 @@ import { t as transformerIcon } from "../transformer-icon-BYedaeE8.js";
|
|
|
6
6
|
import { transformerTab } from "./rehype-code.core.js";
|
|
7
7
|
import { rehypeCode, rehypeCodeDefaultOptions } from "./rehype-code.js";
|
|
8
8
|
import { remarkImage } from "./remark-image.js";
|
|
9
|
-
import {
|
|
9
|
+
import { defaultStringifier, remarkStructure, remarkStructureDefaultOptions, structure } from "./remark-structure.js";
|
|
10
10
|
import { remarkAdmonition } from "./remark-admonition.js";
|
|
11
11
|
import { remarkDirectiveAdmonition } from "./remark-directive-admonition.js";
|
|
12
12
|
import { rehypeToc } from "./rehype-toc.js";
|
|
@@ -17,4 +17,4 @@ import { remarkMdxFiles } from "./remark-mdx-files.js";
|
|
|
17
17
|
import { remarkMdxMermaid } from "./remark-mdx-mermaid.js";
|
|
18
18
|
import { remarkFeedbackBlock } from "./remark-feedback-block.js";
|
|
19
19
|
|
|
20
|
-
export {
|
|
20
|
+
export { defaultStringifier, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkCodeTab, remarkDirectiveAdmonition, remarkFeedbackBlock, remarkGfm, remarkHeading, remarkImage, remarkMdxFiles, remarkMdxMermaid, remarkNpm, remarkSteps, remarkStructure, remarkStructureDefaultOptions, structure, transformerIcon, transformerTab };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as IconOptions, r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-
|
|
2
|
-
import { n as DistributiveOmit } from "../types-
|
|
1
|
+
import { n as IconOptions, r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-C8MUuI2T.js";
|
|
2
|
+
import { n as DistributiveOmit } from "../types-Bt4vrwsT.js";
|
|
3
3
|
import { ResolvedShikiConfig } from "../highlight/config.js";
|
|
4
4
|
import { ShikiTransformer } from "shiki";
|
|
5
5
|
import { Processor, Transformer } from "unified";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-
|
|
1
|
+
import { r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-C8MUuI2T.js";
|
|
2
2
|
import { RehypeCodeOptionsCommon, transformerTab } from "./rehype-code.core.js";
|
|
3
3
|
import * as unified from "unified";
|
|
4
4
|
import * as hast from "hast";
|
|
@@ -16,7 +16,7 @@ interface RemarkFeedbackBlockOptions {
|
|
|
16
16
|
/**
|
|
17
17
|
* determine how the node should be resolved into a feedback block.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* default: skip MDX elements, convert paragraph, list item, and image nodes.
|
|
20
20
|
*
|
|
21
21
|
* @returns
|
|
22
22
|
* - `true`: convert the node into a feedback block.
|
|
@@ -8,16 +8,24 @@ import { createHash } from "node:crypto";
|
|
|
8
8
|
*
|
|
9
9
|
* Note: the uniqueness is only guaranteed per MDX file/page.
|
|
10
10
|
*/
|
|
11
|
-
function remarkFeedbackBlock({ generateHash = ({ body }) => createHash("md5").update(body).digest("hex").substring(0, 16), tagName = "FeedbackBlock", resolve = (node) =>
|
|
11
|
+
function remarkFeedbackBlock({ generateHash = ({ body }) => createHash("md5").update(body).digest("hex").substring(0, 16), tagName = "FeedbackBlock", resolve = (node) => {
|
|
12
|
+
switch (node.type) {
|
|
13
|
+
case "mdxJsxFlowElement": return "skip";
|
|
14
|
+
case "paragraph":
|
|
15
|
+
case "image":
|
|
16
|
+
case "listItem": return true;
|
|
17
|
+
default: return false;
|
|
18
|
+
}
|
|
19
|
+
}, generateBody = true } = {}) {
|
|
12
20
|
return (tree) => {
|
|
13
21
|
const counts = /* @__PURE__ */ new Map();
|
|
14
22
|
visit(tree, (node, index, parent) => {
|
|
15
|
-
if (node.type === "root") return;
|
|
23
|
+
if (node.type === "root" || !parent || typeof index !== "number") return;
|
|
16
24
|
const resolved = resolve(node);
|
|
17
25
|
if (resolved === false) return;
|
|
18
26
|
if (resolved === "skip") return "skip";
|
|
19
27
|
const text = flattenNode(node).trim();
|
|
20
|
-
if (text.length === 0
|
|
28
|
+
if (text.length === 0) return;
|
|
21
29
|
let id = generateHash({ body: text });
|
|
22
30
|
const count = counts.get(id) ?? 0;
|
|
23
31
|
if (count > 0) id = `${id}-${count}`;
|
|
@@ -4,40 +4,80 @@ import { Nodes, Root } from "mdast";
|
|
|
4
4
|
import { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement, MdxJsxTextElement } from "mdast-util-mdx";
|
|
5
5
|
|
|
6
6
|
//#region src/mdx-plugins/remark-structure.d.ts
|
|
7
|
-
interface
|
|
7
|
+
interface StructuredDataHeading {
|
|
8
8
|
id: string;
|
|
9
9
|
content: string;
|
|
10
10
|
}
|
|
11
|
-
interface
|
|
11
|
+
interface StructuredDataContent {
|
|
12
12
|
heading: string | undefined;
|
|
13
13
|
content: string;
|
|
14
14
|
}
|
|
15
15
|
interface StructuredData {
|
|
16
|
-
headings:
|
|
16
|
+
headings: StructuredDataHeading[];
|
|
17
17
|
/**
|
|
18
18
|
* Refer to paragraphs, a heading may contain multiple contents as well
|
|
19
19
|
*/
|
|
20
|
-
contents:
|
|
20
|
+
contents: StructuredDataContent[];
|
|
21
|
+
}
|
|
22
|
+
type Stringifier = (this: Processor, node: Nodes, ctx: StringifierContext) => string;
|
|
23
|
+
interface StringifierContext {
|
|
24
|
+
addContent: (...content: StructuredDataContent[]) => void;
|
|
25
|
+
}
|
|
26
|
+
interface StringifyOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Filter the elements to be included in the output:
|
|
29
|
+
*
|
|
30
|
+
* - `true`: include element & its children.
|
|
31
|
+
* - `children-only`: exclude element but keep its children.
|
|
32
|
+
* - `false`: exclude element & its children.
|
|
33
|
+
*
|
|
34
|
+
* Default:
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* filterElement = (node) => {
|
|
38
|
+
* switch (node.type) {
|
|
39
|
+
* case 'mdxJsxFlowElement':
|
|
40
|
+
* case 'mdxJsxTextElement':
|
|
41
|
+
* switch (node.name) {
|
|
42
|
+
* case 'File':
|
|
43
|
+
* case 'TypeTable':
|
|
44
|
+
* case 'Callout':
|
|
45
|
+
* case 'Card':
|
|
46
|
+
* return true;
|
|
47
|
+
* }
|
|
48
|
+
* return 'children-only';
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* return true;
|
|
52
|
+
* },
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
filterElement?: (node: Nodes) => boolean | 'children-only';
|
|
56
|
+
/**
|
|
57
|
+
* Filter the attributes to stringify.
|
|
58
|
+
*/
|
|
59
|
+
filterMdxAttributes?: (node: MdxJsxFlowElement | MdxJsxTextElement, attribute: MdxJsxAttribute | MdxJsxExpressionAttribute) => boolean;
|
|
21
60
|
}
|
|
22
61
|
interface StructureOptions {
|
|
23
62
|
/**
|
|
24
|
-
* MDAST
|
|
63
|
+
* MDAST node types to be scanned as a content block.
|
|
25
64
|
*
|
|
26
|
-
* If a node's type is
|
|
65
|
+
* If a node's type is listed in this array, it will be converted into a single content block.
|
|
27
66
|
*
|
|
28
67
|
* @defaultValue ['heading', 'paragraph', 'blockquote', 'tableCell', 'mdxJsxFlowElement']
|
|
29
68
|
*/
|
|
30
69
|
types?: string[] | ((node: Nodes) => boolean);
|
|
31
70
|
/**
|
|
32
|
-
* stringify
|
|
71
|
+
* stringify text content from a MDAST node.
|
|
33
72
|
*/
|
|
34
|
-
stringify?:
|
|
73
|
+
stringify?: Stringifier | StringifyOptions;
|
|
35
74
|
/**
|
|
36
|
-
*
|
|
75
|
+
* Whether the MDX element should be treated as a single content block, only effective if `types` has `mdxJsxFlowElement`.
|
|
37
76
|
*
|
|
38
|
-
*
|
|
39
|
-
* - a function that determines if attribute should be indexed.
|
|
77
|
+
* Default: return `true` if the element is a leaf node, otherwise `false`.
|
|
40
78
|
*/
|
|
79
|
+
mdxTypes?: (node: MdxJsxFlowElement | MdxJsxTextElement) => boolean;
|
|
80
|
+
/** @deprecated use `stringify.filterMdxAttributes` instead */
|
|
41
81
|
allowedMdxAttributes?: string[] | ((node: MdxJsxFlowElement | MdxJsxTextElement, attribute: MdxJsxAttribute | MdxJsxExpressionAttribute) => boolean);
|
|
42
82
|
/**
|
|
43
83
|
* export as `structuredData` (if true) or specified variable name.
|
|
@@ -47,22 +87,28 @@ interface StructureOptions {
|
|
|
47
87
|
declare module 'mdast' {
|
|
48
88
|
interface Data {
|
|
49
89
|
/**
|
|
50
|
-
* [Fumadocs]
|
|
90
|
+
* [Fumadocs: remark-structure] The stringified form of node for generating search index.
|
|
51
91
|
*/
|
|
52
|
-
_string?: string
|
|
92
|
+
_string?: string | (() => string);
|
|
93
|
+
/**
|
|
94
|
+
* [Fumadocs: remark-structure] Items to add to the structured data.
|
|
95
|
+
*/
|
|
96
|
+
structuredData?: {
|
|
97
|
+
contents: StructuredDataContent[];
|
|
98
|
+
};
|
|
53
99
|
}
|
|
54
100
|
}
|
|
55
101
|
declare module 'vfile' {
|
|
56
102
|
interface DataMap {
|
|
57
103
|
/**
|
|
58
|
-
* [Fumadocs]
|
|
104
|
+
* [Fumadocs: remark-structure] output data.
|
|
59
105
|
*/
|
|
60
106
|
structuredData: StructuredData;
|
|
61
107
|
}
|
|
62
108
|
}
|
|
63
109
|
declare const remarkStructureDefaultOptions: {
|
|
64
110
|
types: string[];
|
|
65
|
-
|
|
111
|
+
mdxTypes(node: MdxJsxFlowElement | MdxJsxTextElement): boolean;
|
|
66
112
|
exportAs: false;
|
|
67
113
|
};
|
|
68
114
|
/**
|
|
@@ -72,7 +118,8 @@ declare const remarkStructureDefaultOptions: {
|
|
|
72
118
|
*/
|
|
73
119
|
declare function remarkStructure(this: Processor, {
|
|
74
120
|
types,
|
|
75
|
-
|
|
121
|
+
mdxTypes,
|
|
122
|
+
stringify: stringifyOptions,
|
|
76
123
|
allowedMdxAttributes,
|
|
77
124
|
exportAs
|
|
78
125
|
}?: StructureOptions): Transformer<Root, Root>;
|
|
@@ -80,8 +127,6 @@ declare function remarkStructure(this: Processor, {
|
|
|
80
127
|
* Extract data from markdown/mdx content
|
|
81
128
|
*/
|
|
82
129
|
declare function structure(content: string, remarkPlugins?: PluggableList, options?: StructureOptions): StructuredData;
|
|
83
|
-
declare function
|
|
84
|
-
filterMdxAttributes?: (node: MdxJsxFlowElement | MdxJsxTextElement, attribute: MdxJsxAttribute | MdxJsxExpressionAttribute) => boolean;
|
|
85
|
-
}): (this: Processor, node: Nodes) => string;
|
|
130
|
+
declare function defaultStringifier(config?: Options & StringifyOptions): Stringifier;
|
|
86
131
|
//#endregion
|
|
87
|
-
export { StructureOptions, StructuredData,
|
|
132
|
+
export { StringifyOptions, StructureOptions, StructuredData, defaultStringifier, remarkStructure, remarkStructureDefaultOptions, structure };
|