@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.
Files changed (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/advanced-Ct13khZr.js +79 -0
  4. package/dist/algolia-C0E5qQhM.d.ts +66 -0
  5. package/dist/breadcrumb.d.ts +46 -0
  6. package/dist/breadcrumb.js +59 -0
  7. package/dist/build-doc-4OvfjVN2.js +85 -0
  8. package/dist/client-kQ39Ub0-.d.ts +247 -0
  9. package/dist/codeblock-utils-CyP8qsYv.d.ts +29 -0
  10. package/dist/content/github.d.ts +41 -0
  11. package/dist/content/github.js +28 -0
  12. package/dist/content/md/frontmatter.d.ts +15 -0
  13. package/dist/content/md/frontmatter.js +24 -0
  14. package/dist/content/md.d.ts +24 -0
  15. package/dist/content/md.js +43 -0
  16. package/dist/content/mdx/preset-bundler.d.ts +29 -0
  17. package/dist/content/mdx/preset-bundler.js +39 -0
  18. package/dist/content/mdx/preset-runtime.d.ts +26 -0
  19. package/dist/content/mdx/preset-runtime.js +36 -0
  20. package/dist/content/toc.d.ts +19 -0
  21. package/dist/content/toc.js +14 -0
  22. package/dist/definitions-CFOhwE1k.d.ts +72 -0
  23. package/dist/dynamic-CTsodhTH.js +905 -0
  24. package/dist/dynamic-link.d.ts +12 -0
  25. package/dist/dynamic-link.js +31 -0
  26. package/dist/endpoint-MyoBU5IC.js +28 -0
  27. package/dist/framework/astro.d.ts +21 -0
  28. package/dist/framework/astro.js +52 -0
  29. package/dist/framework/index.d.ts +40 -0
  30. package/dist/framework/index.js +66 -0
  31. package/dist/framework/next.d.ts +10 -0
  32. package/dist/framework/next.js +19 -0
  33. package/dist/framework/react-router.d.ts +10 -0
  34. package/dist/framework/react-router.js +43 -0
  35. package/dist/framework/tanstack.d.ts +13 -0
  36. package/dist/framework/tanstack.js +54 -0
  37. package/dist/framework/waku.d.ts +10 -0
  38. package/dist/framework/waku.js +46 -0
  39. package/dist/highlight/client.d.ts +11 -0
  40. package/dist/highlight/client.js +15 -0
  41. package/dist/highlight/index.d.ts +31 -0
  42. package/dist/highlight/index.js +30 -0
  43. package/dist/highlight/shiki/full.d.ts +7 -0
  44. package/dist/highlight/shiki/full.js +23 -0
  45. package/dist/highlight/shiki/index.d.ts +2 -0
  46. package/dist/highlight/shiki/index.js +27 -0
  47. package/dist/highlight/shiki/react.d.ts +23 -0
  48. package/dist/highlight/shiki/react.js +50 -0
  49. package/dist/i18n/index.d.ts +2 -0
  50. package/dist/i18n/index.js +63 -0
  51. package/dist/i18n/middleware.d.ts +34 -0
  52. package/dist/i18n/middleware.js +3855 -0
  53. package/dist/icon-BILaoXeg.js +17 -0
  54. package/dist/index-B-0R0VbS.d.ts +18 -0
  55. package/dist/index-BM36H-xw.d.ts +36 -0
  56. package/dist/index-BMEUQz-F.d.ts +21 -0
  57. package/dist/index-DAYtLGbx.d.ts +16 -0
  58. package/dist/index-DIwKCYOz.d.ts +513 -0
  59. package/dist/index-DydiXvgS.d.ts +90 -0
  60. package/dist/index-E8Qh_yQs.d.ts +49 -0
  61. package/dist/is-equal-LdLqRs0o.js +8 -0
  62. package/dist/link.d.ts +17 -0
  63. package/dist/link.js +23 -0
  64. package/dist/mdx-plugins/codeblock-utils.d.ts +2 -0
  65. package/dist/mdx-plugins/codeblock-utils.js +68 -0
  66. package/dist/mdx-plugins/index.d.ts +20 -0
  67. package/dist/mdx-plugins/index.js +18 -0
  68. package/dist/mdx-plugins/rehype-code.core.d.ts +3 -0
  69. package/dist/mdx-plugins/rehype-code.core.js +3 -0
  70. package/dist/mdx-plugins/rehype-code.d.ts +4 -0
  71. package/dist/mdx-plugins/rehype-code.js +24 -0
  72. package/dist/mdx-plugins/rehype-toc.d.ts +2 -0
  73. package/dist/mdx-plugins/rehype-toc.js +139 -0
  74. package/dist/mdx-plugins/remark-admonition.d.ts +2 -0
  75. package/dist/mdx-plugins/remark-admonition.js +71 -0
  76. package/dist/mdx-plugins/remark-block-id.d.ts +37 -0
  77. package/dist/mdx-plugins/remark-block-id.js +41 -0
  78. package/dist/mdx-plugins/remark-code-tab.d.ts +2 -0
  79. package/dist/mdx-plugins/remark-code-tab.js +190 -0
  80. package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -0
  81. package/dist/mdx-plugins/remark-directive-admonition.js +57 -0
  82. package/dist/mdx-plugins/remark-feedback-block.d.ts +2 -0
  83. package/dist/mdx-plugins/remark-feedback-block.js +54 -0
  84. package/dist/mdx-plugins/remark-gfm.d.ts +2 -0
  85. package/dist/mdx-plugins/remark-gfm.js +2 -0
  86. package/dist/mdx-plugins/remark-heading.d.ts +2 -0
  87. package/dist/mdx-plugins/remark-heading.js +46 -0
  88. package/dist/mdx-plugins/remark-image.d.ts +2 -0
  89. package/dist/mdx-plugins/remark-image.js +167 -0
  90. package/dist/mdx-plugins/remark-llms.d.ts +2 -0
  91. package/dist/mdx-plugins/remark-llms.js +338 -0
  92. package/dist/mdx-plugins/remark-llms.runtime.d.ts +10 -0
  93. package/dist/mdx-plugins/remark-llms.runtime.js +24 -0
  94. package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -0
  95. package/dist/mdx-plugins/remark-mdx-files.js +182 -0
  96. package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -0
  97. package/dist/mdx-plugins/remark-mdx-mermaid.js +28 -0
  98. package/dist/mdx-plugins/remark-npm.d.ts +2 -0
  99. package/dist/mdx-plugins/remark-npm.js +76 -0
  100. package/dist/mdx-plugins/remark-steps.d.ts +2 -0
  101. package/dist/mdx-plugins/remark-steps.js +93 -0
  102. package/dist/mdx-plugins/remark-structure.d.ts +2 -0
  103. package/dist/mdx-plugins/remark-structure.js +118 -0
  104. package/dist/mdx-plugins/stringifier.d.ts +2 -0
  105. package/dist/mdx-plugins/stringifier.js +91 -0
  106. package/dist/mdx-plugins/transformer-icon.d.ts +2 -0
  107. package/dist/mdx-plugins/transformer-icon.js +145 -0
  108. package/dist/negotiation/index.d.ts +17 -0
  109. package/dist/negotiation/index.js +378 -0
  110. package/dist/page-tree/index.d.ts +3 -0
  111. package/dist/page-tree/index.js +2 -0
  112. package/dist/path-1H5VzYiT.js +75 -0
  113. package/dist/rehype-code-D-RFJb9W.d.ts +14 -0
  114. package/dist/rehype-code.core-BUwNuchP.js +548 -0
  115. package/dist/rehype-code.core-BjH1uHWj.d.ts +115 -0
  116. package/dist/rehype-toc-K51AGb5U.d.ts +43 -0
  117. package/dist/remark-admonition-BwTcmI_S.d.ts +20 -0
  118. package/dist/remark-code-tab-DE_4bdnu.d.ts +34 -0
  119. package/dist/remark-directive-admonition-BLiJ5l43.d.ts +27 -0
  120. package/dist/remark-feedback-block-BxtINXN-.d.ts +45 -0
  121. package/dist/remark-gfm-DpVfAX1x.d.ts +2 -0
  122. package/dist/remark-heading-DEIzTkU5.d.ts +33 -0
  123. package/dist/remark-image-BI2S9LOb.d.ts +57 -0
  124. package/dist/remark-llms-bD3WvU2V.d.ts +73 -0
  125. package/dist/remark-mdx-files-Buvxc-sa.d.ts +54 -0
  126. package/dist/remark-mdx-mermaid-C1bCHHc6.d.ts +15 -0
  127. package/dist/remark-npm-BbpvkJaT.d.ts +31 -0
  128. package/dist/remark-steps-DqVEo0iq.d.ts +23 -0
  129. package/dist/remark-structure-CnHwvNZr.d.ts +87 -0
  130. package/dist/remove-markdown-DfKNMl9w.js +40 -0
  131. package/dist/remove-undefined-CzMSKybq.js +24 -0
  132. package/dist/rolldown-runtime-DC62tzP2.js +33 -0
  133. package/dist/search/algolia.d.ts +2 -0
  134. package/dist/search/algolia.js +75 -0
  135. package/dist/search/client/algolia.d.ts +2 -0
  136. package/dist/search/client/algolia.js +53 -0
  137. package/dist/search/client/fetch.d.ts +2 -0
  138. package/dist/search/client/fetch.js +28 -0
  139. package/dist/search/client/flexsearch-static.d.ts +2 -0
  140. package/dist/search/client/flexsearch-static.js +42 -0
  141. package/dist/search/client/mixedbread.d.ts +2 -0
  142. package/dist/search/client/mixedbread.js +65 -0
  143. package/dist/search/client/orama-cloud-legacy.d.ts +2 -0
  144. package/dist/search/client/orama-cloud-legacy.js +84 -0
  145. package/dist/search/client/orama-cloud.d.ts +2 -0
  146. package/dist/search/client/orama-cloud.js +86 -0
  147. package/dist/search/client/orama-static.d.ts +2 -0
  148. package/dist/search/client/orama-static.js +75 -0
  149. package/dist/search/client.d.ts +2 -0
  150. package/dist/search/client.js +97 -0
  151. package/dist/search/flexsearch.d.ts +56 -0
  152. package/dist/search/flexsearch.js +128 -0
  153. package/dist/search/index.d.ts +2 -0
  154. package/dist/search/index.js +74 -0
  155. package/dist/search/mixedbread.d.ts +49 -0
  156. package/dist/search/mixedbread.js +77 -0
  157. package/dist/search/orama-cloud-legacy.d.ts +75 -0
  158. package/dist/search/orama-cloud-legacy.js +48 -0
  159. package/dist/search/orama-cloud.d.ts +75 -0
  160. package/dist/search/orama-cloud.js +50 -0
  161. package/dist/search/server.d.ts +2 -0
  162. package/dist/search/server.js +237 -0
  163. package/dist/server-CCqACwlF.d.ts +165 -0
  164. package/dist/server.browser.d.ts +13 -0
  165. package/dist/server.browser.js +22 -0
  166. package/dist/server.d.ts +42 -0
  167. package/dist/server.js +398 -0
  168. package/dist/source/client/index.d.ts +2 -0
  169. package/dist/source/client/index.js +37 -0
  170. package/dist/source/dynamic.d.ts +2 -0
  171. package/dist/source/dynamic.js +2 -0
  172. package/dist/source/index.d.ts +2 -0
  173. package/dist/source/index.js +5 -0
  174. package/dist/source/llms.d.ts +2 -0
  175. package/dist/source/llms.js +74 -0
  176. package/dist/source/plugins/lucide-icons.d.ts +11 -0
  177. package/dist/source/plugins/lucide-icons.js +21 -0
  178. package/dist/source/plugins/slugs.d.ts +2 -0
  179. package/dist/source/plugins/slugs.js +75 -0
  180. package/dist/source/plugins/status-badges.d.ts +50 -0
  181. package/dist/source/plugins/status-badges.js +52 -0
  182. package/dist/source/schema.d.ts +30 -0
  183. package/dist/source/schema.js +28 -0
  184. package/dist/stringifier-B_QUcUyo.d.ts +63 -0
  185. package/dist/toc-CtW5lwA1.d.ts +64 -0
  186. package/dist/toc.d.ts +2 -0
  187. package/dist/toc.js +245 -0
  188. package/dist/transformer-icon-DlrneIS3.d.ts +17 -0
  189. package/dist/types-D89QoQR-.d.ts +4 -0
  190. package/dist/url-BVHvi3_K.js +29 -0
  191. package/dist/util-BDsqOxh3.d.ts +6 -0
  192. package/dist/util-DjBr9b3w.js +8 -0
  193. package/dist/utils/use-media-query.d.ts +4 -0
  194. package/dist/utils/use-media-query.js +20 -0
  195. package/dist/utils/use-on-change.d.ts +9 -0
  196. package/dist/utils/use-on-change.js +17 -0
  197. package/dist/utils-Bvy3V-fv.js +59 -0
  198. package/dist/utils-Cgs-6U-z.js +39 -0
  199. package/dist/utils-DEVq3cEC.js +151 -0
  200. package/dist/utils-Yx0IL9eW.js +48 -0
  201. package/package.json +251 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Fuma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Fumadocs Core
2
+
3
+ The core library for Fumadocs.
4
+
5
+ 📘 Learn More: [Documentation](https://fumadocs.dev)
@@ -0,0 +1,79 @@
1
+ import { createContentHighlighter } from "./search/index.js";
2
+ import { t as removeUndefined } from "./remove-undefined-CzMSKybq.js";
3
+ import { getByID, search } from "zbsearch";
4
+ //#region src/search/zbsearch/search/simple.ts
5
+ async function searchSimple(db, query, params = {}, locale) {
6
+ const highlighter = createContentHighlighter(query);
7
+ return (await search(db, {
8
+ term: query,
9
+ tolerance: 1,
10
+ ...params,
11
+ boost: {
12
+ title: 2,
13
+ ..."boost" in params ? params.boost : void 0
14
+ },
15
+ where: removeUndefined({
16
+ locale: locale ? { eq: locale } : void 0,
17
+ ...params.where
18
+ })
19
+ })).hits.map((hit) => ({
20
+ type: "page",
21
+ content: highlighter.highlightMarkdown(hit.document.title),
22
+ breadcrumbs: hit.document.breadcrumbs,
23
+ id: hit.document.url,
24
+ url: hit.document.url
25
+ }));
26
+ }
27
+ //#endregion
28
+ //#region src/search/zbsearch/search/advanced.ts
29
+ async function searchAdvanced(db, query, tag = [], { mode = "fulltext", ...override } = {}, locale) {
30
+ if (typeof tag === "string") tag = [tag];
31
+ const params = {
32
+ limit: 60,
33
+ mode,
34
+ ...override,
35
+ where: removeUndefined({
36
+ tags: tag.length > 0 ? { containsAll: tag } : void 0,
37
+ locale: locale ? { eq: locale } : void 0,
38
+ ...override.where
39
+ }),
40
+ groupBy: {
41
+ properties: ["page_id"],
42
+ maxResult: 8,
43
+ ...override.groupBy
44
+ },
45
+ properties: mode === "fulltext" ? ["content"] : ["content", "embeddings"]
46
+ };
47
+ if (query.length > 0) params.term = query;
48
+ const highlighter = createContentHighlighter(query);
49
+ const result = await search(db, params);
50
+ const limit = typeof params.limit === "number" ? params.limit : Infinity;
51
+ const list = [];
52
+ for (const item of result.groups ?? []) {
53
+ if (list.length >= limit) break;
54
+ const pageId = item.values[0];
55
+ const page = getByID(db, pageId);
56
+ if (!page) continue;
57
+ list.push({
58
+ id: pageId,
59
+ type: "page",
60
+ content: highlighter.highlightMarkdown(page.content),
61
+ breadcrumbs: page.breadcrumbs,
62
+ url: page.url
63
+ });
64
+ for (const hit of item.result) {
65
+ if (list.length >= limit) break;
66
+ if (hit.document.type === "page") continue;
67
+ list.push({
68
+ id: hit.document.id.toString(),
69
+ content: highlighter.highlightMarkdown(hit.document.content),
70
+ breadcrumbs: hit.document.breadcrumbs,
71
+ type: hit.document.type,
72
+ url: hit.document.url
73
+ });
74
+ }
75
+ }
76
+ return list;
77
+ }
78
+ //#endregion
79
+ export { searchSimple as n, searchAdvanced as t };
@@ -0,0 +1,66 @@
1
+ import { i as StructuredData } from "./remark-structure-CnHwvNZr.js";
2
+ import { Algoliasearch } from "algoliasearch";
3
+ //#region src/search/algolia.d.ts
4
+ interface DocumentRecord {
5
+ /**
6
+ * The ID of document, must be unique
7
+ */
8
+ _id: string;
9
+ title: string;
10
+ description?: string;
11
+ breadcrumbs?: string[];
12
+ /**
13
+ * URL to the page
14
+ */
15
+ url: string;
16
+ structured: StructuredData;
17
+ /**
18
+ * Tag to filter results
19
+ */
20
+ tag?: string;
21
+ /**
22
+ * Data to be added to each section index
23
+ */
24
+ extra_data?: object;
25
+ }
26
+ interface SyncOptions {
27
+ /**
28
+ * Index Name for documents.
29
+ */
30
+ indexName?: string;
31
+ /**
32
+ * Search indexes
33
+ */
34
+ documents: DocumentRecord[];
35
+ }
36
+ /**
37
+ * Update index settings and replace all objects
38
+ *
39
+ * @param client - Algolia Admin Client
40
+ * @param options - Index Options
41
+ */
42
+ declare function sync(client: Algoliasearch, options: SyncOptions): Promise<void>;
43
+ declare function setIndexSettings(client: Algoliasearch, indexName: string): Promise<void>;
44
+ declare function updateDocuments(client: Algoliasearch, indexName: string, documents: DocumentRecord[]): Promise<void>;
45
+ interface BaseIndex {
46
+ objectID: string;
47
+ title: string;
48
+ url: string;
49
+ tag?: string;
50
+ /**
51
+ * The id of page, used for distinct
52
+ */
53
+ page_id: string;
54
+ /**
55
+ * Heading content
56
+ */
57
+ section?: string;
58
+ /**
59
+ * Heading (anchor) id
60
+ */
61
+ section_id?: string;
62
+ breadcrumbs?: string[];
63
+ content: string;
64
+ }
65
+ //#endregion
66
+ export { sync as a, setIndexSettings as i, DocumentRecord as n, updateDocuments as o, SyncOptions as r, BaseIndex as t };
@@ -0,0 +1,46 @@
1
+ import { i as Root, r as Node, t as Folder } from "./definitions-CFOhwE1k.js";
2
+ import { ReactNode } from "react";
3
+ //#region src/breadcrumb.d.ts
4
+ interface BreadcrumbItem {
5
+ name: ReactNode;
6
+ url?: string;
7
+ }
8
+ interface BreadcrumbOptions {
9
+ /**
10
+ * Include the root folders in the breadcrumb items array.
11
+ *
12
+ * @defaultValue false
13
+ */
14
+ includeRoot?: boolean | {
15
+ /**
16
+ * Specify the url of root
17
+ */
18
+ url: string;
19
+ };
20
+ /**
21
+ * Include the page itself in the breadcrumb items array
22
+ *
23
+ * @defaultValue false
24
+ */
25
+ includePage?: boolean;
26
+ /**
27
+ * Count separator as an item
28
+ *
29
+ * @defaultValue false
30
+ */
31
+ includeSeparator?: boolean;
32
+ }
33
+ declare function useBreadcrumb(url: string, tree: Root | Folder, options?: BreadcrumbOptions): BreadcrumbItem[];
34
+ declare function getBreadcrumbItems(url: string, tree: Root | Folder, options?: BreadcrumbOptions): BreadcrumbItem[];
35
+ declare function getBreadcrumbItemsFromPath(tree: Root | Folder, path: Node[], options: BreadcrumbOptions): BreadcrumbItem[];
36
+ /**
37
+ * Search the path of a node in the tree by a specified url
38
+ *
39
+ * - When the page doesn't exist, return null
40
+ *
41
+ * @returns The path to the target node from root
42
+ * @internal Don't use this on your own
43
+ */
44
+ declare function searchPath(nodes: Node[], url: string): Node[] | null;
45
+ //#endregion
46
+ export { BreadcrumbItem, BreadcrumbOptions, getBreadcrumbItems, getBreadcrumbItemsFromPath, searchPath, useBreadcrumb };
@@ -0,0 +1,59 @@
1
+ import { r as normalizeUrl } from "./url-BVHvi3_K.js";
2
+ import { r as findPath } from "./utils-DEVq3cEC.js";
3
+ import { useMemo } from "react";
4
+ //#region src/breadcrumb.tsx
5
+ function useBreadcrumb(url, tree, options) {
6
+ return useMemo(() => getBreadcrumbItems(url, tree, options), [
7
+ tree,
8
+ url,
9
+ options
10
+ ]);
11
+ }
12
+ function getBreadcrumbItems(url, tree, options = {}) {
13
+ return getBreadcrumbItemsFromPath(tree, searchPath(tree.children, url) ?? [], options);
14
+ }
15
+ function getBreadcrumbItemsFromPath(tree, path, options) {
16
+ const { includePage = false, includeSeparator = false, includeRoot = false } = options;
17
+ let items = [];
18
+ for (let i = 0; i < path.length; i++) {
19
+ const item = path[i];
20
+ switch (item.type) {
21
+ case "page":
22
+ if (includePage) items.push({
23
+ name: item.name,
24
+ url: item.url
25
+ });
26
+ break;
27
+ case "folder":
28
+ if (item.root) {
29
+ items = [];
30
+ if (includeRoot) items.push({
31
+ name: tree.name,
32
+ url: typeof includeRoot === "object" ? includeRoot.url : item.index?.url
33
+ });
34
+ break;
35
+ }
36
+ if (i === path.length - 1 || item.index !== path[i + 1]) items.push({
37
+ name: item.name,
38
+ url: item.index?.url
39
+ });
40
+ break;
41
+ case "separator": if (item.name && includeSeparator) items.push({ name: item.name });
42
+ }
43
+ }
44
+ return items;
45
+ }
46
+ /**
47
+ * Search the path of a node in the tree by a specified url
48
+ *
49
+ * - When the page doesn't exist, return null
50
+ *
51
+ * @returns The path to the target node from root
52
+ * @internal Don't use this on your own
53
+ */
54
+ function searchPath(nodes, url) {
55
+ const normalizedUrl = normalizeUrl(url);
56
+ return findPath(nodes, (node) => node.type === "page" && node.url === normalizedUrl);
57
+ }
58
+ //#endregion
59
+ export { getBreadcrumbItems, getBreadcrumbItemsFromPath, searchPath, useBreadcrumb };
@@ -0,0 +1,85 @@
1
+ import { r as findPath } from "./utils-DEVq3cEC.js";
2
+ import { r as extname, t as basename } from "./path-1H5VzYiT.js";
3
+ //#region src/search/server/build-index.ts
4
+ async function buildIndexDefault(page) {
5
+ let structuredData;
6
+ if (page.data.structuredData) structuredData = typeof page.data.structuredData === "function" ? await page.data.structuredData() : page.data.structuredData;
7
+ else if ("load" in page.data && typeof page.data.load === "function") structuredData = (await page.data.load()).structuredData;
8
+ if (!structuredData) throw new Error("Cannot find structured data from page, please define the page to index function.");
9
+ return {
10
+ title: page.data.title ?? basename(page.path, extname(page.path)),
11
+ description: page.data.description,
12
+ url: page.url,
13
+ id: page.url,
14
+ structuredData
15
+ };
16
+ }
17
+ function isBreadcrumbItem(item) {
18
+ return typeof item === "string" && item.length > 0;
19
+ }
20
+ function buildBreadcrumbs(source, page) {
21
+ const pageTree = source.getPageTree(page.locale);
22
+ const path = findPath(pageTree.children, (node) => node.type === "page" && node.url === page.url);
23
+ if (path) {
24
+ const breadcrumbs = [];
25
+ path.pop();
26
+ if (isBreadcrumbItem(pageTree.name)) breadcrumbs.push(pageTree.name);
27
+ for (const segment of path) {
28
+ if (!isBreadcrumbItem(segment.name)) continue;
29
+ breadcrumbs.push(segment.name);
30
+ }
31
+ return breadcrumbs;
32
+ }
33
+ }
34
+ //#endregion
35
+ //#region src/search/server/build-doc.ts
36
+ function buildDocuments(indexes) {
37
+ const docs = [];
38
+ for (const page of indexes) {
39
+ const pageTag = page.tag ?? [];
40
+ const tags = Array.isArray(pageTag) ? pageTag : [pageTag];
41
+ const data = page.structuredData;
42
+ let id = 0;
43
+ docs.push({
44
+ id: page.id,
45
+ page_id: page.id,
46
+ type: "page",
47
+ content: page.title,
48
+ breadcrumbs: page.breadcrumbs,
49
+ tags,
50
+ url: page.url,
51
+ locale: page.locale
52
+ });
53
+ const nextId = () => `${page.id}-${id++}`;
54
+ if (page.description && !data.contents.some((item) => item.content === page.description)) docs.push({
55
+ id: nextId(),
56
+ page_id: page.id,
57
+ tags,
58
+ type: "text",
59
+ url: page.url,
60
+ content: page.description,
61
+ locale: page.locale
62
+ });
63
+ for (const heading of data.headings) docs.push({
64
+ id: nextId(),
65
+ page_id: page.id,
66
+ type: "heading",
67
+ tags,
68
+ url: `${page.url}#${heading.id}`,
69
+ content: heading.content,
70
+ locale: page.locale
71
+ });
72
+ for (const content of data.contents) docs.push({
73
+ id: nextId(),
74
+ page_id: page.id,
75
+ tags,
76
+ type: "text",
77
+ url: content.heading ? `${page.url}#${content.heading}` : page.url,
78
+ content: content.content,
79
+ locale: page.locale
80
+ });
81
+ }
82
+ return docs;
83
+ }
84
+ //#endregion
85
+ export { buildBreadcrumbs as n, buildIndexDefault as r, buildDocuments as t };
@@ -0,0 +1,247 @@
1
+ import { t as Awaitable } from "./types-D89QoQR-.js";
2
+ import { t as BaseIndex } from "./algolia-C0E5qQhM.js";
3
+ import { r as SortedResult } from "./index-BM36H-xw.js";
4
+ import { DependencyList } from "react";
5
+ import { AnyZBSearch, SearchParams } from "zbsearch";
6
+ import { LiteClient, SearchResponse } from "algoliasearch/lite";
7
+ import { OramaCloud, OramaCloudSearchParams } from "@orama/core";
8
+ import { ClientSearchParams, OramaClient } from "@oramacloud/client";
9
+ import Mixedbread from "@mixedbread/sdk";
10
+ //#region src/search/client/fetch.d.ts
11
+ interface FetchOptions {
12
+ /**
13
+ * API route for search endpoint, support absolute URLs.
14
+ *
15
+ * @defaultValue '/api/search'
16
+ */
17
+ api?: string;
18
+ /**
19
+ * Filter results with specific tag(s).
20
+ */
21
+ tag?: string | string[];
22
+ /**
23
+ * Filter by locale
24
+ */
25
+ locale?: string;
26
+ cache?: Map<string, SortedResult[]>;
27
+ }
28
+ declare function fetchClient({ api, locale, tag, cache }?: FetchOptions): SearchClient;
29
+ //#endregion
30
+ //#region src/search/client/orama-static.d.ts
31
+ interface StaticOptions {
32
+ /**
33
+ * Where to download exported search indexes (URL)
34
+ *
35
+ * @defaultValue '/api/search'
36
+ */
37
+ from?: string;
38
+ /**
39
+ * Customize how the search database is initialized (advanced).
40
+ *
41
+ * For legacy per-locale exports, it is called once per locale.
42
+ */
43
+ initDB?: (locale?: string) => AnyZBSearch | Promise<AnyZBSearch>;
44
+ /**
45
+ * @deprecated Renamed to `initDB`, note that the search engine is now ZBSearch.
46
+ */
47
+ initOrama?: (locale?: string) => AnyZBSearch | Promise<AnyZBSearch>;
48
+ /**
49
+ * Filter results with specific tag(s).
50
+ */
51
+ tag?: string | string[];
52
+ /**
53
+ * Filter by locale (for i18n)
54
+ */
55
+ locale?: string;
56
+ /**
57
+ * extra options for search
58
+ */
59
+ search?: Partial<SearchParams<AnyZBSearch>>;
60
+ }
61
+ declare function staticClient(options?: StaticOptions): SearchClient;
62
+ /**
63
+ * @deprecated Renamed to `staticClient`, note that the search engine is now ZBSearch.
64
+ */
65
+ declare const oramaStaticClient: typeof staticClient;
66
+ //#endregion
67
+ //#region src/search/client/algolia.d.ts
68
+ interface AlgoliaOptions {
69
+ indexName: string;
70
+ client: LiteClient;
71
+ /**
72
+ * Filter results with specific tag.
73
+ */
74
+ tag?: string;
75
+ locale?: string;
76
+ onSearch?: (query: string, tag?: string, locale?: string) => Promise<{
77
+ results: SearchResponse<BaseIndex>[];
78
+ }>;
79
+ }
80
+ declare function algoliaClient(options: AlgoliaOptions): SearchClient;
81
+ //#endregion
82
+ //#region src/search/client/orama-cloud.d.ts
83
+ interface OramaCloudOptions {
84
+ client: OramaCloud;
85
+ /**
86
+ * The type of your index.
87
+ *
88
+ * You can set it to `crawler` if you use crawler instead of the JSON index with schema provided by Fumadocs
89
+ */
90
+ index?: 'default' | 'crawler';
91
+ /**
92
+ * Note: not included in dependency list.
93
+ */
94
+ params?: Partial<OramaCloudSearchParams>;
95
+ /**
96
+ * Filter results with specific tag.
97
+ */
98
+ tag?: string;
99
+ /**
100
+ * Filter by locale (unsupported at the moment)
101
+ */
102
+ locale?: string;
103
+ }
104
+ declare function oramaCloudClient(options: OramaCloudOptions): SearchClient;
105
+ //#endregion
106
+ //#region src/search/client/orama-cloud-legacy.d.ts
107
+ interface OramaCloudLegacyOptions {
108
+ client: OramaClient;
109
+ /**
110
+ * The type of your index.
111
+ *
112
+ * You can set it to `crawler` if you use crawler instead of the JSON index with schema provided by Fumadocs.
113
+ */
114
+ index?: 'default' | 'crawler';
115
+ /**
116
+ * Note: not included into dependency list.
117
+ */
118
+ params?: ClientSearchParams;
119
+ /**
120
+ * Filter results with specific tag.
121
+ */
122
+ tag?: string;
123
+ /**
124
+ * Filter by locale (unsupported at the moment)
125
+ */
126
+ locale?: string;
127
+ }
128
+ declare function oramaCloudLegacyClient(options: OramaCloudLegacyOptions): SearchClient;
129
+ //#endregion
130
+ //#region src/search/client/mixedbread.d.ts
131
+ interface MixedbreadOptions {
132
+ /**
133
+ * The identifier of the store to search in
134
+ */
135
+ storeIdentifier: string;
136
+ /**
137
+ * The Mixedbread SDK client instance
138
+ */
139
+ client: Mixedbread;
140
+ /**
141
+ * Filter results with specific tag.
142
+ */
143
+ tag?: string;
144
+ /**
145
+ * Filter by locale (unsupported at the moment)
146
+ */
147
+ locale?: string;
148
+ }
149
+ interface SearchMetadata {
150
+ title?: string;
151
+ description?: string;
152
+ url?: string;
153
+ tag?: string;
154
+ }
155
+ /**
156
+ * @deprecated Use `createMixedbreadSearchAPI` from `@vezham/docs-core/search/mixedbread` instead.
157
+ * This client-side approach exposes your API key in the browser.
158
+ * The server-side approach keeps the key secure and uses `client: fetchClient(...)` on the client.
159
+ */
160
+ declare function mixedbreadClient(options: MixedbreadOptions): SearchClient;
161
+ //#endregion
162
+ //#region src/search/client/flexsearch-static.d.ts
163
+ interface FlexsearchStaticOptions {
164
+ /**
165
+ * @defaultValue `/api/search`
166
+ */
167
+ from?: string;
168
+ locale?: string;
169
+ tag?: string | string[];
170
+ }
171
+ declare function flexsearchStaticClient(options?: FlexsearchStaticOptions): SearchClient;
172
+ //#endregion
173
+ //#region src/search/client.d.ts
174
+ interface UseDocsSearch {
175
+ search: string;
176
+ setSearch: (v: string) => void;
177
+ query: {
178
+ isLoading: boolean;
179
+ data?: SortedResult[] | 'empty';
180
+ error?: Error;
181
+ };
182
+ }
183
+ type ClientPreset = ({
184
+ /**
185
+ * @deprecated Pass `client: fetchClient(...)` instead.
186
+ */
187
+ type: 'fetch';
188
+ } & FetchOptions) | ({
189
+ /**
190
+ * @deprecated Pass `client: staticClient(...)` instead.
191
+ */
192
+ type: 'static';
193
+ } & StaticOptions) | ({
194
+ /**
195
+ * @deprecated Pass `client: algoliaClient(...)` instead.
196
+ */
197
+ type: 'algolia';
198
+ } & AlgoliaOptions) | ({
199
+ /**
200
+ * @deprecated Pass `client: oramaCloudClient(...)` instead.
201
+ */
202
+ type: 'orama-cloud';
203
+ } & OramaCloudOptions) | ({
204
+ /**
205
+ * @deprecated Pass `client: oramaCloudLegacyClient(...)` instead.
206
+ */
207
+ type: 'orama-cloud-legacy';
208
+ } & OramaCloudLegacyOptions) | ({
209
+ /**
210
+ * @deprecated Pass `client: flexsearchStaticClient(...)` instead.
211
+ */
212
+ type: 'flexsearch-static';
213
+ } & FlexsearchStaticOptions) | ({
214
+ /**
215
+ * @deprecated Use `createMixedbreadSearchAPI` from `@vezham/docs-core/search/mixedbread` instead.
216
+ * This client-side approach exposes your API key in the browser.
217
+ * The server-side approach keeps the key secure and uses `client: fetchClient(...)` on the client.
218
+ */
219
+ type: 'mixedbread';
220
+ } & MixedbreadOptions) | {
221
+ client: SearchClient;
222
+ };
223
+ interface SearchClient {
224
+ search: (query: string) => Awaitable<SortedResult[]>;
225
+ deps?: DependencyList;
226
+ }
227
+ /**
228
+ * Provide a hook to query different official search clients.
229
+ *
230
+ * Note: it will re-query when its parameters changed, make sure to define `deps` array if you encounter rendering issues.
231
+ */
232
+ declare function useDocsSearch(clientOptions: ClientPreset & {
233
+ /**
234
+ * The debounced delay for performing a search (in ms).
235
+ * .
236
+ * @defaultValue 100
237
+ */
238
+ delayMs?: number;
239
+ /**
240
+ * still perform search even if query is empty.
241
+ *
242
+ * @defaultValue false
243
+ */
244
+ allowEmpty?: boolean;
245
+ }, customDeps?: DependencyList): UseDocsSearch;
246
+ //#endregion
247
+ export { staticClient as _, flexsearchStaticClient as a, mixedbreadClient as c, OramaCloudOptions as d, oramaCloudClient as f, oramaStaticClient as g, StaticOptions as h, FlexsearchStaticOptions as i, OramaCloudLegacyOptions as l, algoliaClient as m, SearchClient as n, MixedbreadOptions as o, AlgoliaOptions as p, useDocsSearch as r, SearchMetadata as s, ClientPreset as t, oramaCloudLegacyClient as u, FetchOptions as v, fetchClient as y };
@@ -0,0 +1,29 @@
1
+ import { MdxJsxAttribute, MdxJsxFlowElement } from "mdast-util-mdx";
2
+ import { BlockContent, Text } from "mdast";
3
+ //#region src/mdx-plugins/codeblock-utils.d.ts
4
+ interface CodeBlockTabsOptions {
5
+ attributes?: MdxJsxAttribute[];
6
+ defaultValue?: string;
7
+ persist?: {
8
+ id: string;
9
+ } | false;
10
+ triggers: {
11
+ value: string;
12
+ children: (BlockContent | Text)[];
13
+ }[];
14
+ tabs: {
15
+ value: string;
16
+ children: BlockContent[];
17
+ }[];
18
+ }
19
+ declare function generateCodeBlockTabs({ persist, defaultValue, triggers, tabs, ...options }: CodeBlockTabsOptions): MdxJsxFlowElement;
20
+ interface CodeBlockAttributes<Name extends string = string> {
21
+ attributes: Partial<Record<Name, string | number | null>>;
22
+ rest: string;
23
+ }
24
+ /**
25
+ * Parse Fumadocs-style code block attributes from meta string, like `title="hello world"`
26
+ */
27
+ declare function parseCodeBlockAttributes<const Name extends string = string>(meta: string, allowedNames?: Name[]): CodeBlockAttributes<Name>;
28
+ //#endregion
29
+ export { parseCodeBlockAttributes as i, CodeBlockTabsOptions as n, generateCodeBlockTabs as r, CodeBlockAttributes as t };
@@ -0,0 +1,41 @@
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 customize this.
38
+ */
39
+ declare function getGithubLastEdit({ repo, token, owner, path, sha, baseUrl, options, params: customParams }: GetGithubLastCommitOptions): Promise<Date | null>;
40
+ //#endregion
41
+ export { GetGithubLastCommitOptions, getGithubLastEdit };