fumadocs-core 16.4.0 → 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.
Files changed (278) hide show
  1. package/dist/advanced-BRT5Ij43.js +80 -0
  2. package/dist/advanced-BRT5Ij43.js.map +1 -0
  3. package/dist/algolia-CBBN8R6-.d.ts +68 -0
  4. package/dist/algolia-CBBN8R6-.d.ts.map +1 -0
  5. package/dist/algolia-CQPXCnjV.js +49 -0
  6. package/dist/algolia-CQPXCnjV.js.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-B-ezknvj.js +42 -0
  12. package/dist/codeblock-utils-lld8UiQo.d.ts +37 -0
  13. package/dist/codeblock-utils-lld8UiQo.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-DuxDer_c.d.ts +62 -0
  35. package/dist/definitions-DuxDer_c.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-B5e9CFfN.js +20 -0
  41. package/dist/fetch-B5e9CFfN.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-Dt7IObrc.js +19 -0
  76. package/dist/icon-Dt7IObrc.js.map +1 -0
  77. package/dist/index-2U6Tl4--.d.ts +379 -0
  78. package/dist/index-2U6Tl4--.d.ts.map +1 -0
  79. package/dist/index-Bw-DCOra.d.ts +41 -0
  80. package/dist/index-Bw-DCOra.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-mc9-X-PK.js +40 -0
  86. package/dist/mdast-utils-mc9-X-PK.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-DlByNYSd.js +88 -0
  129. package/dist/mixedbread-DlByNYSd.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-DP9-1I-S.js +16 -0
  135. package/dist/normalize-url-DP9-1I-S.js.map +1 -0
  136. package/dist/orama-cloud-DH3g37zc.js +84 -0
  137. package/dist/orama-cloud-DH3g37zc.js.map +1 -0
  138. package/dist/page-tree/index.d.ts +23 -11
  139. package/dist/page-tree/index.d.ts.map +1 -0
  140. package/dist/page-tree/index.js +3 -17
  141. package/dist/path-DHIjrDBP.js +60 -0
  142. package/dist/path-DHIjrDBP.js.map +1 -0
  143. package/dist/rehype-code-CdiZ1Y6P.js +241 -0
  144. package/dist/rehype-code-CdiZ1Y6P.js.map +1 -0
  145. package/dist/rehype-code-vVWG4-ej.d.ts +58 -0
  146. package/dist/rehype-code-vVWG4-ej.d.ts.map +1 -0
  147. package/dist/rehype-toc-DJvSyE0o.d.ts +18 -0
  148. package/dist/rehype-toc-DJvSyE0o.d.ts.map +1 -0
  149. package/dist/rehype-toc-DVwJcwvA.js +143 -0
  150. package/dist/rehype-toc-DVwJcwvA.js.map +1 -0
  151. package/dist/remark-admonition-DOwBWzsH.d.ts +22 -0
  152. package/dist/remark-admonition-DOwBWzsH.d.ts.map +1 -0
  153. package/dist/remark-code-tab-CXsYlims.d.ts +32 -0
  154. package/dist/remark-code-tab-CXsYlims.d.ts.map +1 -0
  155. package/dist/remark-directive-admonition-BCm_yiU9.d.ts +36 -0
  156. package/dist/remark-directive-admonition-BCm_yiU9.d.ts.map +1 -0
  157. package/dist/remark-gfm-CeWpMwyk.d.ts +2 -0
  158. package/dist/remark-heading-CXvCY0go.d.ts +37 -0
  159. package/dist/remark-heading-CXvCY0go.d.ts.map +1 -0
  160. package/dist/remark-image-CvUis4R1.d.ts +65 -0
  161. package/dist/remark-image-CvUis4R1.d.ts.map +1 -0
  162. package/dist/remark-mdx-files-B31xFFG4.d.ts +56 -0
  163. package/dist/remark-mdx-files-B31xFFG4.d.ts.map +1 -0
  164. package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts +17 -0
  165. package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts.map +1 -0
  166. package/dist/remark-npm-BIvIEKT2.d.ts +36 -0
  167. package/dist/remark-npm-BIvIEKT2.d.ts.map +1 -0
  168. package/dist/remark-steps-CHJN-rtm.d.ts +28 -0
  169. package/dist/remark-steps-CHJN-rtm.d.ts.map +1 -0
  170. package/dist/remark-structure-RZD2gGKp.d.ts +77 -0
  171. package/dist/remark-structure-RZD2gGKp.d.ts.map +1 -0
  172. package/dist/remove-undefined-Cfs4o_mM.js +19 -0
  173. package/dist/remove-undefined-Cfs4o_mM.js.map +1 -0
  174. package/dist/search/algolia.d.ts +3 -69
  175. package/dist/search/algolia.js +69 -63
  176. package/dist/search/algolia.js.map +1 -0
  177. package/dist/search/client.d.ts +120 -114
  178. package/dist/search/client.d.ts.map +1 -0
  179. package/dist/search/client.js +92 -91
  180. package/dist/search/client.js.map +1 -0
  181. package/dist/search/index.d.ts +20 -18
  182. package/dist/search/index.d.ts.map +1 -0
  183. package/dist/search/index.js +3 -7
  184. package/dist/search/orama-cloud.d.ts +70 -68
  185. package/dist/search/orama-cloud.d.ts.map +1 -0
  186. package/dist/search/orama-cloud.js +46 -54
  187. package/dist/search/orama-cloud.js.map +1 -0
  188. package/dist/search/server.d.ts +6 -136
  189. package/dist/search/server.js +292 -369
  190. package/dist/search/server.js.map +1 -0
  191. package/dist/search-D6ChCLhY.js +44 -0
  192. package/dist/search-D6ChCLhY.js.map +1 -0
  193. package/dist/server-CPR_fgkH.d.ts +133 -0
  194. package/dist/server-CPR_fgkH.d.ts.map +1 -0
  195. package/dist/shiki-4oMYwHED.js +80 -0
  196. package/dist/shiki-4oMYwHED.js.map +1 -0
  197. package/dist/shiki-CIBQys54.d.ts +33 -0
  198. package/dist/shiki-CIBQys54.d.ts.map +1 -0
  199. package/dist/source/client/index.d.ts +7 -5
  200. package/dist/source/client/index.d.ts.map +1 -0
  201. package/dist/source/client/index.js +24 -35
  202. package/dist/source/client/index.js.map +1 -0
  203. package/dist/source/index.d.ts +3 -42
  204. package/dist/source/index.js +599 -752
  205. package/dist/source/index.js.map +1 -0
  206. package/dist/source/plugins/lucide-icons.d.ts +7 -7
  207. package/dist/source/plugins/lucide-icons.d.ts.map +1 -0
  208. package/dist/source/plugins/lucide-icons.js +21 -20
  209. package/dist/source/plugins/lucide-icons.js.map +1 -0
  210. package/dist/source/plugins/slugs.d.ts +3 -0
  211. package/dist/source/plugins/slugs.js +65 -0
  212. package/dist/source/plugins/slugs.js.map +1 -0
  213. package/dist/source/schema.d.ts +17 -14
  214. package/dist/source/schema.d.ts.map +1 -0
  215. package/dist/source/schema.js +26 -22
  216. package/dist/source/schema.js.map +1 -0
  217. package/dist/static-Dq8pA8Ay.js +51 -0
  218. package/dist/static-Dq8pA8Ay.js.map +1 -0
  219. package/dist/toc.d.ts +38 -25
  220. package/dist/toc.d.ts.map +1 -0
  221. package/dist/toc.js +123 -136
  222. package/dist/toc.js.map +1 -0
  223. package/dist/util-CK2ykiif.d.ts +8 -0
  224. package/dist/util-CK2ykiif.d.ts.map +1 -0
  225. package/dist/util-s9piKHsk.js +10 -0
  226. package/dist/util-s9piKHsk.js.map +1 -0
  227. package/dist/utils/use-effect-event.d.ts +3 -1
  228. package/dist/utils/use-effect-event.d.ts.map +1 -0
  229. package/dist/utils/use-effect-event.js +16 -13
  230. package/dist/utils/use-effect-event.js.map +1 -0
  231. package/dist/utils/use-media-query.d.ts +3 -1
  232. package/dist/utils/use-media-query.d.ts.map +1 -0
  233. package/dist/utils/use-media-query.js +20 -20
  234. package/dist/utils/use-media-query.js.map +1 -0
  235. package/dist/utils/use-on-change.d.ts +3 -1
  236. package/dist/utils/use-on-change.d.ts.map +1 -0
  237. package/dist/utils/use-on-change.js +23 -7
  238. package/dist/utils/use-on-change.js.map +1 -0
  239. package/dist/utils-DUvi2WkD.js +134 -0
  240. package/dist/utils-DUvi2WkD.js.map +1 -0
  241. package/package.json +60 -58
  242. package/dist/algolia-IZEDLPHE.js +0 -58
  243. package/dist/chunk-5PMI7QDD.js +0 -220
  244. package/dist/chunk-ADBHPKXG.js +0 -78
  245. package/dist/chunk-APKPSBSB.js +0 -74
  246. package/dist/chunk-CH7YHH7V.js +0 -222
  247. package/dist/chunk-EFVXL2PP.js +0 -144
  248. package/dist/chunk-EMWGTXSW.js +0 -19
  249. package/dist/chunk-FAEPKD7U.js +0 -20
  250. package/dist/chunk-FUUVPEA5.js +0 -29
  251. package/dist/chunk-GINBKBVQ.js +0 -12
  252. package/dist/chunk-GLRQBLGN.js +0 -59
  253. package/dist/chunk-JUF4WZ6G.js +0 -117
  254. package/dist/chunk-K4WNLOVQ.js +0 -75
  255. package/dist/chunk-L4JKQWCM.js +0 -131
  256. package/dist/chunk-MA6O2UUE.js +0 -50
  257. package/dist/chunk-ONG4RVCR.js +0 -8
  258. package/dist/chunk-OTD7MV33.js +0 -53
  259. package/dist/chunk-PFNP6PEB.js +0 -11
  260. package/dist/chunk-SH7BNTG7.js +0 -38
  261. package/dist/chunk-TWIDBWFG.js +0 -84
  262. package/dist/chunk-U67V476Y.js +0 -35
  263. package/dist/chunk-VLSDGCJE.js +0 -47
  264. package/dist/chunk-W6WTLKRA.js +0 -73
  265. package/dist/chunk-X2HFD5QJ.js +0 -275
  266. package/dist/chunk-XJ6ZQNEX.js +0 -91
  267. package/dist/chunk-XN2LKXFZ.js +0 -101
  268. package/dist/chunk-XOFXGHS4.js +0 -93
  269. package/dist/chunk-XZSI7AHE.js +0 -67
  270. package/dist/chunk-YVVDKJ2H.js +0 -34
  271. package/dist/chunk-ZMWYLUDP.js +0 -21
  272. package/dist/definitions-pJ7PybYY.d.ts +0 -60
  273. package/dist/fetch-IBTWQCJR.js +0 -22
  274. package/dist/loader-_E2HOdV0.d.ts +0 -333
  275. package/dist/mixedbread-A3WLENES.js +0 -117
  276. package/dist/orama-cloud-UZAPMPFV.js +0 -93
  277. package/dist/static-A2YJ5TXV.js +0 -62
  278. package/dist/util-bZU2QeJ2.d.ts +0 -6
@@ -1,69 +1,3 @@
1
- import { Algoliasearch } from 'algoliasearch';
2
- import { StructuredData } from '../mdx-plugins/remark-structure.js';
3
- import 'mdast';
4
- import 'unified';
5
- import 'mdast-util-mdx-jsx';
6
-
7
- interface DocumentRecord {
8
- /**
9
- * The ID of document, must be unique
10
- */
11
- _id: string;
12
- title: string;
13
- description?: string;
14
- breadcrumbs?: string[];
15
- /**
16
- * URL to the page
17
- */
18
- url: string;
19
- structured: StructuredData;
20
- /**
21
- * Tag to filter results
22
- */
23
- tag?: string;
24
- /**
25
- * Data to be added to each section index
26
- */
27
- extra_data?: object;
28
- }
29
- interface SyncOptions {
30
- /**
31
- * Index Name for documents.
32
- */
33
- indexName?: string;
34
- /**
35
- * Search indexes
36
- */
37
- documents: DocumentRecord[];
38
- }
39
- /**
40
- * Update index settings and replace all objects
41
- *
42
- * @param client - Algolia Admin Client
43
- * @param options - Index Options
44
- */
45
- declare function sync(client: Algoliasearch, options: SyncOptions): Promise<void>;
46
- declare function setIndexSettings(client: Algoliasearch, indexName: string): Promise<void>;
47
- declare function updateDocuments(client: Algoliasearch, indexName: string, documents: DocumentRecord[]): Promise<void>;
48
- interface BaseIndex {
49
- objectID: string;
50
- title: string;
51
- url: string;
52
- tag?: string;
53
- /**
54
- * The id of page, used for distinct
55
- */
56
- page_id: string;
57
- /**
58
- * Heading content
59
- */
60
- section?: string;
61
- /**
62
- * Heading (anchor) id
63
- */
64
- section_id?: string;
65
- breadcrumbs?: string[];
66
- content: string;
67
- }
68
-
69
- export { type BaseIndex, type DocumentRecord, type SyncOptions, setIndexSettings, sync, updateDocuments };
1
+ import "../remark-structure-RZD2gGKp.js";
2
+ import { a as sync, i as setIndexSettings, n as DocumentRecord, o as updateDocuments, r as SyncOptions, t as BaseIndex } from "../algolia-CBBN8R6-.js";
3
+ export { BaseIndex, DocumentRecord, SyncOptions, setIndexSettings, sync, updateDocuments };
@@ -1,71 +1,77 @@
1
- import "../chunk-U67V476Y.js";
2
-
3
- // src/search/algolia.ts
1
+ //#region src/search/algolia.ts
2
+ /**
3
+ * Update index settings and replace all objects
4
+ *
5
+ * @param client - Algolia Admin Client
6
+ * @param options - Index Options
7
+ */
4
8
  async function sync(client, options) {
5
- const { indexName = "document", documents } = options;
6
- await setIndexSettings(client, indexName);
7
- await updateDocuments(client, indexName, documents);
9
+ const { indexName = "document", documents } = options;
10
+ await setIndexSettings(client, indexName);
11
+ await updateDocuments(client, indexName, documents);
8
12
  }
9
13
  async function setIndexSettings(client, indexName) {
10
- await client.setSettings({
11
- indexName,
12
- indexSettings: {
13
- attributeForDistinct: "page_id",
14
- attributesToRetrieve: [
15
- "title",
16
- "section",
17
- "content",
18
- "url",
19
- "section_id",
20
- "breadcrumbs"
21
- ],
22
- searchableAttributes: ["title", "section", "content"],
23
- attributesToSnippet: [],
24
- attributesForFaceting: ["tag"]
25
- }
26
- });
14
+ await client.setSettings({
15
+ indexName,
16
+ indexSettings: {
17
+ attributeForDistinct: "page_id",
18
+ attributesToRetrieve: [
19
+ "title",
20
+ "section",
21
+ "content",
22
+ "url",
23
+ "section_id",
24
+ "breadcrumbs"
25
+ ],
26
+ searchableAttributes: [
27
+ "title",
28
+ "section",
29
+ "content"
30
+ ],
31
+ attributesToSnippet: [],
32
+ attributesForFaceting: ["tag"]
33
+ }
34
+ });
27
35
  }
28
36
  function toIndex(page) {
29
- let id = 0;
30
- const indexes = [];
31
- const scannedHeadings = /* @__PURE__ */ new Set();
32
- function createIndex(section, sectionId, content) {
33
- return {
34
- objectID: `${page._id}-${(id++).toString()}`,
35
- breadcrumbs: page.breadcrumbs,
36
- title: page.title,
37
- url: page.url,
38
- page_id: page._id,
39
- tag: page.tag,
40
- section,
41
- section_id: sectionId,
42
- content,
43
- ...page.extra_data
44
- };
45
- }
46
- if (page.description)
47
- indexes.push(createIndex(void 0, void 0, page.description));
48
- const { headings, contents } = page.structured;
49
- for (const p of contents) {
50
- const heading = p.heading ? headings.find((h) => p.heading === h.id) : null;
51
- const index = createIndex(heading?.content, heading?.id, p.content);
52
- if (heading && !scannedHeadings.has(heading.id)) {
53
- scannedHeadings.add(heading.id);
54
- indexes.push(createIndex(heading.content, heading.id, heading.content));
55
- }
56
- indexes.push(index);
57
- }
58
- return indexes;
37
+ let id = 0;
38
+ const indexes = [];
39
+ const scannedHeadings = /* @__PURE__ */ new Set();
40
+ function createIndex(section, sectionId, content) {
41
+ return {
42
+ objectID: `${page._id}-${(id++).toString()}`,
43
+ breadcrumbs: page.breadcrumbs,
44
+ title: page.title,
45
+ url: page.url,
46
+ page_id: page._id,
47
+ tag: page.tag,
48
+ section,
49
+ section_id: sectionId,
50
+ content,
51
+ ...page.extra_data
52
+ };
53
+ }
54
+ if (page.description) indexes.push(createIndex(void 0, void 0, page.description));
55
+ const { headings, contents } = page.structured;
56
+ for (const p of contents) {
57
+ const heading = p.heading ? headings.find((h) => p.heading === h.id) : null;
58
+ const index = createIndex(heading?.content, heading?.id, p.content);
59
+ if (heading && !scannedHeadings.has(heading.id)) {
60
+ scannedHeadings.add(heading.id);
61
+ indexes.push(createIndex(heading.content, heading.id, heading.content));
62
+ }
63
+ indexes.push(index);
64
+ }
65
+ return indexes;
59
66
  }
60
67
  async function updateDocuments(client, indexName, documents) {
61
- const objects = documents.flatMap(toIndex);
62
- await client.replaceAllObjects({
63
- indexName,
64
- objects
65
- });
68
+ const objects = documents.flatMap(toIndex);
69
+ await client.replaceAllObjects({
70
+ indexName,
71
+ objects
72
+ });
66
73
  }
67
- export {
68
- setIndexSettings,
69
- sync,
70
- updateDocuments
71
- };
74
+
75
+ //#endregion
76
+ export { setIndexSettings, sync, updateDocuments };
77
+ //# sourceMappingURL=algolia.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algolia.js","names":["indexes: BaseIndex[]"],"sources":["../../src/search/algolia.ts"],"sourcesContent":["import type { Algoliasearch } from 'algoliasearch';\nimport type { StructuredData } from '@/mdx-plugins/remark-structure';\n\nexport interface DocumentRecord {\n /**\n * The ID of document, must be unique\n */\n _id: string;\n\n title: string;\n description?: string;\n breadcrumbs?: string[];\n\n /**\n * URL to the page\n */\n url: string;\n structured: StructuredData;\n\n /**\n * Tag to filter results\n */\n tag?: string;\n\n /**\n * Data to be added to each section index\n */\n extra_data?: object;\n}\n\nexport interface SyncOptions {\n /**\n * Index Name for documents.\n */\n indexName?: string;\n\n /**\n * Search indexes\n */\n documents: DocumentRecord[];\n}\n\n/**\n * Update index settings and replace all objects\n *\n * @param client - Algolia Admin Client\n * @param options - Index Options\n */\nexport async function sync(client: Algoliasearch, options: SyncOptions): Promise<void> {\n const { indexName = 'document', documents } = options;\n await setIndexSettings(client, indexName);\n await updateDocuments(client, indexName, documents);\n}\n\nexport async function setIndexSettings(client: Algoliasearch, indexName: string): Promise<void> {\n await client.setSettings({\n indexName,\n indexSettings: {\n attributeForDistinct: 'page_id',\n attributesToRetrieve: ['title', 'section', 'content', 'url', 'section_id', 'breadcrumbs'],\n searchableAttributes: ['title', 'section', 'content'],\n attributesToSnippet: [],\n attributesForFaceting: ['tag'],\n },\n });\n}\n\nfunction toIndex(page: DocumentRecord): BaseIndex[] {\n let id = 0;\n const indexes: BaseIndex[] = [];\n const scannedHeadings = new Set<string>();\n\n function createIndex(\n section: string | undefined,\n sectionId: string | undefined,\n content: string,\n ): BaseIndex {\n return {\n objectID: `${page._id}-${(id++).toString()}`,\n breadcrumbs: page.breadcrumbs,\n title: page.title,\n url: page.url,\n page_id: page._id,\n tag: page.tag,\n section,\n section_id: sectionId,\n content,\n ...page.extra_data,\n };\n }\n\n if (page.description) indexes.push(createIndex(undefined, undefined, page.description));\n const { headings, contents } = page.structured;\n\n for (const p of contents) {\n const heading = p.heading ? headings.find((h) => p.heading === h.id) : null;\n\n const index = createIndex(heading?.content, heading?.id, p.content);\n\n if (heading && !scannedHeadings.has(heading.id)) {\n scannedHeadings.add(heading.id);\n\n indexes.push(createIndex(heading.content, heading.id, heading.content));\n }\n\n indexes.push(index);\n }\n\n return indexes;\n}\n\nexport async function updateDocuments(\n client: Algoliasearch,\n indexName: string,\n documents: DocumentRecord[],\n): Promise<void> {\n const objects = documents.flatMap(toIndex);\n\n await client.replaceAllObjects({\n indexName,\n objects: objects as unknown as Record<string, unknown>[],\n });\n}\n\nexport interface BaseIndex {\n objectID: string;\n title: string;\n url: string;\n tag?: string;\n\n /**\n * The id of page, used for distinct\n */\n page_id: string;\n\n /**\n * Heading content\n */\n section?: string;\n\n /**\n * Heading (anchor) id\n */\n section_id?: string;\n\n breadcrumbs?: string[];\n\n content: string;\n}\n"],"mappings":";;;;;;;AAgDA,eAAsB,KAAK,QAAuB,SAAqC;CACrF,MAAM,EAAE,YAAY,YAAY,cAAc;AAC9C,OAAM,iBAAiB,QAAQ,UAAU;AACzC,OAAM,gBAAgB,QAAQ,WAAW,UAAU;;AAGrD,eAAsB,iBAAiB,QAAuB,WAAkC;AAC9F,OAAM,OAAO,YAAY;EACvB;EACA,eAAe;GACb,sBAAsB;GACtB,sBAAsB;IAAC;IAAS;IAAW;IAAW;IAAO;IAAc;IAAc;GACzF,sBAAsB;IAAC;IAAS;IAAW;IAAU;GACrD,qBAAqB,EAAE;GACvB,uBAAuB,CAAC,MAAM;GAC/B;EACF,CAAC;;AAGJ,SAAS,QAAQ,MAAmC;CAClD,IAAI,KAAK;CACT,MAAMA,UAAuB,EAAE;CAC/B,MAAM,kCAAkB,IAAI,KAAa;CAEzC,SAAS,YACP,SACA,WACA,SACW;AACX,SAAO;GACL,UAAU,GAAG,KAAK,IAAI,IAAI,MAAM,UAAU;GAC1C,aAAa,KAAK;GAClB,OAAO,KAAK;GACZ,KAAK,KAAK;GACV,SAAS,KAAK;GACd,KAAK,KAAK;GACV;GACA,YAAY;GACZ;GACA,GAAG,KAAK;GACT;;AAGH,KAAI,KAAK,YAAa,SAAQ,KAAK,YAAY,QAAW,QAAW,KAAK,YAAY,CAAC;CACvF,MAAM,EAAE,UAAU,aAAa,KAAK;AAEpC,MAAK,MAAM,KAAK,UAAU;EACxB,MAAM,UAAU,EAAE,UAAU,SAAS,MAAM,MAAM,EAAE,YAAY,EAAE,GAAG,GAAG;EAEvE,MAAM,QAAQ,YAAY,SAAS,SAAS,SAAS,IAAI,EAAE,QAAQ;AAEnE,MAAI,WAAW,CAAC,gBAAgB,IAAI,QAAQ,GAAG,EAAE;AAC/C,mBAAgB,IAAI,QAAQ,GAAG;AAE/B,WAAQ,KAAK,YAAY,QAAQ,SAAS,QAAQ,IAAI,QAAQ,QAAQ,CAAC;;AAGzE,UAAQ,KAAK,MAAM;;AAGrB,QAAO;;AAGT,eAAsB,gBACpB,QACA,WACA,WACe;CACf,MAAM,UAAU,UAAU,QAAQ,QAAQ;AAE1C,OAAM,OAAO,kBAAkB;EAC7B;EACS;EACV,CAAC"}
@@ -1,121 +1,126 @@
1
- import { DependencyList } from 'react';
2
- import { AnyOrama } from '@orama/orama';
3
- import '../mdx-plugins/remark-structure.js';
4
- import { BaseIndex } from './algolia.js';
5
- import { LiteClient, SearchResponse } from 'algoliasearch/lite';
6
- import { OramaCloud, OramaCloudSearchParams } from '@orama/core';
7
- import Mixedbread from '@mixedbread/sdk';
8
- import { SortedResult } from './index.js';
9
- import 'mdast';
10
- import 'unified';
11
- import 'mdast-util-mdx-jsx';
12
- import 'algoliasearch';
1
+ import "../definitions-DuxDer_c.js";
2
+ import "../remark-structure-RZD2gGKp.js";
3
+ import { t as BaseIndex } from "../algolia-CBBN8R6-.js";
4
+ import { SortedResult } from "./index.js";
5
+ import "../server-CPR_fgkH.js";
6
+ import "../index-2U6Tl4--.js";
7
+ import { DependencyList } from "react";
8
+ import { AnyOrama } from "@orama/orama";
9
+ import { LiteClient, SearchResponse } from "algoliasearch/lite";
10
+ import { OramaCloud, OramaCloudSearchParams } from "@orama/core";
11
+ import Mixedbread from "@mixedbread/sdk";
13
12
 
13
+ //#region src/search/client/fetch.d.ts
14
14
  interface FetchOptions {
15
- /**
16
- * API route for search endpoint, support absolute URLs.
17
- *
18
- * @defaultValue '/api/search'
19
- */
20
- api?: string;
21
- /**
22
- * Filter results with specific tag(s).
23
- */
24
- tag?: string | string[];
25
- /**
26
- * Filter by locale
27
- */
28
- locale?: string;
15
+ /**
16
+ * API route for search endpoint, support absolute URLs.
17
+ *
18
+ * @defaultValue '/api/search'
19
+ */
20
+ api?: string;
21
+ /**
22
+ * Filter results with specific tag(s).
23
+ */
24
+ tag?: string | string[];
25
+ /**
26
+ * Filter by locale
27
+ */
28
+ locale?: string;
29
29
  }
30
-
30
+ //#endregion
31
+ //#region src/search/client/static.d.ts
31
32
  interface StaticOptions {
32
- /**
33
- * Where to download exported search indexes (URL)
34
- *
35
- * @defaultValue '/api/search'
36
- */
37
- from?: string;
38
- initOrama?: (locale?: string) => AnyOrama | Promise<AnyOrama>;
39
- /**
40
- * Filter results with specific tag(s).
41
- */
42
- tag?: string | string[];
43
- /**
44
- * Filter by locale (unsupported at the moment)
45
- */
46
- locale?: string;
33
+ /**
34
+ * Where to download exported search indexes (URL)
35
+ *
36
+ * @defaultValue '/api/search'
37
+ */
38
+ from?: string;
39
+ initOrama?: (locale?: string) => AnyOrama | Promise<AnyOrama>;
40
+ /**
41
+ * Filter results with specific tag(s).
42
+ */
43
+ tag?: string | string[];
44
+ /**
45
+ * Filter by locale (unsupported at the moment)
46
+ */
47
+ locale?: string;
47
48
  }
48
-
49
+ //#endregion
50
+ //#region src/search/client/algolia.d.ts
49
51
  interface AlgoliaOptions {
50
- indexName: string;
51
- client: LiteClient;
52
- /**
53
- * Filter results with specific tag.
54
- */
55
- tag?: string;
56
- locale?: string;
57
- onSearch?: (query: string, tag?: string, locale?: string) => Promise<{
58
- results: SearchResponse<BaseIndex>[];
59
- }>;
52
+ indexName: string;
53
+ client: LiteClient;
54
+ /**
55
+ * Filter results with specific tag.
56
+ */
57
+ tag?: string;
58
+ locale?: string;
59
+ onSearch?: (query: string, tag?: string, locale?: string) => Promise<{
60
+ results: SearchResponse<BaseIndex>[];
61
+ }>;
60
62
  }
61
-
63
+ //#endregion
64
+ //#region src/search/client/orama-cloud.d.ts
62
65
  interface OramaCloudOptions {
63
- client: OramaCloud;
64
- /**
65
- * The type of your index.
66
- *
67
- * You can set it to `crawler` if you use crawler instead of the JSON index with schema provided by Fumadocs
68
- */
69
- index?: 'default' | 'crawler';
70
- params?: Partial<OramaCloudSearchParams>;
71
- /**
72
- * Filter results with specific tag.
73
- */
74
- tag?: string;
75
- /**
76
- * Filter by locale (unsupported at the moment)
77
- */
78
- locale?: string;
66
+ client: OramaCloud;
67
+ /**
68
+ * The type of your index.
69
+ *
70
+ * You can set it to `crawler` if you use crawler instead of the JSON index with schema provided by Fumadocs
71
+ */
72
+ index?: 'default' | 'crawler';
73
+ params?: Partial<OramaCloudSearchParams>;
74
+ /**
75
+ * Filter results with specific tag.
76
+ */
77
+ tag?: string;
78
+ /**
79
+ * Filter by locale (unsupported at the moment)
80
+ */
81
+ locale?: string;
79
82
  }
80
-
83
+ //#endregion
84
+ //#region src/search/client/mixedbread.d.ts
81
85
  interface MixedbreadOptions {
82
- /**
83
- * The identifier of the store to search in
84
- */
85
- storeIdentifier: string;
86
- /**
87
- * The Mixedbread SDK client instance
88
- */
89
- client: Mixedbread;
90
- /**
91
- * Filter results with specific tag.
92
- */
93
- tag?: string;
94
- /**
95
- * Filter by locale (unsupported at the moment)
96
- */
97
- locale?: string;
86
+ /**
87
+ * The identifier of the store to search in
88
+ */
89
+ storeIdentifier: string;
90
+ /**
91
+ * The Mixedbread SDK client instance
92
+ */
93
+ client: Mixedbread;
94
+ /**
95
+ * Filter results with specific tag.
96
+ */
97
+ tag?: string;
98
+ /**
99
+ * Filter by locale (unsupported at the moment)
100
+ */
101
+ locale?: string;
98
102
  }
99
-
103
+ //#endregion
104
+ //#region src/search/client.d.ts
100
105
  interface UseDocsSearch {
101
- search: string;
102
- setSearch: (v: string) => void;
103
- query: {
104
- isLoading: boolean;
105
- data?: SortedResult[] | 'empty';
106
- error?: Error;
107
- };
106
+ search: string;
107
+ setSearch: (v: string) => void;
108
+ query: {
109
+ isLoading: boolean;
110
+ data?: SortedResult[] | 'empty';
111
+ error?: Error;
112
+ };
108
113
  }
109
114
  type Client = ({
110
- type: 'fetch';
115
+ type: 'fetch';
111
116
  } & FetchOptions) | ({
112
- type: 'static';
117
+ type: 'static';
113
118
  } & StaticOptions) | ({
114
- type: 'algolia';
119
+ type: 'algolia';
115
120
  } & AlgoliaOptions) | ({
116
- type: 'orama-cloud';
121
+ type: 'orama-cloud';
117
122
  } & OramaCloudOptions) | ({
118
- type: 'mixedbread';
123
+ type: 'mixedbread';
119
124
  } & MixedbreadOptions);
120
125
  /**
121
126
  * Provide a hook to query different official search clients.
@@ -123,18 +128,19 @@ type Client = ({
123
128
  * Note: it will re-query when its parameters changed, make sure to use `useMemo()` on `clientOptions` or define `deps` array.
124
129
  */
125
130
  declare function useDocsSearch(clientOptions: Client & {
126
- /**
127
- * The debounced delay for performing a search (in ms).
128
- * .
129
- * @defaultValue 100
130
- */
131
- delayMs?: number;
132
- /**
133
- * still perform search even if query is empty.
134
- *
135
- * @defaultValue false
136
- */
137
- allowEmpty?: boolean;
131
+ /**
132
+ * The debounced delay for performing a search (in ms).
133
+ * .
134
+ * @defaultValue 100
135
+ */
136
+ delayMs?: number;
137
+ /**
138
+ * still perform search even if query is empty.
139
+ *
140
+ * @defaultValue false
141
+ */
142
+ allowEmpty?: boolean;
138
143
  }, deps?: DependencyList): UseDocsSearch;
139
-
140
- export { type AlgoliaOptions, type Client, type FetchOptions, type OramaCloudOptions, type StaticOptions, useDocsSearch };
144
+ //#endregion
145
+ export { type AlgoliaOptions, Client, type FetchOptions, type OramaCloudOptions, type StaticOptions, useDocsSearch };
146
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","names":[],"sources":["../../src/search/client/fetch.ts","../../src/search/client/static.ts","../../src/search/client/algolia.ts","../../src/search/client/orama-cloud.ts","../../src/search/client/mixedbread.ts","../../src/search/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;UAEiB,YAAA;;;;;;;;;;;;AAAjB;;;;;;UCIiB,aAAA;;;;;;;mCAQkB,WAAW,QAAQ;;;;;EDZrC;;;;ACIjB;;;UCFiB,cAAA;;UAEP;;;;;;+DAaH;aACM,eAAe;EFlBX,CAAA,CAAA;;;;UGWA,iBAAA;UACP;;;;;;;WAOC,QAAQ;;;AHnBnB;;;;ACIA;EAQmC,MAAA,CAAA,EAAA,MAAA;;;;UGRlB,iBAAA;;;;;;;;UASP;;;AJbV;;;;ACIA;EAQmC,MAAA,CAAA,EAAA,MAAA;;;;UIJzB,aAAA;;;;;WAKC;ILbM,KAAA,CAAA,EKcL,KLdiB;;;KKkBjB,MAAA;EJdK,IAAA,EAAA,OAAA;CAQkB,GIS3B,YJT2B,CAAA,GAAA,CAAA;EAAmB,IAAA,EAAA,QAAA;CAAR,GIYtC,aJZsC,CAAA,GAAA,CAAA;EAAO,IAAA,EAAA,SAAA;IIe7C;;IAGA;EH5BS,IAAA,EAAA,YAAc;CAErB,GG6BF,iBH7BE,CAAA;;;;;;iBG2DM,aAAA,gBACC;;AFrDjB;;;;EAQkB,OAAA,CAAA,EAAA,MAAA;;;;ACflB;;;UC2ES,iBACN"}