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
package/README.md
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { t as createContentHighlighter } from "./search-D6ChCLhY.js";
|
|
2
|
+
import { t as removeUndefined } from "./remove-undefined-Cfs4o_mM.js";
|
|
3
|
+
import { getByID, search } from "@orama/orama";
|
|
4
|
+
|
|
5
|
+
//#region src/search/orama/search/simple.ts
|
|
6
|
+
async function searchSimple(db, query, params = {}) {
|
|
7
|
+
const highlighter = createContentHighlighter(query);
|
|
8
|
+
return (await search(db, {
|
|
9
|
+
term: query,
|
|
10
|
+
tolerance: 1,
|
|
11
|
+
...params,
|
|
12
|
+
boost: {
|
|
13
|
+
title: 2,
|
|
14
|
+
..."boost" in params ? params.boost : void 0
|
|
15
|
+
}
|
|
16
|
+
})).hits.map((hit) => ({
|
|
17
|
+
type: "page",
|
|
18
|
+
content: hit.document.title,
|
|
19
|
+
breadcrumbs: hit.document.breadcrumbs,
|
|
20
|
+
contentWithHighlights: highlighter.highlight(hit.document.title),
|
|
21
|
+
id: hit.document.url,
|
|
22
|
+
url: hit.document.url
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/search/orama/search/advanced.ts
|
|
28
|
+
async function searchAdvanced(db, query, tag = [], { mode = "fulltext", ...override } = {}) {
|
|
29
|
+
if (typeof tag === "string") tag = [tag];
|
|
30
|
+
let params = {
|
|
31
|
+
...override,
|
|
32
|
+
mode,
|
|
33
|
+
where: removeUndefined({
|
|
34
|
+
tags: tag.length > 0 ? { containsAll: tag } : void 0,
|
|
35
|
+
...override.where
|
|
36
|
+
}),
|
|
37
|
+
groupBy: {
|
|
38
|
+
properties: ["page_id"],
|
|
39
|
+
maxResult: 8,
|
|
40
|
+
...override.groupBy
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
if (query.length > 0) params = {
|
|
44
|
+
...params,
|
|
45
|
+
term: query,
|
|
46
|
+
properties: mode === "fulltext" ? ["content"] : ["content", "embeddings"]
|
|
47
|
+
};
|
|
48
|
+
const highlighter = createContentHighlighter(query);
|
|
49
|
+
const result = await search(db, params);
|
|
50
|
+
const list = [];
|
|
51
|
+
for (const item of result.groups ?? []) {
|
|
52
|
+
const pageId = item.values[0];
|
|
53
|
+
const page = getByID(db, pageId);
|
|
54
|
+
if (!page) continue;
|
|
55
|
+
list.push({
|
|
56
|
+
id: pageId,
|
|
57
|
+
type: "page",
|
|
58
|
+
content: page.content,
|
|
59
|
+
breadcrumbs: page.breadcrumbs,
|
|
60
|
+
contentWithHighlights: highlighter.highlight(page.content),
|
|
61
|
+
url: page.url
|
|
62
|
+
});
|
|
63
|
+
for (const hit of item.result) {
|
|
64
|
+
if (hit.document.type === "page") continue;
|
|
65
|
+
list.push({
|
|
66
|
+
id: hit.document.id.toString(),
|
|
67
|
+
content: hit.document.content,
|
|
68
|
+
breadcrumbs: hit.document.breadcrumbs,
|
|
69
|
+
contentWithHighlights: highlighter.highlight(hit.document.content),
|
|
70
|
+
type: hit.document.type,
|
|
71
|
+
url: hit.document.url
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return list;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
export { searchSimple as n, searchAdvanced as t };
|
|
80
|
+
//# sourceMappingURL=advanced-BRT5Ij43.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced-BRT5Ij43.js","names":["list: SortedResult[]"],"sources":["../src/search/orama/search/simple.ts","../src/search/orama/search/advanced.ts"],"sourcesContent":["import { type Orama, search, type SearchParams } from '@orama/orama';\nimport { type SimpleDocument, type simpleSchema } from '@/search/orama/create-db';\nimport { createContentHighlighter, type SortedResult } from '@/search';\n\nexport async function searchSimple(\n db: Orama<typeof simpleSchema>,\n query: string,\n params: Partial<SearchParams<Orama<typeof simpleSchema>, SimpleDocument>> = {},\n): Promise<SortedResult[]> {\n const highlighter = createContentHighlighter(query);\n const result = await search(db, {\n term: query,\n tolerance: 1,\n ...params,\n boost: {\n title: 2,\n ...('boost' in params ? params.boost : undefined),\n },\n });\n\n return result.hits.map<SortedResult>((hit) => ({\n type: 'page',\n content: hit.document.title,\n breadcrumbs: hit.document.breadcrumbs,\n contentWithHighlights: highlighter.highlight(hit.document.title),\n id: hit.document.url,\n url: hit.document.url,\n }));\n}\n","import { getByID, type Orama, search, type SearchParams } from '@orama/orama';\nimport { type AdvancedDocument, type advancedSchema } from '@/search/orama/create-db';\nimport { removeUndefined } from '@/utils/remove-undefined';\nimport { createContentHighlighter, type SortedResult } from '@/search';\n\nexport async function searchAdvanced(\n db: Orama<typeof advancedSchema>,\n query: string,\n tag: string | string[] = [],\n {\n mode = 'fulltext',\n ...override\n }: Partial<SearchParams<Orama<typeof advancedSchema>, AdvancedDocument>> = {},\n): Promise<SortedResult[]> {\n if (typeof tag === 'string') tag = [tag];\n\n let params = {\n ...override,\n mode,\n where: removeUndefined({\n tags:\n tag.length > 0\n ? {\n containsAll: tag,\n }\n : undefined,\n ...override.where,\n }),\n groupBy: {\n properties: ['page_id'],\n maxResult: 8,\n ...override.groupBy,\n },\n } as SearchParams<typeof db, AdvancedDocument>;\n\n if (query.length > 0) {\n params = {\n ...params,\n term: query,\n properties: mode === 'fulltext' ? ['content'] : ['content', 'embeddings'],\n } as SearchParams<typeof db, AdvancedDocument>;\n }\n\n const highlighter = createContentHighlighter(query);\n const result = await search(db, params);\n const list: SortedResult[] = [];\n for (const item of result.groups ?? []) {\n const pageId = item.values[0] as string;\n\n const page = getByID(db, pageId);\n if (!page) continue;\n\n list.push({\n id: pageId,\n type: 'page',\n content: page.content,\n breadcrumbs: page.breadcrumbs,\n contentWithHighlights: highlighter.highlight(page.content),\n url: page.url,\n });\n\n for (const hit of item.result) {\n if (hit.document.type === 'page') continue;\n\n list.push({\n id: hit.document.id.toString(),\n content: hit.document.content,\n breadcrumbs: hit.document.breadcrumbs,\n contentWithHighlights: highlighter.highlight(hit.document.content),\n type: hit.document.type as SortedResult['type'],\n url: hit.document.url,\n });\n }\n }\n return list;\n}\n"],"mappings":";;;;;AAIA,eAAsB,aACpB,IACA,OACA,SAA4E,EAAE,EACrD;CACzB,MAAM,cAAc,yBAAyB,MAAM;AAWnD,SAVe,MAAM,OAAO,IAAI;EAC9B,MAAM;EACN,WAAW;EACX,GAAG;EACH,OAAO;GACL,OAAO;GACP,GAAI,WAAW,SAAS,OAAO,QAAQ;GACxC;EACF,CAAC,EAEY,KAAK,KAAmB,SAAS;EAC7C,MAAM;EACN,SAAS,IAAI,SAAS;EACtB,aAAa,IAAI,SAAS;EAC1B,uBAAuB,YAAY,UAAU,IAAI,SAAS,MAAM;EAChE,IAAI,IAAI,SAAS;EACjB,KAAK,IAAI,SAAS;EACnB,EAAE;;;;;ACtBL,eAAsB,eACpB,IACA,OACA,MAAyB,EAAE,EAC3B,EACE,OAAO,YACP,GAAG,aACsE,EAAE,EACpD;AACzB,KAAI,OAAO,QAAQ,SAAU,OAAM,CAAC,IAAI;CAExC,IAAI,SAAS;EACX,GAAG;EACH;EACA,OAAO,gBAAgB;GACrB,MACE,IAAI,SAAS,IACT,EACE,aAAa,KACd,GACD;GACN,GAAG,SAAS;GACb,CAAC;EACF,SAAS;GACP,YAAY,CAAC,UAAU;GACvB,WAAW;GACX,GAAG,SAAS;GACb;EACF;AAED,KAAI,MAAM,SAAS,EACjB,UAAS;EACP,GAAG;EACH,MAAM;EACN,YAAY,SAAS,aAAa,CAAC,UAAU,GAAG,CAAC,WAAW,aAAa;EAC1E;CAGH,MAAM,cAAc,yBAAyB,MAAM;CACnD,MAAM,SAAS,MAAM,OAAO,IAAI,OAAO;CACvC,MAAMA,OAAuB,EAAE;AAC/B,MAAK,MAAM,QAAQ,OAAO,UAAU,EAAE,EAAE;EACtC,MAAM,SAAS,KAAK,OAAO;EAE3B,MAAM,OAAO,QAAQ,IAAI,OAAO;AAChC,MAAI,CAAC,KAAM;AAEX,OAAK,KAAK;GACR,IAAI;GACJ,MAAM;GACN,SAAS,KAAK;GACd,aAAa,KAAK;GAClB,uBAAuB,YAAY,UAAU,KAAK,QAAQ;GAC1D,KAAK,KAAK;GACX,CAAC;AAEF,OAAK,MAAM,OAAO,KAAK,QAAQ;AAC7B,OAAI,IAAI,SAAS,SAAS,OAAQ;AAElC,QAAK,KAAK;IACR,IAAI,IAAI,SAAS,GAAG,UAAU;IAC9B,SAAS,IAAI,SAAS;IACtB,aAAa,IAAI,SAAS;IAC1B,uBAAuB,YAAY,UAAU,IAAI,SAAS,QAAQ;IAClE,MAAM,IAAI,SAAS;IACnB,KAAK,IAAI,SAAS;IACnB,CAAC;;;AAGN,QAAO"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { n as StructuredData } from "./remark-structure-RZD2gGKp.js";
|
|
2
|
+
import { Algoliasearch } from "algoliasearch";
|
|
3
|
+
|
|
4
|
+
//#region src/search/algolia.d.ts
|
|
5
|
+
interface DocumentRecord {
|
|
6
|
+
/**
|
|
7
|
+
* The ID of document, must be unique
|
|
8
|
+
*/
|
|
9
|
+
_id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
breadcrumbs?: string[];
|
|
13
|
+
/**
|
|
14
|
+
* URL to the page
|
|
15
|
+
*/
|
|
16
|
+
url: string;
|
|
17
|
+
structured: StructuredData;
|
|
18
|
+
/**
|
|
19
|
+
* Tag to filter results
|
|
20
|
+
*/
|
|
21
|
+
tag?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Data to be added to each section index
|
|
24
|
+
*/
|
|
25
|
+
extra_data?: object;
|
|
26
|
+
}
|
|
27
|
+
interface SyncOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Index Name for documents.
|
|
30
|
+
*/
|
|
31
|
+
indexName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Search indexes
|
|
34
|
+
*/
|
|
35
|
+
documents: DocumentRecord[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Update index settings and replace all objects
|
|
39
|
+
*
|
|
40
|
+
* @param client - Algolia Admin Client
|
|
41
|
+
* @param options - Index Options
|
|
42
|
+
*/
|
|
43
|
+
declare function sync(client: Algoliasearch, options: SyncOptions): Promise<void>;
|
|
44
|
+
declare function setIndexSettings(client: Algoliasearch, indexName: string): Promise<void>;
|
|
45
|
+
declare function updateDocuments(client: Algoliasearch, indexName: string, documents: DocumentRecord[]): Promise<void>;
|
|
46
|
+
interface BaseIndex {
|
|
47
|
+
objectID: string;
|
|
48
|
+
title: string;
|
|
49
|
+
url: string;
|
|
50
|
+
tag?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The id of page, used for distinct
|
|
53
|
+
*/
|
|
54
|
+
page_id: string;
|
|
55
|
+
/**
|
|
56
|
+
* Heading content
|
|
57
|
+
*/
|
|
58
|
+
section?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Heading (anchor) id
|
|
61
|
+
*/
|
|
62
|
+
section_id?: string;
|
|
63
|
+
breadcrumbs?: string[];
|
|
64
|
+
content: string;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { sync as a, setIndexSettings as i, DocumentRecord as n, updateDocuments as o, SyncOptions as r, BaseIndex as t };
|
|
68
|
+
//# sourceMappingURL=algolia-CBBN8R6-.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algolia-CBBN8R6-.d.ts","names":[],"sources":["../src/search/algolia.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,cAAA;;AAAjB;AA2BA;EAkBsB,GAAA,EAAA,MAAI;EAAS,KAAA,EAAA,MAAA;EAAwB,WAAA,CAAA,EAAA,MAAA;EAAc,WAAA,CAAA,EAAA,MAAA,EAAA;EAAO;AAMhF;AAyDA;EACU,GAAA,EAAA,MAAA;EAEG,UAAA,EAjGC,cAiGD;EACV;;AASH;;;;;;;UA9FiB,WAAA;;;;;;;;aASJ;;;;;;;;iBASS,IAAA,SAAa,wBAAwB,cAAc;iBAMnD,gBAAA,SAAyB,mCAAmC;iBAyD5D,eAAA,SACZ,6CAEG,mBACV;UASc,SAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { t as createContentHighlighter } from "./search-D6ChCLhY.js";
|
|
2
|
+
|
|
3
|
+
//#region src/search/client/algolia.ts
|
|
4
|
+
function groupResults(hits) {
|
|
5
|
+
const grouped = [];
|
|
6
|
+
const scannedUrls = /* @__PURE__ */ new Set();
|
|
7
|
+
for (const hit of hits) {
|
|
8
|
+
if (!scannedUrls.has(hit.url)) {
|
|
9
|
+
scannedUrls.add(hit.url);
|
|
10
|
+
grouped.push({
|
|
11
|
+
id: hit.url,
|
|
12
|
+
type: "page",
|
|
13
|
+
breadcrumbs: hit.breadcrumbs,
|
|
14
|
+
url: hit.url,
|
|
15
|
+
content: hit.title
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
grouped.push({
|
|
19
|
+
id: hit.objectID,
|
|
20
|
+
type: hit.content === hit.section ? "heading" : "text",
|
|
21
|
+
url: hit.section_id ? `${hit.url}#${hit.section_id}` : hit.url,
|
|
22
|
+
content: hit.content
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return grouped;
|
|
26
|
+
}
|
|
27
|
+
async function searchDocs(query, { indexName, onSearch, client, locale, tag }) {
|
|
28
|
+
if (query.trim().length === 0) return [];
|
|
29
|
+
const result = onSearch ? await onSearch(query, tag, locale) : await client.searchForHits({ requests: [{
|
|
30
|
+
type: "default",
|
|
31
|
+
indexName,
|
|
32
|
+
query,
|
|
33
|
+
distinct: 5,
|
|
34
|
+
hitsPerPage: 10,
|
|
35
|
+
filters: tag ? `tag:${tag}` : void 0
|
|
36
|
+
}] });
|
|
37
|
+
const highlighter = createContentHighlighter(query);
|
|
38
|
+
return groupResults(result.results[0].hits).flatMap((hit) => {
|
|
39
|
+
if (hit.type === "page") return {
|
|
40
|
+
...hit,
|
|
41
|
+
contentWithHighlights: hit.contentWithHighlights ?? highlighter.highlight(hit.content)
|
|
42
|
+
};
|
|
43
|
+
return [];
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { searchDocs };
|
|
49
|
+
//# sourceMappingURL=algolia-CQPXCnjV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algolia-CQPXCnjV.js","names":["grouped: SortedResult[]"],"sources":["../src/search/client/algolia.ts"],"sourcesContent":["import type { BaseIndex } from '@/search/algolia';\nimport type { Hit, LiteClient, SearchResponse } from 'algoliasearch/lite';\nimport { createContentHighlighter, type SortedResult } from '@/search';\n\nexport interface AlgoliaOptions {\n indexName: string;\n client: LiteClient;\n\n /**\n * Filter results with specific tag.\n */\n tag?: string;\n\n locale?: string;\n\n onSearch?: (\n query: string,\n tag?: string,\n locale?: string,\n ) => Promise<{\n results: SearchResponse<BaseIndex>[];\n }>;\n}\n\nexport function groupResults(hits: Hit<BaseIndex>[]): SortedResult[] {\n const grouped: SortedResult[] = [];\n const scannedUrls = new Set<string>();\n\n for (const hit of hits) {\n if (!scannedUrls.has(hit.url)) {\n scannedUrls.add(hit.url);\n\n grouped.push({\n id: hit.url,\n type: 'page',\n breadcrumbs: hit.breadcrumbs,\n url: hit.url,\n content: hit.title,\n });\n }\n\n grouped.push({\n id: hit.objectID,\n type: hit.content === hit.section ? 'heading' : 'text',\n url: hit.section_id ? `${hit.url}#${hit.section_id}` : hit.url,\n content: hit.content,\n });\n }\n\n return grouped;\n}\n\nexport async function searchDocs(\n query: string,\n { indexName, onSearch, client, locale, tag }: AlgoliaOptions,\n): Promise<SortedResult[]> {\n if (query.trim().length === 0) return [];\n\n const result = onSearch\n ? await onSearch(query, tag, locale)\n : await client.searchForHits<BaseIndex>({\n requests: [\n {\n type: 'default',\n indexName,\n query,\n distinct: 5,\n hitsPerPage: 10,\n filters: tag ? `tag:${tag}` : undefined,\n },\n ],\n });\n\n const highlighter = createContentHighlighter(query);\n return groupResults(result.results[0].hits).flatMap((hit) => {\n if (hit.type === 'page') {\n return {\n ...hit,\n contentWithHighlights: hit.contentWithHighlights ?? highlighter.highlight(hit.content),\n };\n }\n\n return [];\n });\n}\n"],"mappings":";;;AAwBA,SAAgB,aAAa,MAAwC;CACnE,MAAMA,UAA0B,EAAE;CAClC,MAAM,8BAAc,IAAI,KAAa;AAErC,MAAK,MAAM,OAAO,MAAM;AACtB,MAAI,CAAC,YAAY,IAAI,IAAI,IAAI,EAAE;AAC7B,eAAY,IAAI,IAAI,IAAI;AAExB,WAAQ,KAAK;IACX,IAAI,IAAI;IACR,MAAM;IACN,aAAa,IAAI;IACjB,KAAK,IAAI;IACT,SAAS,IAAI;IACd,CAAC;;AAGJ,UAAQ,KAAK;GACX,IAAI,IAAI;GACR,MAAM,IAAI,YAAY,IAAI,UAAU,YAAY;GAChD,KAAK,IAAI,aAAa,GAAG,IAAI,IAAI,GAAG,IAAI,eAAe,IAAI;GAC3D,SAAS,IAAI;GACd,CAAC;;AAGJ,QAAO;;AAGT,eAAsB,WACpB,OACA,EAAE,WAAW,UAAU,QAAQ,QAAQ,OACd;AACzB,KAAI,MAAM,MAAM,CAAC,WAAW,EAAG,QAAO,EAAE;CAExC,MAAM,SAAS,WACX,MAAM,SAAS,OAAO,KAAK,OAAO,GAClC,MAAM,OAAO,cAAyB,EACpC,UAAU,CACR;EACE,MAAM;EACN;EACA;EACA,UAAU;EACV,aAAa;EACb,SAAS,MAAM,OAAO,QAAQ;EAC/B,CACF,EACF,CAAC;CAEN,MAAM,cAAc,yBAAyB,MAAM;AACnD,QAAO,aAAa,OAAO,QAAQ,GAAG,KAAK,CAAC,SAAS,QAAQ;AAC3D,MAAI,IAAI,SAAS,OACf,QAAO;GACL,GAAG;GACH,uBAAuB,IAAI,yBAAyB,YAAY,UAAU,IAAI,QAAQ;GACvF;AAGH,SAAO,EAAE;GACT"}
|
package/dist/breadcrumb.d.ts
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as Root, r as Node } from "./definitions-DuxDer_c.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
3
|
|
|
4
|
+
//#region src/breadcrumb.d.ts
|
|
4
5
|
interface BreadcrumbItem {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
name: ReactNode;
|
|
7
|
+
url?: string;
|
|
7
8
|
}
|
|
8
9
|
interface BreadcrumbOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Include the root folders in the breadcrumb items array.
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue false
|
|
14
|
+
*/
|
|
15
|
+
includeRoot?: boolean | {
|
|
9
16
|
/**
|
|
10
|
-
*
|
|
11
|
-
* Specify the url by passing an object instead
|
|
12
|
-
*
|
|
13
|
-
* @defaultValue false
|
|
17
|
+
* Specify the url of root
|
|
14
18
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
includeSeparator?: boolean;
|
|
19
|
+
url: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Include the page itself in the breadcrumb items array
|
|
23
|
+
*
|
|
24
|
+
* @defaultValue false
|
|
25
|
+
*/
|
|
26
|
+
includePage?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Count separator as an item
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue false
|
|
31
|
+
*/
|
|
32
|
+
includeSeparator?: boolean;
|
|
30
33
|
}
|
|
31
34
|
declare function useBreadcrumb(url: string, tree: Root, options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
32
35
|
declare function getBreadcrumbItems(url: string, tree: Root, options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
@@ -37,8 +40,9 @@ declare function getBreadcrumbItemsFromPath(tree: Root, path: Node[], options: B
|
|
|
37
40
|
* - When the page doesn't exist, return null
|
|
38
41
|
*
|
|
39
42
|
* @returns The path to the target node from root
|
|
40
|
-
* @internal
|
|
43
|
+
* @internal Don't use this on your own
|
|
41
44
|
*/
|
|
42
45
|
declare function searchPath(nodes: Node[], url: string): Node[] | null;
|
|
43
|
-
|
|
44
|
-
export {
|
|
46
|
+
//#endregion
|
|
47
|
+
export { BreadcrumbItem, BreadcrumbOptions, getBreadcrumbItems, getBreadcrumbItemsFromPath, searchPath, useBreadcrumb };
|
|
48
|
+
//# sourceMappingURL=breadcrumb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumb.d.ts","names":[],"sources":["../src/breadcrumb.tsx"],"sourcesContent":[],"mappings":";;;;UAKiB,cAAA;QACT;EADS,GAAA,CAAA,EAAA,MAAA;AAKjB;AA8BgB,UA9BC,iBAAA,CA8BY;EAErB;;;;AAMR;EAEQ,WAAA,CAAA,EAAA,OAAA,GAAA;IACG;;;IAKK,GAAA,EAAA,MAAA;EACR,CAAA;EACA;;;;AAyDR;;;;;;;;;iBA3EgB,aAAA,oBAER,gBACI,oBACT;iBAIa,kBAAA,oBAER,gBACG,oBACR;iBAIa,0BAAA,OACR,YACA,iBACG,oBACR;;;;;;;;;iBAuDa,UAAA,QAAkB,sBAA+B"}
|
package/dist/breadcrumb.js
CHANGED
|
@@ -1,87 +1,64 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
|
|
3
|
-
// src/breadcrumb.tsx
|
|
1
|
+
import { t as normalizeUrl } from "./normalize-url-DP9-1I-S.js";
|
|
2
|
+
import { r as findPath } from "./utils-DUvi2WkD.js";
|
|
4
3
|
import { useMemo } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/breadcrumb.tsx
|
|
5
6
|
function useBreadcrumb(url, tree, options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
return useMemo(() => getBreadcrumbItems(url, tree, options), [
|
|
8
|
+
tree,
|
|
9
|
+
url,
|
|
10
|
+
options
|
|
11
|
+
]);
|
|
10
12
|
}
|
|
11
13
|
function getBreadcrumbItems(url, tree, options = {}) {
|
|
12
|
-
|
|
13
|
-
tree,
|
|
14
|
-
searchPath(tree.children, url) ?? [],
|
|
15
|
-
options
|
|
16
|
-
);
|
|
14
|
+
return getBreadcrumbItemsFromPath(tree, searchPath(tree.children, url) ?? [], options);
|
|
17
15
|
}
|
|
18
16
|
function getBreadcrumbItemsFromPath(tree, path, options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return items;
|
|
17
|
+
const { includePage = false, includeSeparator = false, includeRoot = false } = options;
|
|
18
|
+
let items = [];
|
|
19
|
+
for (let i = 0; i < path.length; i++) {
|
|
20
|
+
const item = path[i];
|
|
21
|
+
switch (item.type) {
|
|
22
|
+
case "page":
|
|
23
|
+
if (includePage) items.push({
|
|
24
|
+
name: item.name,
|
|
25
|
+
url: item.url
|
|
26
|
+
});
|
|
27
|
+
break;
|
|
28
|
+
case "folder":
|
|
29
|
+
if (item.root && !includeRoot) {
|
|
30
|
+
items = [];
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
if (i === path.length - 1 || item.index !== path[i + 1]) items.push({
|
|
34
|
+
name: item.name,
|
|
35
|
+
url: item.index?.url
|
|
36
|
+
});
|
|
37
|
+
break;
|
|
38
|
+
case "separator":
|
|
39
|
+
if (item.name && includeSeparator) items.push({ name: item.name });
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (includeRoot) items.unshift({
|
|
44
|
+
name: tree.name,
|
|
45
|
+
url: typeof includeRoot === "object" ? includeRoot.url : void 0
|
|
46
|
+
});
|
|
47
|
+
return items;
|
|
53
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Search the path of a node in the tree by a specified url
|
|
51
|
+
*
|
|
52
|
+
* - When the page doesn't exist, return null
|
|
53
|
+
*
|
|
54
|
+
* @returns The path to the target node from root
|
|
55
|
+
* @internal Don't use this on your own
|
|
56
|
+
*/
|
|
54
57
|
function searchPath(nodes, url) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
for (const node of nodes) {
|
|
58
|
-
if (node.type === "separator") separator = node;
|
|
59
|
-
if (node.type === "folder") {
|
|
60
|
-
if (node.index?.url === url) {
|
|
61
|
-
const items2 = [];
|
|
62
|
-
if (separator) items2.push(separator);
|
|
63
|
-
items2.push(node, node.index);
|
|
64
|
-
return items2;
|
|
65
|
-
}
|
|
66
|
-
const items = searchPath(node.children, url);
|
|
67
|
-
if (items) {
|
|
68
|
-
items.unshift(node);
|
|
69
|
-
if (separator) items.unshift(separator);
|
|
70
|
-
return items;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (node.type === "page" && node.url === url) {
|
|
74
|
-
const items = [];
|
|
75
|
-
if (separator) items.push(separator);
|
|
76
|
-
items.push(node);
|
|
77
|
-
return items;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return null;
|
|
58
|
+
const normalizedUrl = normalizeUrl(url);
|
|
59
|
+
return findPath(nodes, (node) => node.type === "page" && node.url === normalizedUrl);
|
|
81
60
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
useBreadcrumb
|
|
87
|
-
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { getBreadcrumbItems, getBreadcrumbItemsFromPath, searchPath, useBreadcrumb };
|
|
64
|
+
//# sourceMappingURL=breadcrumb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumb.js","names":["items: BreadcrumbItem[]"],"sources":["../src/breadcrumb.tsx"],"sourcesContent":["import { type ReactNode, useMemo } from 'react';\nimport type * as PageTree from '@/page-tree/definitions';\nimport { normalizeUrl } from '@/utils/normalize-url';\nimport { findPath } from '@/page-tree/utils';\n\nexport interface BreadcrumbItem {\n name: ReactNode;\n url?: string;\n}\n\nexport interface BreadcrumbOptions {\n /**\n * Include the root folders in the breadcrumb items array.\n *\n * @defaultValue false\n */\n includeRoot?:\n | boolean\n | {\n /**\n * Specify the url of root\n */\n url: string;\n };\n\n /**\n * Include the page itself in the breadcrumb items array\n *\n * @defaultValue false\n */\n includePage?: boolean;\n\n /**\n * Count separator as an item\n *\n * @defaultValue false\n */\n includeSeparator?: boolean;\n}\n\nexport function useBreadcrumb(\n url: string,\n tree: PageTree.Root,\n options?: BreadcrumbOptions,\n): BreadcrumbItem[] {\n return useMemo(() => getBreadcrumbItems(url, tree, options), [tree, url, options]);\n}\n\nexport function getBreadcrumbItems(\n url: string,\n tree: PageTree.Root,\n options: BreadcrumbOptions = {},\n): BreadcrumbItem[] {\n return getBreadcrumbItemsFromPath(tree, searchPath(tree.children, url) ?? [], options);\n}\n\nexport function getBreadcrumbItemsFromPath(\n tree: PageTree.Root,\n path: PageTree.Node[],\n options: BreadcrumbOptions,\n): BreadcrumbItem[] {\n const { includePage = false, includeSeparator = false, includeRoot = false } = options;\n let items: BreadcrumbItem[] = [];\n for (let i = 0; i < path.length; i++) {\n const item = path[i];\n\n switch (item.type) {\n case 'page':\n if (includePage)\n items.push({\n name: item.name,\n url: item.url,\n });\n break;\n case 'folder':\n if (item.root && !includeRoot) {\n items = [];\n break;\n }\n\n // only show the index node of folders if possible\n if (i === path.length - 1 || item.index !== path[i + 1]) {\n items.push({\n name: item.name,\n url: item.index?.url,\n });\n }\n break;\n case 'separator':\n if (item.name && includeSeparator)\n items.push({\n name: item.name,\n });\n break;\n }\n }\n\n if (includeRoot) {\n items.unshift({\n name: tree.name,\n url: typeof includeRoot === 'object' ? includeRoot.url : undefined,\n });\n }\n\n return items;\n}\n\n/**\n * Search the path of a node in the tree by a specified url\n *\n * - When the page doesn't exist, return null\n *\n * @returns The path to the target node from root\n * @internal Don't use this on your own\n */\nexport function searchPath(nodes: PageTree.Node[], url: string): PageTree.Node[] | null {\n const normalizedUrl = normalizeUrl(url);\n\n return findPath(nodes, (node) => node.type === 'page' && node.url === normalizedUrl);\n}\n"],"mappings":";;;;;AAwCA,SAAgB,cACd,KACA,MACA,SACkB;AAClB,QAAO,cAAc,mBAAmB,KAAK,MAAM,QAAQ,EAAE;EAAC;EAAM;EAAK;EAAQ,CAAC;;AAGpF,SAAgB,mBACd,KACA,MACA,UAA6B,EAAE,EACb;AAClB,QAAO,2BAA2B,MAAM,WAAW,KAAK,UAAU,IAAI,IAAI,EAAE,EAAE,QAAQ;;AAGxF,SAAgB,2BACd,MACA,MACA,SACkB;CAClB,MAAM,EAAE,cAAc,OAAO,mBAAmB,OAAO,cAAc,UAAU;CAC/E,IAAIA,QAA0B,EAAE;AAChC,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,OAAO,KAAK;AAElB,UAAQ,KAAK,MAAb;GACE,KAAK;AACH,QAAI,YACF,OAAM,KAAK;KACT,MAAM,KAAK;KACX,KAAK,KAAK;KACX,CAAC;AACJ;GACF,KAAK;AACH,QAAI,KAAK,QAAQ,CAAC,aAAa;AAC7B,aAAQ,EAAE;AACV;;AAIF,QAAI,MAAM,KAAK,SAAS,KAAK,KAAK,UAAU,KAAK,IAAI,GACnD,OAAM,KAAK;KACT,MAAM,KAAK;KACX,KAAK,KAAK,OAAO;KAClB,CAAC;AAEJ;GACF,KAAK;AACH,QAAI,KAAK,QAAQ,iBACf,OAAM,KAAK,EACT,MAAM,KAAK,MACZ,CAAC;AACJ;;;AAIN,KAAI,YACF,OAAM,QAAQ;EACZ,MAAM,KAAK;EACX,KAAK,OAAO,gBAAgB,WAAW,YAAY,MAAM;EAC1D,CAAC;AAGJ,QAAO;;;;;;;;;;AAWT,SAAgB,WAAW,OAAwB,KAAqC;CACtF,MAAM,gBAAgB,aAAa,IAAI;AAEvC,QAAO,SAAS,QAAQ,SAAS,KAAK,SAAS,UAAU,KAAK,QAAQ,cAAc"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __exportAll = (all, symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) {
|
|
12
|
+
__defProp(target, name, {
|
|
13
|
+
get: all[name],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (symbols) {
|
|
18
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
+
key = keys[i];
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
27
|
+
__defProp(to, key, {
|
|
28
|
+
get: ((k) => from[k]).bind(null, key),
|
|
29
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
37
|
+
value: mod,
|
|
38
|
+
enumerable: true
|
|
39
|
+
}) : target, mod));
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { __exportAll as n, __toESM as r, __commonJSMin as t };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BlockContent, Text } from "mdast";
|
|
2
|
+
import { MdxJsxAttribute, MdxJsxFlowElement } from "mdast-util-mdx-jsx";
|
|
3
|
+
|
|
4
|
+
//#region src/mdx-plugins/codeblock-utils.d.ts
|
|
5
|
+
interface CodeBlockTabsOptions {
|
|
6
|
+
attributes?: MdxJsxAttribute[];
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
persist?: {
|
|
9
|
+
id: string;
|
|
10
|
+
} | false;
|
|
11
|
+
triggers: {
|
|
12
|
+
value: string;
|
|
13
|
+
children: (BlockContent | Text)[];
|
|
14
|
+
}[];
|
|
15
|
+
tabs: {
|
|
16
|
+
value: string;
|
|
17
|
+
children: BlockContent[];
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
declare function generateCodeBlockTabs({
|
|
21
|
+
persist,
|
|
22
|
+
defaultValue,
|
|
23
|
+
triggers,
|
|
24
|
+
tabs,
|
|
25
|
+
...options
|
|
26
|
+
}: CodeBlockTabsOptions): MdxJsxFlowElement;
|
|
27
|
+
interface CodeBlockAttributes<Name extends string = string> {
|
|
28
|
+
attributes: Partial<Record<Name, string | null>>;
|
|
29
|
+
rest: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parse Fumadocs-style code block attributes from meta string, like `title="hello world"`
|
|
33
|
+
*/
|
|
34
|
+
declare function parseCodeBlockAttributes<Name extends string = string>(meta: string, allowedNames?: Name[]): CodeBlockAttributes<Name>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { parseCodeBlockAttributes as i, CodeBlockTabsOptions as n, generateCodeBlockTabs as r, CodeBlockAttributes as t };
|
|
37
|
+
//# sourceMappingURL=codeblock-utils-lld8UiQo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeblock-utils-lld8UiQo.d.ts","names":[],"sources":["../src/mdx-plugins/codeblock-utils.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,oBAAA;eACF;EADE,YAAA,CAAA,EAAA,MAAA;EACF,OAAA,CAAA,EAAA;IASA,EAAA,EAAA,MAAA;EAAe,CAAA,GAAA,KAAA;EAIhB,QAAA,EAAA;IAAY,KAAA,EAAA,MAAA;IAIV,QAAA,EAAA,CARD,YAQsB,GARP,IAQO,CAAA,EAAA;EACnC,CAAA,EAAA;EACA,IAAA,EAAA;IACA,KAAA,EAAA,MAAA;IACA,QAAA,EARY,YAQZ,EAAA;EAEC,CAAA,EAAA;;AAAwC,iBAN3B,qBAAA,CAM2B;EAAA,OAAA;EAAA,YAAA;EAAA,QAAA;EAAA,IAAA;EAAA,GAAA;AAAA,CAAA,EAAxC,oBAAwC,CAAA,EAAjB,iBAAiB;AA6D1B,UAAA,mBAAmB,CAAA,aAAA,MAAA,GAAA,MAAA,CAAA,CAAA;EACP,UAAA,EAAf,OAAe,CAAP,MAAO,CAAA,IAAA,EAAA,MAAA,GAAA,IAAA,CAAA,CAAA;EAAP,IAAA,EAAA,MAAA;;;AAOtB;;AAGuB,iBAHP,wBAGO,CAAA,aAAA,MAAA,GAAA,MAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,YAAA,CAAA,EADN,IACM,EAAA,CAAA,EAApB,mBAAoB,CAAA,IAAA,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/content/github.d.ts
|
|
2
|
+
interface GetGithubLastCommitOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Repository name, like "fumadocs"
|
|
5
|
+
*/
|
|
6
|
+
repo: string;
|
|
7
|
+
/** Owner of repository */
|
|
8
|
+
owner: string;
|
|
9
|
+
/**
|
|
10
|
+
* Path to file
|
|
11
|
+
*/
|
|
12
|
+
path: string;
|
|
13
|
+
/**
|
|
14
|
+
* GitHub access token
|
|
15
|
+
*/
|
|
16
|
+
token?: string;
|
|
17
|
+
/**
|
|
18
|
+
* SHA or ref (branch or tag) name.
|
|
19
|
+
*/
|
|
20
|
+
sha?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Base URL for GitHub API
|
|
23
|
+
* @default "https://api.github.com"
|
|
24
|
+
* @link https://docs.github.com/en/get-started/using-github-docs/about-versions-of-github-docs#determining-which-github-product-you-use
|
|
25
|
+
*/
|
|
26
|
+
baseUrl?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Custom query parameters
|
|
29
|
+
*/
|
|
30
|
+
params?: Record<string, string>;
|
|
31
|
+
options?: RequestInit;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the last edit time of a file using GitHub API
|
|
35
|
+
*
|
|
36
|
+
* By default, this will cache the result forever.
|
|
37
|
+
* Set `options.next.revalidate` to customise this.
|
|
38
|
+
*/
|
|
39
|
+
declare function getGithubLastEdit({
|
|
40
|
+
repo,
|
|
41
|
+
token,
|
|
42
|
+
owner,
|
|
43
|
+
path,
|
|
44
|
+
sha,
|
|
45
|
+
baseUrl,
|
|
46
|
+
options,
|
|
47
|
+
params: customParams
|
|
48
|
+
}: GetGithubLastCommitOptions): Promise<Date | null>;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { GetGithubLastCommitOptions, getGithubLastEdit };
|
|
51
|
+
//# sourceMappingURL=github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","names":[],"sources":["../../src/content/github.ts"],"sourcesContent":[],"mappings":";UAQiB,0BAAA;EAAA;AA6CjB;;EAEE,IAAA,EAAA,MAAA;EACA;EACA,KAAA,EAAA,MAAA;EACA;;;EAGQ,IAAA,EAAA,MAAA;EACP;;;EAAoC,KAAA,CAAA,EAAA,MAAA;;;;;;;;;;;;;;WApB5B;YAEC;;;;;;;;iBASU,iBAAA;;;;;;;;UAQZ;GACP,6BAA6B,QAAQ"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/content/github.ts
|
|
2
|
+
/**
|
|
3
|
+
* Get the last edit time of a file using GitHub API
|
|
4
|
+
*
|
|
5
|
+
* By default, this will cache the result forever.
|
|
6
|
+
* Set `options.next.revalidate` to customise this.
|
|
7
|
+
*/
|
|
8
|
+
async function getGithubLastEdit({ repo, token, owner, path, sha, baseUrl = "https://api.github.com", options = {}, params: customParams = {} }) {
|
|
9
|
+
const headers = new Headers(options.headers);
|
|
10
|
+
const params = new URLSearchParams();
|
|
11
|
+
params.set("path", path);
|
|
12
|
+
params.set("page", "1");
|
|
13
|
+
params.set("per_page", "1");
|
|
14
|
+
if (sha) params.set("sha", sha);
|
|
15
|
+
for (const [key, value] of Object.entries(customParams)) params.set(key, value);
|
|
16
|
+
if (token) headers.append("authorization", token);
|
|
17
|
+
const res = await fetch(`${baseUrl}/repos/${owner}/${repo}/commits?${params.toString()}`, {
|
|
18
|
+
cache: "force-cache",
|
|
19
|
+
...options,
|
|
20
|
+
headers
|
|
21
|
+
});
|
|
22
|
+
if (!res.ok) throw new Error(`Failed to fetch last edit time from Git ${await res.text()}`);
|
|
23
|
+
const data = await res.json();
|
|
24
|
+
if (data.length === 0) return null;
|
|
25
|
+
return new Date(data[0].commit.committer.date);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { getGithubLastEdit };
|
|
30
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","names":[],"sources":["../../src/content/github.ts"],"sourcesContent":["type Response = {\n commit: {\n committer: {\n date: string;\n };\n };\n}[];\n\nexport interface GetGithubLastCommitOptions {\n /**\n * Repository name, like \"fumadocs\"\n */\n repo: string;\n\n /** Owner of repository */\n owner: string;\n\n /**\n * Path to file\n */\n path: string;\n\n /**\n * GitHub access token\n */\n token?: string;\n\n /**\n * SHA or ref (branch or tag) name.\n */\n sha?: string;\n\n /**\n * Base URL for GitHub API\n * @default \"https://api.github.com\"\n * @link https://docs.github.com/en/get-started/using-github-docs/about-versions-of-github-docs#determining-which-github-product-you-use\n */\n baseUrl?: string;\n\n /**\n * Custom query parameters\n */\n params?: Record<string, string>;\n\n options?: RequestInit;\n}\n\n/**\n * Get the last edit time of a file using GitHub API\n *\n * By default, this will cache the result forever.\n * Set `options.next.revalidate` to customise this.\n */\nexport async function getGithubLastEdit({\n repo,\n token,\n owner,\n path,\n sha,\n baseUrl = 'https://api.github.com',\n options = {},\n params: customParams = {},\n}: GetGithubLastCommitOptions): Promise<Date | null> {\n const headers = new Headers(options.headers);\n const params = new URLSearchParams();\n params.set('path', path);\n params.set('page', '1');\n params.set('per_page', '1');\n\n if (sha) params.set('sha', sha);\n\n for (const [key, value] of Object.entries(customParams)) {\n params.set(key, value);\n }\n\n if (token) {\n headers.append('authorization', token);\n }\n\n const res = await fetch(`${baseUrl}/repos/${owner}/${repo}/commits?${params.toString()}`, {\n cache: 'force-cache',\n ...options,\n headers,\n });\n\n if (!res.ok) throw new Error(`Failed to fetch last edit time from Git ${await res.text()}`);\n const data = (await res.json()) as Response;\n\n if (data.length === 0) return null;\n return new Date(data[0].commit.committer.date);\n}\n"],"mappings":";;;;;;;AAqDA,eAAsB,kBAAkB,EACtC,MACA,OACA,OACA,MACA,KACA,UAAU,0BACV,UAAU,EAAE,EACZ,QAAQ,eAAe,EAAE,IAC0B;CACnD,MAAM,UAAU,IAAI,QAAQ,QAAQ,QAAQ;CAC5C,MAAM,SAAS,IAAI,iBAAiB;AACpC,QAAO,IAAI,QAAQ,KAAK;AACxB,QAAO,IAAI,QAAQ,IAAI;AACvB,QAAO,IAAI,YAAY,IAAI;AAE3B,KAAI,IAAK,QAAO,IAAI,OAAO,IAAI;AAE/B,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,aAAa,CACrD,QAAO,IAAI,KAAK,MAAM;AAGxB,KAAI,MACF,SAAQ,OAAO,iBAAiB,MAAM;CAGxC,MAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,SAAS,MAAM,GAAG,KAAK,WAAW,OAAO,UAAU,IAAI;EACxF,OAAO;EACP,GAAG;EACH;EACD,CAAC;AAEF,KAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,2CAA2C,MAAM,IAAI,MAAM,GAAG;CAC3F,MAAM,OAAQ,MAAM,IAAI,MAAM;AAE9B,KAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,QAAO,IAAI,KAAK,KAAK,GAAG,OAAO,UAAU,KAAK"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react3 from "react";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { Components } from "hast-util-to-jsx-runtime";
|
|
4
|
+
import { Compatible } from "vfile";
|
|
5
|
+
import { PluggableList } from "unified";
|
|
6
|
+
|
|
7
|
+
//#region src/content/index.d.ts
|
|
8
|
+
interface MarkdownProps {
|
|
9
|
+
components?: Components;
|
|
10
|
+
}
|
|
11
|
+
declare function Markdown({
|
|
12
|
+
children: content,
|
|
13
|
+
remarkPlugins,
|
|
14
|
+
rehypePlugins,
|
|
15
|
+
...options
|
|
16
|
+
}: MarkdownProps & {
|
|
17
|
+
remarkPlugins?: PluggableList;
|
|
18
|
+
rehypePlugins?: PluggableList;
|
|
19
|
+
children: Compatible;
|
|
20
|
+
}): Promise<react3.ReactElement<unknown, string | react3.JSXElementConstructor<any>> | Iterable<ReactNode> | (string | number | bigint | boolean | react3.ReactPortal | react3.ReactElement<unknown, string | react3.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined)>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Markdown, MarkdownProps };
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|