fumadocs-core 16.4.1 → 16.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/dist/advanced-DSlc7qa9.js +80 -0
  2. package/dist/advanced-DSlc7qa9.js.map +1 -0
  3. package/dist/algolia-BGWM-DkQ.js +49 -0
  4. package/dist/algolia-BGWM-DkQ.js.map +1 -0
  5. package/dist/algolia-FqjcaTcD.d.ts +68 -0
  6. package/dist/algolia-FqjcaTcD.d.ts.map +1 -0
  7. package/dist/breadcrumb.d.ts +29 -27
  8. package/dist/breadcrumb.d.ts.map +1 -0
  9. package/dist/breadcrumb.js +55 -72
  10. package/dist/breadcrumb.js.map +1 -0
  11. package/dist/chunk-C1JLJEPO.js +42 -0
  12. package/dist/codeblock-utils-Dh1w8ICD.d.ts +37 -0
  13. package/dist/codeblock-utils-Dh1w8ICD.d.ts.map +1 -0
  14. package/dist/content/github.d.ts +43 -32
  15. package/dist/content/github.d.ts.map +1 -0
  16. package/dist/content/github.js +29 -43
  17. package/dist/content/github.js.map +1 -0
  18. package/dist/content/index.d.ts +20 -13
  19. package/dist/content/index.d.ts.map +1 -0
  20. package/dist/content/index.js +17 -23
  21. package/dist/content/index.js.map +1 -0
  22. package/dist/content/mdx/preset-bundler.d.ts +22 -24
  23. package/dist/content/mdx/preset-bundler.d.ts.map +1 -0
  24. package/dist/content/mdx/preset-bundler.js +38 -69
  25. package/dist/content/mdx/preset-bundler.js.map +1 -0
  26. package/dist/content/mdx/preset-runtime.d.ts +22 -24
  27. package/dist/content/mdx/preset-runtime.d.ts.map +1 -0
  28. package/dist/content/mdx/preset-runtime.js +36 -68
  29. package/dist/content/mdx/preset-runtime.js.map +1 -0
  30. package/dist/content/toc.d.ts +7 -6
  31. package/dist/content/toc.d.ts.map +1 -0
  32. package/dist/content/toc.js +15 -19
  33. package/dist/content/toc.js.map +1 -0
  34. package/dist/definitions-DJAPG-2U.d.ts +62 -0
  35. package/dist/definitions-DJAPG-2U.d.ts.map +1 -0
  36. package/dist/dynamic-link.d.ts +7 -5
  37. package/dist/dynamic-link.d.ts.map +1 -0
  38. package/dist/dynamic-link.js +29 -27
  39. package/dist/dynamic-link.js.map +1 -0
  40. package/dist/fetch-B1nmMSyw.js +20 -0
  41. package/dist/fetch-B1nmMSyw.js.map +1 -0
  42. package/dist/framework/index.d.ts +38 -29
  43. package/dist/framework/index.d.ts.map +1 -0
  44. package/dist/framework/index.js +68 -17
  45. package/dist/framework/index.js.map +1 -0
  46. package/dist/framework/next.d.ts +15 -10
  47. package/dist/framework/next.d.ts.map +1 -0
  48. package/dist/framework/next.js +18 -26
  49. package/dist/framework/next.js.map +1 -0
  50. package/dist/framework/react-router.d.ts +15 -10
  51. package/dist/framework/react-router.d.ts.map +1 -0
  52. package/dist/framework/react-router.js +42 -55
  53. package/dist/framework/react-router.js.map +1 -0
  54. package/dist/framework/tanstack.d.ts +15 -10
  55. package/dist/framework/tanstack.d.ts.map +1 -0
  56. package/dist/framework/tanstack.js +54 -69
  57. package/dist/framework/tanstack.js.map +1 -0
  58. package/dist/framework/waku.d.ts +15 -10
  59. package/dist/framework/waku.d.ts.map +1 -0
  60. package/dist/framework/waku.js +47 -58
  61. package/dist/framework/waku.js.map +1 -0
  62. package/dist/highlight/client.d.ts +6 -7
  63. package/dist/highlight/client.d.ts.map +1 -0
  64. package/dist/highlight/client.js +22 -14
  65. package/dist/highlight/client.js.map +1 -0
  66. package/dist/highlight/index.d.ts +2 -30
  67. package/dist/highlight/index.js +3 -13
  68. package/dist/i18n/index.d.ts +2 -39
  69. package/dist/i18n/index.js +6 -7
  70. package/dist/i18n/index.js.map +1 -0
  71. package/dist/i18n/middleware.d.ts +36 -28
  72. package/dist/i18n/middleware.d.ts.map +1 -0
  73. package/dist/i18n/middleware.js +55 -73
  74. package/dist/i18n/middleware.js.map +1 -0
  75. package/dist/icon-5lVe3l-0.js +19 -0
  76. package/dist/icon-5lVe3l-0.js.map +1 -0
  77. package/dist/index-BhVrX5J1.d.ts +41 -0
  78. package/dist/index-BhVrX5J1.d.ts.map +1 -0
  79. package/dist/index-Co_C8NEi.d.ts +380 -0
  80. package/dist/index-Co_C8NEi.d.ts.map +1 -0
  81. package/dist/link.d.ts +17 -15
  82. package/dist/link.d.ts.map +1 -0
  83. package/dist/link.js +29 -9
  84. package/dist/link.js.map +1 -0
  85. package/dist/mdast-utils-ix4DsXJP.js +40 -0
  86. package/dist/mdast-utils-ix4DsXJP.js.map +1 -0
  87. package/dist/mdx-plugins/codeblock-utils.d.ts +2 -29
  88. package/dist/mdx-plugins/codeblock-utils.js +71 -9
  89. package/dist/mdx-plugins/codeblock-utils.js.map +1 -0
  90. package/dist/mdx-plugins/index.d.ts +15 -20
  91. package/dist/mdx-plugins/index.js +18 -73
  92. package/dist/mdx-plugins/rehype-code.d.ts +2 -55
  93. package/dist/mdx-plugins/rehype-code.js +5 -15
  94. package/dist/mdx-plugins/rehype-toc.d.ts +2 -14
  95. package/dist/mdx-plugins/rehype-toc.js +3 -7
  96. package/dist/mdx-plugins/remark-admonition.d.ts +2 -20
  97. package/dist/mdx-plugins/remark-admonition.js +74 -8
  98. package/dist/mdx-plugins/remark-admonition.js.map +1 -0
  99. package/dist/mdx-plugins/remark-code-tab.d.ts +2 -30
  100. package/dist/mdx-plugins/remark-code-tab.js +183 -7
  101. package/dist/mdx-plugins/remark-code-tab.js.map +1 -0
  102. package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -27
  103. package/dist/mdx-plugins/remark-directive-admonition.js +60 -7
  104. package/dist/mdx-plugins/remark-directive-admonition.js.map +1 -0
  105. package/dist/mdx-plugins/remark-gfm.d.ts +2 -1
  106. package/dist/mdx-plugins/remark-gfm.js +3 -7
  107. package/dist/mdx-plugins/remark-heading.d.ts +2 -31
  108. package/dist/mdx-plugins/remark-heading.js +45 -8
  109. package/dist/mdx-plugins/remark-heading.js.map +1 -0
  110. package/dist/mdx-plugins/remark-image.d.ts +2 -57
  111. package/dist/mdx-plugins/remark-image.js +192 -7
  112. package/dist/mdx-plugins/remark-image.js.map +1 -0
  113. package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -40
  114. package/dist/mdx-plugins/remark-mdx-files.js +187 -7
  115. package/dist/mdx-plugins/remark-mdx-files.js.map +1 -0
  116. package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -15
  117. package/dist/mdx-plugins/remark-mdx-mermaid.js +31 -7
  118. package/dist/mdx-plugins/remark-mdx-mermaid.js.map +1 -0
  119. package/dist/mdx-plugins/remark-npm.d.ts +2 -31
  120. package/dist/mdx-plugins/remark-npm.js +68 -8
  121. package/dist/mdx-plugins/remark-npm.js.map +1 -0
  122. package/dist/mdx-plugins/remark-steps.d.ts +2 -23
  123. package/dist/mdx-plugins/remark-steps.js +77 -7
  124. package/dist/mdx-plugins/remark-steps.js.map +1 -0
  125. package/dist/mdx-plugins/remark-structure.d.ts +2 -71
  126. package/dist/mdx-plugins/remark-structure.js +105 -11
  127. package/dist/mdx-plugins/remark-structure.js.map +1 -0
  128. package/dist/mixedbread-DSiQfUnN.js +88 -0
  129. package/dist/mixedbread-DSiQfUnN.js.map +1 -0
  130. package/dist/negotiation/index.d.ts +6 -4
  131. package/dist/negotiation/index.d.ts.map +1 -0
  132. package/dist/negotiation/index.js +41 -11
  133. package/dist/negotiation/index.js.map +1 -0
  134. package/dist/normalize-url-3WQZ_H_j.js +16 -0
  135. package/dist/normalize-url-3WQZ_H_j.js.map +1 -0
  136. package/dist/orama-cloud-BMDBfk05.js +84 -0
  137. package/dist/orama-cloud-BMDBfk05.js.map +1 -0
  138. package/dist/orama-cloud-legacy-CRZzZXWn.js +82 -0
  139. package/dist/orama-cloud-legacy-CRZzZXWn.js.map +1 -0
  140. package/dist/page-tree/index.d.ts +23 -11
  141. package/dist/page-tree/index.d.ts.map +1 -0
  142. package/dist/page-tree/index.js +3 -17
  143. package/dist/path-D6M0ZQvO.js +60 -0
  144. package/dist/path-D6M0ZQvO.js.map +1 -0
  145. package/dist/rehype-code-Bd52chOe.d.ts +58 -0
  146. package/dist/rehype-code-Bd52chOe.d.ts.map +1 -0
  147. package/dist/rehype-code-Dr35mETC.js +241 -0
  148. package/dist/rehype-code-Dr35mETC.js.map +1 -0
  149. package/dist/rehype-toc-BJVsblvp.d.ts +18 -0
  150. package/dist/rehype-toc-BJVsblvp.d.ts.map +1 -0
  151. package/dist/rehype-toc-Dqgey2tW.js +143 -0
  152. package/dist/rehype-toc-Dqgey2tW.js.map +1 -0
  153. package/dist/remark-admonition-Chku_iWO.d.ts +22 -0
  154. package/dist/remark-admonition-Chku_iWO.d.ts.map +1 -0
  155. package/dist/remark-code-tab-C0f6BPcw.d.ts +32 -0
  156. package/dist/remark-code-tab-C0f6BPcw.d.ts.map +1 -0
  157. package/dist/remark-directive-admonition-CBwJdh9z.d.ts +36 -0
  158. package/dist/remark-directive-admonition-CBwJdh9z.d.ts.map +1 -0
  159. package/dist/remark-gfm-B2aZXutO.d.ts +2 -0
  160. package/dist/remark-heading-CUAe4zIu.d.ts +37 -0
  161. package/dist/remark-heading-CUAe4zIu.d.ts.map +1 -0
  162. package/dist/remark-image-DMRnxsRO.d.ts +65 -0
  163. package/dist/remark-image-DMRnxsRO.d.ts.map +1 -0
  164. package/dist/remark-mdx-files-B5KMXnfh.d.ts +56 -0
  165. package/dist/remark-mdx-files-B5KMXnfh.d.ts.map +1 -0
  166. package/dist/remark-mdx-mermaid-C_4W5gfj.d.ts +17 -0
  167. package/dist/remark-mdx-mermaid-C_4W5gfj.d.ts.map +1 -0
  168. package/dist/remark-npm-CykFgJn2.d.ts +36 -0
  169. package/dist/remark-npm-CykFgJn2.d.ts.map +1 -0
  170. package/dist/remark-steps-5-DmLVv3.d.ts +28 -0
  171. package/dist/remark-steps-5-DmLVv3.d.ts.map +1 -0
  172. package/dist/remark-structure-CszwnaMR.d.ts +77 -0
  173. package/dist/remark-structure-CszwnaMR.d.ts.map +1 -0
  174. package/dist/remove-undefined-B7zJF-YS.js +19 -0
  175. package/dist/remove-undefined-B7zJF-YS.js.map +1 -0
  176. package/dist/search/algolia.d.ts +3 -69
  177. package/dist/search/algolia.js +69 -63
  178. package/dist/search/algolia.js.map +1 -0
  179. package/dist/search/client.d.ts +143 -114
  180. package/dist/search/client.d.ts.map +1 -0
  181. package/dist/search/client.js +98 -91
  182. package/dist/search/client.js.map +1 -0
  183. package/dist/search/index.d.ts +20 -18
  184. package/dist/search/index.d.ts.map +1 -0
  185. package/dist/search/index.js +3 -7
  186. package/dist/search/orama-cloud-legacy.d.ts +81 -0
  187. package/dist/search/orama-cloud-legacy.d.ts.map +1 -0
  188. package/dist/search/orama-cloud-legacy.js +50 -0
  189. package/dist/search/orama-cloud-legacy.js.map +1 -0
  190. package/dist/search/orama-cloud.d.ts +72 -70
  191. package/dist/search/orama-cloud.d.ts.map +1 -0
  192. package/dist/search/orama-cloud.js +46 -54
  193. package/dist/search/orama-cloud.js.map +1 -0
  194. package/dist/search/server.d.ts +6 -136
  195. package/dist/search/server.js +292 -369
  196. package/dist/search/server.js.map +1 -0
  197. package/dist/search-DcH54N2x.js +44 -0
  198. package/dist/search-DcH54N2x.js.map +1 -0
  199. package/dist/server-BzFuYBxW.d.ts +133 -0
  200. package/dist/server-BzFuYBxW.d.ts.map +1 -0
  201. package/dist/shiki-Bdk0JGsB.d.ts +33 -0
  202. package/dist/shiki-Bdk0JGsB.d.ts.map +1 -0
  203. package/dist/shiki-DoHr6fEj.js +80 -0
  204. package/dist/shiki-DoHr6fEj.js.map +1 -0
  205. package/dist/source/client/index.d.ts +7 -5
  206. package/dist/source/client/index.d.ts.map +1 -0
  207. package/dist/source/client/index.js +24 -35
  208. package/dist/source/client/index.js.map +1 -0
  209. package/dist/source/index.d.ts +3 -42
  210. package/dist/source/index.js +599 -752
  211. package/dist/source/index.js.map +1 -0
  212. package/dist/source/plugins/lucide-icons.d.ts +7 -7
  213. package/dist/source/plugins/lucide-icons.d.ts.map +1 -0
  214. package/dist/source/plugins/lucide-icons.js +21 -20
  215. package/dist/source/plugins/lucide-icons.js.map +1 -0
  216. package/dist/source/plugins/slugs.d.ts +3 -0
  217. package/dist/source/plugins/slugs.js +65 -0
  218. package/dist/source/plugins/slugs.js.map +1 -0
  219. package/dist/source/schema.d.ts +17 -14
  220. package/dist/source/schema.d.ts.map +1 -0
  221. package/dist/source/schema.js +26 -22
  222. package/dist/source/schema.js.map +1 -0
  223. package/dist/static-DAjBQpus.js +51 -0
  224. package/dist/static-DAjBQpus.js.map +1 -0
  225. package/dist/toc.d.ts +38 -25
  226. package/dist/toc.d.ts.map +1 -0
  227. package/dist/toc.js +123 -136
  228. package/dist/toc.js.map +1 -0
  229. package/dist/util-92szu3Vf.js +10 -0
  230. package/dist/util-92szu3Vf.js.map +1 -0
  231. package/dist/util-ofJFdM-e.d.ts +8 -0
  232. package/dist/util-ofJFdM-e.d.ts.map +1 -0
  233. package/dist/utils/use-effect-event.d.ts +3 -1
  234. package/dist/utils/use-effect-event.d.ts.map +1 -0
  235. package/dist/utils/use-effect-event.js +16 -13
  236. package/dist/utils/use-effect-event.js.map +1 -0
  237. package/dist/utils/use-media-query.d.ts +3 -1
  238. package/dist/utils/use-media-query.d.ts.map +1 -0
  239. package/dist/utils/use-media-query.js +20 -20
  240. package/dist/utils/use-media-query.js.map +1 -0
  241. package/dist/utils/use-on-change.d.ts +3 -1
  242. package/dist/utils/use-on-change.d.ts.map +1 -0
  243. package/dist/utils/use-on-change.js +23 -7
  244. package/dist/utils/use-on-change.js.map +1 -0
  245. package/dist/utils-bAoAH1Rh.js +134 -0
  246. package/dist/utils-bAoAH1Rh.js.map +1 -0
  247. package/package.json +72 -65
  248. package/dist/algolia-IZEDLPHE.js +0 -58
  249. package/dist/chunk-5PMI7QDD.js +0 -220
  250. package/dist/chunk-ADBHPKXG.js +0 -78
  251. package/dist/chunk-APKPSBSB.js +0 -74
  252. package/dist/chunk-CH7YHH7V.js +0 -222
  253. package/dist/chunk-EFVXL2PP.js +0 -144
  254. package/dist/chunk-EMWGTXSW.js +0 -19
  255. package/dist/chunk-FAEPKD7U.js +0 -20
  256. package/dist/chunk-FUUVPEA5.js +0 -29
  257. package/dist/chunk-GINBKBVQ.js +0 -12
  258. package/dist/chunk-GLRQBLGN.js +0 -59
  259. package/dist/chunk-JUF4WZ6G.js +0 -117
  260. package/dist/chunk-K4WNLOVQ.js +0 -75
  261. package/dist/chunk-L4JKQWCM.js +0 -131
  262. package/dist/chunk-MA6O2UUE.js +0 -50
  263. package/dist/chunk-ONG4RVCR.js +0 -8
  264. package/dist/chunk-OTD7MV33.js +0 -53
  265. package/dist/chunk-PFNP6PEB.js +0 -11
  266. package/dist/chunk-SH7BNTG7.js +0 -38
  267. package/dist/chunk-TWIDBWFG.js +0 -84
  268. package/dist/chunk-U67V476Y.js +0 -35
  269. package/dist/chunk-VLSDGCJE.js +0 -47
  270. package/dist/chunk-W6WTLKRA.js +0 -73
  271. package/dist/chunk-X2HFD5QJ.js +0 -275
  272. package/dist/chunk-XJ6ZQNEX.js +0 -91
  273. package/dist/chunk-XN2LKXFZ.js +0 -101
  274. package/dist/chunk-XOFXGHS4.js +0 -93
  275. package/dist/chunk-XZSI7AHE.js +0 -67
  276. package/dist/chunk-YVVDKJ2H.js +0 -34
  277. package/dist/chunk-ZMWYLUDP.js +0 -21
  278. package/dist/definitions-pJ7PybYY.d.ts +0 -60
  279. package/dist/fetch-IBTWQCJR.js +0 -22
  280. package/dist/loader-_E2HOdV0.d.ts +0 -333
  281. package/dist/mixedbread-A3WLENES.js +0 -117
  282. package/dist/orama-cloud-UZAPMPFV.js +0 -93
  283. package/dist/static-A2YJ5TXV.js +0 -62
  284. package/dist/util-bZU2QeJ2.d.ts +0 -6
@@ -1,21 +0,0 @@
1
- // src/utils/remove-undefined.ts
2
- function removeUndefined(value, deep = false) {
3
- const obj = value;
4
- for (const key in obj) {
5
- if (obj[key] === void 0) delete obj[key];
6
- if (!deep) continue;
7
- const entry = obj[key];
8
- if (typeof entry === "object" && entry !== null) {
9
- removeUndefined(entry, deep);
10
- continue;
11
- }
12
- if (Array.isArray(entry)) {
13
- for (const item of entry) removeUndefined(item, deep);
14
- }
15
- }
16
- return value;
17
- }
18
-
19
- export {
20
- removeUndefined
21
- };
@@ -1,60 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- interface ID {
4
- /**
5
- * ID for the node, unique in all page trees (even across different locales)
6
- */
7
- $id?: string;
8
- }
9
- interface Root extends ID {
10
- name: ReactNode;
11
- children: Node[];
12
- /**
13
- * Another page tree that won't be displayed unless being opened.
14
- */
15
- fallback?: Root;
16
- }
17
- type Node = Item | Separator | Folder;
18
- interface Item extends ID {
19
- /**
20
- * @internal
21
- */
22
- $ref?: {
23
- file: string;
24
- };
25
- type: 'page';
26
- name: ReactNode;
27
- url: string;
28
- /**
29
- * Whether the link should be treated as external (e.g. use HTML <a> tag).
30
- *
31
- * When unspecified, it depends on the value of `url`.
32
- */
33
- external?: boolean;
34
- description?: ReactNode;
35
- icon?: ReactNode;
36
- }
37
- interface Separator extends ID {
38
- type: 'separator';
39
- name?: ReactNode;
40
- icon?: ReactNode;
41
- }
42
- interface Folder extends ID {
43
- /**
44
- * @internal
45
- */
46
- $ref?: {
47
- metaFile?: string;
48
- };
49
- type: 'folder';
50
- name: ReactNode;
51
- description?: ReactNode;
52
- root?: boolean;
53
- defaultOpen?: boolean;
54
- collapsible?: boolean;
55
- index?: Item;
56
- icon?: ReactNode;
57
- children: Node[];
58
- }
59
-
60
- export type { Folder as F, Item as I, Node as N, Root as R, Separator as S };
@@ -1,22 +0,0 @@
1
- import "./chunk-U67V476Y.js";
2
-
3
- // src/search/client/fetch.ts
4
- var cache = /* @__PURE__ */ new Map();
5
- async function fetchDocs(query, { api = "/api/search", locale, tag }) {
6
- const url = new URL(api, window.location.origin);
7
- url.searchParams.set("query", query);
8
- if (locale) url.searchParams.set("locale", locale);
9
- if (tag)
10
- url.searchParams.set("tag", Array.isArray(tag) ? tag.join(",") : tag);
11
- const key = url.toString();
12
- const cached = cache.get(key);
13
- if (cached) return cached;
14
- const res = await fetch(url);
15
- if (!res.ok) throw new Error(await res.text());
16
- const result = await res.json();
17
- cache.set(key, result);
18
- return result;
19
- }
20
- export {
21
- fetchDocs
22
- };
@@ -1,333 +0,0 @@
1
- import { R as Root, I as Item, F as Folder, S as Separator } from './definitions-pJ7PybYY.js';
2
- import { I18nConfig } from './i18n/index.js';
3
- import { ReactNode } from 'react';
4
-
5
- interface Source<Config extends SourceConfig = SourceConfig> {
6
- files: VirtualFile<Config>[];
7
- }
8
- interface SourceConfig {
9
- pageData: PageData;
10
- metaData: MetaData;
11
- }
12
- interface MetaData {
13
- icon?: string | undefined;
14
- title?: string | undefined;
15
- root?: boolean | undefined;
16
- pages?: string[] | undefined;
17
- defaultOpen?: boolean | undefined;
18
- collapsible?: boolean | undefined;
19
- description?: string | undefined;
20
- }
21
- interface PageData {
22
- icon?: string | undefined;
23
- title?: string;
24
- description?: string | undefined;
25
- }
26
- type VirtualFile<Config extends SourceConfig = SourceConfig> = VirtualPage<Config['pageData']> | VirtualMeta<Config['metaData']>;
27
- interface BaseVirtualFile {
28
- /**
29
- * Virtualized path (relative to content directory)
30
- *
31
- * @example `docs/page.mdx`
32
- */
33
- path: string;
34
- /**
35
- * Absolute path of the file
36
- */
37
- absolutePath?: string;
38
- }
39
- interface VirtualPage<Data extends PageData> extends BaseVirtualFile {
40
- type: 'page';
41
- /**
42
- * Specified Slugs for page
43
- */
44
- slugs?: string[];
45
- data: Data;
46
- }
47
- interface VirtualMeta<Data extends MetaData> extends BaseVirtualFile {
48
- type: 'meta';
49
- data: Data;
50
- }
51
- type _ConfigUnion_<T extends Record<string, Source>> = {
52
- [K in keyof T]: T[K] extends Source<infer Config> ? {
53
- pageData: Config['pageData'] & {
54
- type: K;
55
- };
56
- metaData: Config['metaData'] & {
57
- type: K;
58
- };
59
- } : never;
60
- }[keyof T];
61
- declare function multiple<T extends Record<string, Source>>(sources: T): Source<_ConfigUnion_<T>>;
62
- declare function source<Page extends PageData, Meta extends MetaData>(config: {
63
- pages: VirtualPage<Page>[];
64
- metas: VirtualMeta<Meta>[];
65
- }): Source<{
66
- pageData: Page;
67
- metaData: Meta;
68
- }>;
69
- /**
70
- * update a source object in-place.
71
- */
72
- declare function update<Config extends SourceConfig>(source: Source<Config>): {
73
- files<Page extends PageData, Meta extends MetaData>(fn: (files: VirtualFile<Config>[]) => (VirtualPage<Page> | VirtualMeta<Meta>)[]): typeof update<{
74
- pageData: Page;
75
- metaData: Meta;
76
- }>;
77
- page<V extends PageData>(fn: (page: VirtualPage<Config["pageData"]>) => VirtualPage<V>): typeof update<{
78
- pageData: V;
79
- metaData: Config["metaData"];
80
- }>;
81
- meta<V extends MetaData>(fn: (meta: VirtualMeta<Config["metaData"]>) => VirtualMeta<V>): typeof update<{
82
- pageData: Config["pageData"];
83
- metaData: V;
84
- }>;
85
- build(): Source<Config>;
86
- };
87
-
88
- /**
89
- * In memory file system.
90
- */
91
- declare class FileSystem<File> {
92
- files: Map<string, File>;
93
- folders: Map<string, string[]>;
94
- constructor(inherit?: FileSystem<File>);
95
- read(path: string): File | undefined;
96
- /**
97
- * get the direct children of folder (in virtual file path)
98
- */
99
- readDir(path: string): string[] | undefined;
100
- write(path: string, file: File): void;
101
- /**
102
- * Delete files at specified path.
103
- *
104
- * @param path - the target path.
105
- * @param [recursive=false] - if set to `true`, it will also delete directories.
106
- */
107
- delete(path: string, recursive?: boolean): boolean;
108
- getFiles(): string[];
109
- makeDir(path: string): void;
110
- }
111
-
112
- type ContentStorage<Config extends SourceConfig = SourceConfig> = FileSystem<ContentStorageFile<Config>>;
113
- type ContentStorageFile<Config extends SourceConfig = SourceConfig> = {
114
- path: string;
115
- absolutePath?: string;
116
- format: 'meta';
117
- data: Config['metaData'];
118
- } | {
119
- path: string;
120
- absolutePath?: string;
121
- format: 'page';
122
- slugs: string[];
123
- data: Config['pageData'];
124
- };
125
- /**
126
- * @param defaultLanguage - language to use when i18n is not configured.
127
- * @returns a map of locale and its content storage.
128
- *
129
- * in the storage, locale codes are removed from file paths, hence the same file will have same file paths in every storage.
130
- */
131
- declare function buildContentStorage(loaderConfig: ResolvedLoaderConfig, defaultLanguage: string): Record<string, ContentStorage>;
132
-
133
- interface PageTreeBuilderContext<Config extends SourceConfig = SourceConfig> {
134
- rootId: string;
135
- generateNodeId: () => string;
136
- options: PageTreeOptions;
137
- transformers: PageTreeTransformer<Config>[];
138
- builder: PageTreeBuilder;
139
- storage: ContentStorage<Config>;
140
- getUrl: ResolvedLoaderConfig['url'];
141
- storages?: Record<string, ContentStorage<Config>>;
142
- locale?: string;
143
- }
144
- interface PageTreeTransformer<Config extends SourceConfig = SourceConfig> {
145
- file?: (this: PageTreeBuilderContext<Config>, node: Item, filePath?: string) => Item;
146
- folder?: (this: PageTreeBuilderContext<Config>, node: Folder, folderPath: string, metaPath?: string) => Folder;
147
- separator?: (this: PageTreeBuilderContext<Config>, node: Separator) => Separator;
148
- root?: (this: PageTreeBuilderContext<Config>, node: Root) => Root;
149
- }
150
- interface PageTreeOptions<Config extends LoaderConfig = LoaderConfig> {
151
- id?: string;
152
- /**
153
- * Remove references to the file path of original nodes (`$ref`)
154
- *
155
- * @defaultValue false
156
- */
157
- noRef?: boolean;
158
- /**
159
- * generate fallback page tree
160
- *
161
- * @defaultValue true
162
- */
163
- generateFallback?: boolean;
164
- /**
165
- * Additional page tree transformers to apply
166
- */
167
- transformers?: PageTreeTransformer<Config['source']>[];
168
- }
169
- interface PageTreeBuilder {
170
- build: (storage: ContentStorage, options?: PageTreeOptions) => Root;
171
- buildI18n: (storages: Record<string, ContentStorage>, options?: PageTreeOptions) => Record<string, Root>;
172
- }
173
- declare function createPageTreeBuilder(loaderConfig: ResolvedLoaderConfig): PageTreeBuilder;
174
-
175
- interface LoaderPlugin<Config extends LoaderConfig = LoaderConfig> {
176
- name?: string;
177
- /**
178
- * Change the order of plugin:
179
- * - `pre`: before normal plugins
180
- * - `post`: after normal plugins
181
- */
182
- enforce?: 'pre' | 'post';
183
- /**
184
- * receive & replace loader options
185
- */
186
- config?: (config: ResolvedLoaderConfig) => ResolvedLoaderConfig | void | undefined;
187
- /**
188
- * transform the storage after loading
189
- */
190
- transformStorage?: (context: {
191
- storage: ContentStorage<Config['source']>;
192
- }) => void;
193
- /**
194
- * transform the generated page tree
195
- */
196
- transformPageTree?: PageTreeTransformer<Config['source']>;
197
- }
198
- type LoaderPluginOption<Config extends LoaderConfig = LoaderConfig> = LoaderPlugin<Config> | LoaderPluginOption<Config>[] | undefined;
199
- declare function buildPlugins(plugins: LoaderPluginOption[], sort?: boolean): LoaderPlugin[];
200
-
201
- type IconResolver = (icon: string | undefined) => ReactNode;
202
-
203
- interface LoaderConfig {
204
- source: SourceConfig;
205
- i18n: I18nConfig | undefined;
206
- }
207
- interface LoaderOptions<C extends LoaderConfig = LoaderConfig> {
208
- baseUrl: string;
209
- i18n?: C['i18n'];
210
- url?: (slugs: string[], locale?: string) => string;
211
- /**
212
- * Additional options for page tree builder
213
- */
214
- pageTree?: PageTreeOptions<C>;
215
- plugins?: LoaderPluginOption[] | ((context: {
216
- typedPlugin: (plugin: LoaderPlugin<C>) => LoaderPlugin;
217
- }) => LoaderPluginOption[]);
218
- icon?: IconResolver;
219
- slugs?: (info: {
220
- path: string;
221
- }) => string[];
222
- }
223
- interface ResolvedLoaderConfig {
224
- source: Source;
225
- url: (slugs: string[], locale?: string) => string;
226
- plugins?: LoaderPlugin[];
227
- pageTree?: PageTreeOptions;
228
- i18n?: I18nConfig | undefined;
229
- }
230
- interface SharedFileInfo {
231
- /**
232
- * Virtualized file path (relative to content directory)
233
- *
234
- * @example `docs/page.mdx`
235
- */
236
- path: string;
237
- /**
238
- * Absolute path of the file
239
- */
240
- absolutePath?: string;
241
- }
242
- interface Page<Data = PageData> extends SharedFileInfo {
243
- slugs: string[];
244
- url: string;
245
- data: Data;
246
- locale?: string | undefined;
247
- }
248
- interface Meta<Data = MetaData> extends SharedFileInfo {
249
- data: Data;
250
- }
251
- interface LoaderOutput<Config extends LoaderConfig> {
252
- pageTree: Config['i18n'] extends I18nConfig ? Record<string, Root> : Root;
253
- getPageTree: (locale?: string) => Root;
254
- /**
255
- * get referenced page from href, supported:
256
- *
257
- * - relative file paths, like `./my/page.mdx`.
258
- * - generated page pathname, like `/docs/my/page`.
259
- */
260
- getPageByHref: (href: string, options?: {
261
- language?: string;
262
- /**
263
- * resolve relative file paths in `href` from specified dirname, must be a virtual path.
264
- */
265
- dir?: string;
266
- }) => {
267
- page: Page<Config['source']['pageData']>;
268
- hash?: string;
269
- } | undefined;
270
- /**
271
- * resolve special hrefs in a page, including:
272
- *
273
- * - relative file paths, like `./my/page.mdx`.
274
- */
275
- resolveHref: (href: string, parent: Page<Config['source']['pageData']>) => string;
276
- /**
277
- * @internal
278
- */
279
- _i18n?: I18nConfig;
280
- /**
281
- * Get a list of pages from specified language
282
- *
283
- * @param language - If empty, list pages from all languages.
284
- */
285
- getPages: (language?: string) => Page<Config['source']['pageData']>[];
286
- /**
287
- * get each language and its pages, empty if i18n is not enabled.
288
- */
289
- getLanguages: () => {
290
- language: string;
291
- pages: Page<Config['source']['pageData']>[];
292
- }[];
293
- /**
294
- * Get page with slugs, the slugs can also be URI encoded.
295
- *
296
- * @param language - If empty, the default language will be used
297
- */
298
- getPage: (slugs: string[] | undefined, language?: string) => Page<Config['source']['pageData']> | undefined;
299
- getNodePage: (node: Item, language?: string) => Page<Config['source']['pageData']> | undefined;
300
- getNodeMeta: (node: Folder, language?: string) => Meta<Config['source']['metaData']> | undefined;
301
- /**
302
- * generate static params for Next.js SSG
303
- *
304
- * @param slug - customise parameter name for slugs
305
- * @param lang - customise parameter name for lang
306
- */
307
- generateParams: <TSlug extends string = 'slug', TLang extends string = 'lang'>(slug?: TSlug, lang?: TLang) => (Record<TSlug, string[]> & Record<TLang, string>)[];
308
- /**
309
- * serialize page tree for non-RSC environments
310
- */
311
- serializePageTree: (tree: Root) => Promise<object>;
312
- }
313
- declare function createGetUrl(baseUrl: string, i18n?: I18nConfig): ResolvedLoaderConfig['url'];
314
- declare function loader<Config extends SourceConfig, I18n extends I18nConfig | undefined = undefined>(source: Source<Config>, options: LoaderOptions<{
315
- source: NoInfer<Config>;
316
- i18n: I18n;
317
- }>): LoaderOutput<{
318
- source: Config;
319
- i18n: I18n;
320
- }>;
321
- declare function loader<Config extends SourceConfig, I18n extends I18nConfig | undefined = undefined>(options: LoaderOptions<{
322
- source: NoInfer<Config>;
323
- i18n: I18n;
324
- }> & {
325
- source: Source<Config>;
326
- }): LoaderOutput<{
327
- source: Config;
328
- i18n: I18n;
329
- }>;
330
- type InferPageType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput<infer Config> ? Page<Config['source']['pageData']> : never;
331
- type InferMetaType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput<infer Config> ? Meta<Config['source']['metaData']> : never;
332
-
333
- export { type ContentStorage as C, FileSystem as F, type InferPageType as I, type LoaderPlugin as L, type MetaData as M, type PageData as P, type ResolvedLoaderConfig as R, type Source as S, type VirtualFile as V, type _ConfigUnion_ as _, type SourceConfig as a, type LoaderConfig as b, type LoaderOptions as c, type Page as d, type Meta as e, type LoaderOutput as f, createGetUrl as g, type InferMetaType as h, type PageTreeBuilderContext as i, type PageTreeTransformer as j, type PageTreeOptions as k, loader as l, multiple as m, type PageTreeBuilder as n, createPageTreeBuilder as o, type ContentStorageFile as p, buildContentStorage as q, type LoaderPluginOption as r, source as s, buildPlugins as t, update as u };
@@ -1,117 +0,0 @@
1
- import {
2
- __commonJS,
3
- __toESM
4
- } from "./chunk-U67V476Y.js";
5
-
6
- // ../../node_modules/.pnpm/remove-markdown@0.6.2/node_modules/remove-markdown/index.js
7
- var require_remove_markdown = __commonJS({
8
- "../../node_modules/.pnpm/remove-markdown@0.6.2/node_modules/remove-markdown/index.js"(exports, module) {
9
- "use strict";
10
- module.exports = function(md, options) {
11
- options = options || {};
12
- options.listUnicodeChar = options.hasOwnProperty("listUnicodeChar") ? options.listUnicodeChar : false;
13
- options.stripListLeaders = options.hasOwnProperty("stripListLeaders") ? options.stripListLeaders : true;
14
- options.gfm = options.hasOwnProperty("gfm") ? options.gfm : true;
15
- options.useImgAltText = options.hasOwnProperty("useImgAltText") ? options.useImgAltText : true;
16
- options.abbr = options.hasOwnProperty("abbr") ? options.abbr : false;
17
- options.replaceLinksWithURL = options.hasOwnProperty("replaceLinksWithURL") ? options.replaceLinksWithURL : false;
18
- options.htmlTagsToSkip = options.hasOwnProperty("htmlTagsToSkip") ? options.htmlTagsToSkip : [];
19
- options.throwError = options.hasOwnProperty("throwError") ? options.throwError : false;
20
- var output = md || "";
21
- output = output.replace(/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/gm, "");
22
- try {
23
- if (options.stripListLeaders) {
24
- if (options.listUnicodeChar)
25
- output = output.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm, options.listUnicodeChar + " $1");
26
- else
27
- output = output.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm, "$1");
28
- }
29
- if (options.gfm) {
30
- output = output.replace(/\n={2,}/g, "\n").replace(/~{3}.*\n/g, "").replace(/~~/g, "").replace(/```(?:.*)\n([\s\S]*?)```/g, (_, code) => code.trim());
31
- }
32
- if (options.abbr) {
33
- output = output.replace(/\*\[.*\]:.*\n/, "");
34
- }
35
- let htmlReplaceRegex = /<[^>]*>/g;
36
- if (options.htmlTagsToSkip && options.htmlTagsToSkip.length > 0) {
37
- const joinedHtmlTagsToSkip = options.htmlTagsToSkip.join("|");
38
- htmlReplaceRegex = new RegExp(
39
- `<(?!/?(${joinedHtmlTagsToSkip})(?=>|s[^>]*>))[^>]*>`,
40
- "g"
41
- );
42
- }
43
- output = output.replace(htmlReplaceRegex, "").replace(/^[=\-]{2,}\s*$/g, "").replace(/\[\^.+?\](\: .*?$)?/g, "").replace(/\s{0,2}\[.*?\]: .*?$/g, "").replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? "$1" : "").replace(/\[([\s\S]*?)\]\s*[\(\[].*?[\)\]]/g, options.replaceLinksWithURL ? "$2" : "$1").replace(/^(\n)?\s{0,3}>\s?/gm, "$1").replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, "").replace(/^(\n)?\s{0,}#{1,6}\s*( (.+))? +#+$|^(\n)?\s{0,}#{1,6}\s*( (.+))?$/gm, "$1$3$4$6").replace(/([\*]+)(\S)(.*?\S)??\1/g, "$2$3").replace(/(^|\W)([_]+)(\S)(.*?\S)??\2($|\W)/g, "$1$3$4$5").replace(/(`{3,})(.*?)\1/gm, "$2").replace(/`(.+?)`/g, "$1").replace(/~(.*?)~/g, "$1");
44
- } catch (e) {
45
- if (options.throwError) throw e;
46
- console.error("remove-markdown encountered error: %s", e);
47
- return md;
48
- }
49
- return output;
50
- };
51
- }
52
- });
53
-
54
- // src/search/client/mixedbread.ts
55
- var import_remove_markdown = __toESM(require_remove_markdown(), 1);
56
- import Slugger from "github-slugger";
57
- var slugger = new Slugger();
58
- function extractHeadingTitle(text) {
59
- const trimmedText = text.trim();
60
- if (!trimmedText.startsWith("#")) {
61
- return "";
62
- }
63
- const lines = trimmedText.split("\n");
64
- const firstLine = lines[0]?.trim();
65
- if (firstLine) {
66
- return (0, import_remove_markdown.default)(firstLine, {
67
- useImgAltText: false
68
- });
69
- }
70
- return "";
71
- }
72
- async function search(query, options) {
73
- const { client, storeIdentifier, tag } = options;
74
- if (!query.trim()) {
75
- return [];
76
- }
77
- const res = await client.stores.search({
78
- query,
79
- store_identifiers: [storeIdentifier],
80
- top_k: 10,
81
- filters: {
82
- key: "generated_metadata.tag",
83
- operator: "eq",
84
- value: tag
85
- },
86
- search_options: {
87
- return_metadata: true
88
- }
89
- });
90
- return res.data.flatMap((item) => {
91
- const metadata = item.generated_metadata;
92
- const url = metadata.url || "#";
93
- const title = metadata.title || "Untitled";
94
- const chunkResults = [
95
- {
96
- id: `${item.file_id}-${item.chunk_index}-page`,
97
- type: "page",
98
- content: title,
99
- url
100
- }
101
- ];
102
- const headingTitle = item.type === "text" ? extractHeadingTitle(item.text) : "";
103
- if (headingTitle) {
104
- slugger.reset();
105
- chunkResults.push({
106
- id: `${item.file_id}-${item.chunk_index}-heading`,
107
- type: "heading",
108
- content: headingTitle,
109
- url: `${url}#${slugger.slug(headingTitle)}`
110
- });
111
- }
112
- return chunkResults;
113
- });
114
- }
115
- export {
116
- search
117
- };
@@ -1,93 +0,0 @@
1
- import {
2
- removeUndefined
3
- } from "./chunk-ZMWYLUDP.js";
4
- import {
5
- createContentHighlighter
6
- } from "./chunk-OTD7MV33.js";
7
- import "./chunk-U67V476Y.js";
8
-
9
- // src/search/client/orama-cloud.ts
10
- async function searchDocs(query, options) {
11
- const highlighter = createContentHighlighter(query);
12
- const list = [];
13
- const { index = "default", client, params: extraParams, tag } = options;
14
- if (index === "crawler") {
15
- const result2 = await client.search({
16
- datasources: [],
17
- ...extraParams,
18
- term: query,
19
- where: {
20
- category: tag ? {
21
- eq: tag.slice(0, 1).toUpperCase() + tag.slice(1)
22
- } : void 0,
23
- ...extraParams?.where
24
- },
25
- limit: 10
26
- });
27
- if (!result2) return list;
28
- for (const hit of result2.hits) {
29
- const doc = hit.document;
30
- list.push(
31
- {
32
- id: hit.id,
33
- type: "page",
34
- content: doc.title,
35
- contentWithHighlights: highlighter.highlight(doc.title),
36
- url: doc.path
37
- },
38
- {
39
- id: "page" + hit.id,
40
- type: "text",
41
- content: doc.content,
42
- contentWithHighlights: highlighter.highlight(doc.content),
43
- url: doc.path
44
- }
45
- );
46
- }
47
- return list;
48
- }
49
- const params = {
50
- datasources: [],
51
- ...extraParams,
52
- term: query,
53
- where: removeUndefined({
54
- tag,
55
- ...extraParams?.where
56
- }),
57
- groupBy: {
58
- properties: ["page_id"],
59
- max_results: 7,
60
- ...extraParams?.groupBy
61
- }
62
- };
63
- const result = await client.search(params);
64
- if (!result || !result.groups) return list;
65
- for (const item of result.groups) {
66
- let addedHead = false;
67
- for (const hit of item.result) {
68
- const doc = hit.document;
69
- if (!addedHead) {
70
- list.push({
71
- id: doc.page_id,
72
- type: "page",
73
- content: doc.title,
74
- breadcrumbs: doc.breadcrumbs,
75
- contentWithHighlights: highlighter.highlight(doc.title),
76
- url: doc.url
77
- });
78
- addedHead = true;
79
- }
80
- list.push({
81
- id: doc.id,
82
- content: doc.content,
83
- contentWithHighlights: highlighter.highlight(doc.content),
84
- type: doc.content === doc.section ? "heading" : "text",
85
- url: doc.section_id ? `${doc.url}#${doc.section_id}` : doc.url
86
- });
87
- }
88
- }
89
- return list;
90
- }
91
- export {
92
- searchDocs
93
- };