@blogmcp/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/dist/_virtual/_plugin-vue_export-helper.js +9 -0
  2. package/dist/_virtual/constants.js +4 -0
  3. package/dist/_virtual/index.js +2 -0
  4. package/dist/_virtual/index2.js +4 -0
  5. package/dist/_virtual/index3.js +2 -0
  6. package/dist/_virtual/re.js +4 -0
  7. package/dist/core/article-seo.d.ts +27 -0
  8. package/dist/core/article-seo.js +25 -0
  9. package/dist/core/auth.d.ts +34 -0
  10. package/dist/core/auth.js +89 -0
  11. package/dist/core/blog-config.d.ts +5 -0
  12. package/dist/core/blog-config.js +14 -0
  13. package/dist/core/client-types.d.ts +51 -0
  14. package/dist/core/client.d.ts +159 -0
  15. package/dist/core/client.js +82 -0
  16. package/dist/core/i18n.d.ts +29 -0
  17. package/dist/core/i18n.js +34 -0
  18. package/dist/core/index.d.ts +26 -0
  19. package/dist/core/index.js +67 -0
  20. package/dist/core/markdown.d.ts +69 -0
  21. package/dist/core/markdown.js +47 -0
  22. package/dist/core/navigation.d.ts +70 -0
  23. package/dist/core/navigation.js +71 -0
  24. package/dist/core/queries.d.ts +34 -0
  25. package/dist/core/queries.js +363 -0
  26. package/dist/core/retry.d.ts +9 -0
  27. package/dist/core/retry.js +14 -0
  28. package/dist/core/seo.d.ts +142 -0
  29. package/dist/core/seo.js +166 -0
  30. package/dist/core/theme.d.ts +41 -0
  31. package/dist/core/theme.js +60 -0
  32. package/dist/core/translations/cs.json.js +27 -0
  33. package/dist/core/translations/en.json.js +27 -0
  34. package/dist/core/types.d.ts +184 -0
  35. package/dist/core/types.js +9 -0
  36. package/dist/core/view-model.d.ts +53 -0
  37. package/dist/core/view-model.js +47 -0
  38. package/dist/node_modules/@braintree/sanitize-url/dist/constants.js +8 -0
  39. package/dist/node_modules/@braintree/sanitize-url/dist/index.js +60 -0
  40. package/dist/node_modules/dompurify/dist/purify.es.js +662 -0
  41. package/dist/node_modules/semver/classes/comparator.js +56 -0
  42. package/dist/node_modules/semver/classes/range.js +148 -0
  43. package/dist/node_modules/semver/classes/semver.js +169 -0
  44. package/dist/node_modules/semver/functions/clean.js +14 -0
  45. package/dist/node_modules/semver/functions/cmp.js +39 -0
  46. package/dist/node_modules/semver/functions/coerce.js +33 -0
  47. package/dist/node_modules/semver/functions/compare-build.js +14 -0
  48. package/dist/node_modules/semver/functions/compare-loose.js +11 -0
  49. package/dist/node_modules/semver/functions/compare.js +11 -0
  50. package/dist/node_modules/semver/functions/diff.js +24 -0
  51. package/dist/node_modules/semver/functions/eq.js +11 -0
  52. package/dist/node_modules/semver/functions/gt.js +11 -0
  53. package/dist/node_modules/semver/functions/gte.js +11 -0
  54. package/dist/node_modules/semver/functions/inc.js +21 -0
  55. package/dist/node_modules/semver/functions/lt.js +11 -0
  56. package/dist/node_modules/semver/functions/lte.js +11 -0
  57. package/dist/node_modules/semver/functions/major.js +11 -0
  58. package/dist/node_modules/semver/functions/minor.js +11 -0
  59. package/dist/node_modules/semver/functions/neq.js +11 -0
  60. package/dist/node_modules/semver/functions/parse.js +21 -0
  61. package/dist/node_modules/semver/functions/patch.js +11 -0
  62. package/dist/node_modules/semver/functions/prerelease.js +14 -0
  63. package/dist/node_modules/semver/functions/rcompare.js +11 -0
  64. package/dist/node_modules/semver/functions/rsort.js +11 -0
  65. package/dist/node_modules/semver/functions/satisfies.js +18 -0
  66. package/dist/node_modules/semver/functions/sort.js +11 -0
  67. package/dist/node_modules/semver/functions/valid.js +14 -0
  68. package/dist/node_modules/semver/index.js +97 -0
  69. package/dist/node_modules/semver/internal/constants.js +28 -0
  70. package/dist/node_modules/semver/internal/debug.js +8 -0
  71. package/dist/node_modules/semver/internal/identifiers.js +18 -0
  72. package/dist/node_modules/semver/internal/lrucache.js +32 -0
  73. package/dist/node_modules/semver/internal/parse-options.js +10 -0
  74. package/dist/node_modules/semver/internal/re.js +32 -0
  75. package/dist/node_modules/semver/ranges/gtr.js +11 -0
  76. package/dist/node_modules/semver/ranges/intersects.js +11 -0
  77. package/dist/node_modules/semver/ranges/ltr.js +11 -0
  78. package/dist/node_modules/semver/ranges/max-satisfying.js +22 -0
  79. package/dist/node_modules/semver/ranges/min-satisfying.js +22 -0
  80. package/dist/node_modules/semver/ranges/min-version.js +42 -0
  81. package/dist/node_modules/semver/ranges/outside.js +44 -0
  82. package/dist/node_modules/semver/ranges/simplify.js +24 -0
  83. package/dist/node_modules/semver/ranges/subset.js +94 -0
  84. package/dist/node_modules/semver/ranges/to-comparators.js +11 -0
  85. package/dist/node_modules/semver/ranges/valid.js +17 -0
  86. package/dist/nuxt/composables/useAsyncKb.d.ts +32 -0
  87. package/dist/nuxt/composables/useAsyncKb.js +34 -0
  88. package/dist/nuxt/index.d.ts +1 -0
  89. package/dist/nuxt/index.js +6 -0
  90. package/dist/packages/mdx-render-vue/dist/_virtual/_plugin-vue_export-helper.js +9 -0
  91. package/dist/packages/mdx-render-vue/dist/_virtual/constants.js +4 -0
  92. package/dist/packages/mdx-render-vue/dist/_virtual/index.js +5 -0
  93. package/dist/packages/mdx-render-vue/dist/_virtual/index2.js +4 -0
  94. package/dist/packages/mdx-render-vue/dist/composables/useAudioPlayer.js +40 -0
  95. package/dist/packages/mdx-render-vue/dist/composables/useCallout.js +66 -0
  96. package/dist/packages/mdx-render-vue/dist/composables/useCodeBlock.js +62 -0
  97. package/dist/packages/mdx-render-vue/dist/composables/useGallery.js +68 -0
  98. package/dist/packages/mdx-render-vue/dist/composables/useMedia.js +9 -0
  99. package/dist/packages/mdx-render-vue/dist/composables/useYouTube.js +24 -0
  100. package/dist/packages/mdx-render-vue/dist/edit/AlertEdit.vue.js +4 -0
  101. package/dist/packages/mdx-render-vue/dist/edit/AlertEdit.vue2.js +16 -0
  102. package/dist/packages/mdx-render-vue/dist/edit/AudioPlayerEdit.vue.js +102 -0
  103. package/dist/packages/mdx-render-vue/dist/edit/AudioPlayerEdit.vue2.js +4 -0
  104. package/dist/packages/mdx-render-vue/dist/edit/BadgeEdit.vue.js +4 -0
  105. package/dist/packages/mdx-render-vue/dist/edit/BadgeEdit.vue2.js +11 -0
  106. package/dist/packages/mdx-render-vue/dist/edit/ButtonEdit.vue.js +4 -0
  107. package/dist/packages/mdx-render-vue/dist/edit/ButtonEdit.vue2.js +11 -0
  108. package/dist/packages/mdx-render-vue/dist/edit/CalloutEdit.vue.js +78 -0
  109. package/dist/packages/mdx-render-vue/dist/edit/CalloutEdit.vue2.js +4 -0
  110. package/dist/packages/mdx-render-vue/dist/edit/CardEdit.vue.js +4 -0
  111. package/dist/packages/mdx-render-vue/dist/edit/CardEdit.vue2.js +16 -0
  112. package/dist/packages/mdx-render-vue/dist/edit/CodeBlockEdit.vue.js +6 -0
  113. package/dist/packages/mdx-render-vue/dist/edit/CodeBlockEdit.vue2.js +74 -0
  114. package/dist/packages/mdx-render-vue/dist/edit/GalleryEdit.vue.js +56 -0
  115. package/dist/packages/mdx-render-vue/dist/edit/GalleryEdit.vue2.js +4 -0
  116. package/dist/packages/mdx-render-vue/dist/edit/IconEdit.vue.js +4 -0
  117. package/dist/packages/mdx-render-vue/dist/edit/IconEdit.vue2.js +11 -0
  118. package/dist/packages/mdx-render-vue/dist/edit/TooltipEdit.vue.js +4 -0
  119. package/dist/packages/mdx-render-vue/dist/edit/TooltipEdit.vue2.js +20 -0
  120. package/dist/packages/mdx-render-vue/dist/edit/YouTubeEdit.vue.js +34 -0
  121. package/dist/packages/mdx-render-vue/dist/edit/YouTubeEdit.vue2.js +4 -0
  122. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/_virtual/_rolldown/runtime.js +11 -0
  123. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/factory.js +29 -0
  124. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/presence/use-presence-context.js +6 -0
  125. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/presence/use-presence.js +32 -0
  126. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow-tip.js +5 -0
  127. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow-tip.vue_vue_type_script_setup_true_lang.js +18 -0
  128. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow.js +5 -0
  129. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow.vue_vue_type_script_setup_true_lang.js +18 -0
  130. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-content.js +5 -0
  131. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-content.vue_vue_type_script_setup_true_lang.js +20 -0
  132. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-context.js +5 -0
  133. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-context.vue_vue_type_script_setup_true_lang.js +12 -0
  134. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-positioner.js +5 -0
  135. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-positioner.vue_vue_type_script_setup_true_lang.js +19 -0
  136. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root-provider.js +5 -0
  137. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root-provider.vue_vue_type_script_setup_true_lang.js +29 -0
  138. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root.js +5 -0
  139. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root.vue_vue_type_script_setup_true_lang.js +59 -0
  140. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-trigger.js +5 -0
  141. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-trigger.vue_vue_type_script_setup_true_lang.js +21 -0
  142. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip.js +22 -0
  143. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/use-tooltip-context.js +6 -0
  144. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/components/tooltip/use-tooltip.js +29 -0
  145. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/providers/environment/use-environment-context.js +12 -0
  146. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/providers/locale/use-locale-context.js +11 -0
  147. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/utils/clean-props.js +8 -0
  148. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/utils/create-context.js +12 -0
  149. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/utils/dynamic.js +25 -0
  150. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/utils/unref-element.js +8 -0
  151. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/utils/use-forward-expose.js +36 -0
  152. package/dist/packages/mdx-render-vue/dist/node_modules/@ark-ui/vue/dist/utils/use-render-strategy.js +5 -0
  153. package/dist/packages/mdx-render-vue/dist/node_modules/@braintree/sanitize-url/dist/constants.js +8 -0
  154. package/dist/packages/mdx-render-vue/dist/node_modules/@braintree/sanitize-url/dist/index.js +60 -0
  155. package/dist/packages/mdx-render-vue/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +532 -0
  156. package/dist/packages/mdx-render-vue/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +403 -0
  157. package/dist/packages/mdx-render-vue/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +136 -0
  158. package/dist/packages/mdx-render-vue/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +128 -0
  159. package/dist/packages/mdx-render-vue/dist/node_modules/@iconify/vue/dist/iconify.js +1192 -0
  160. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/anatomy/dist/create-anatomy.js +26 -0
  161. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/core/dist/create-machine.js +21 -0
  162. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/core/dist/merge-props.js +45 -0
  163. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/core/dist/scope.js +16 -0
  164. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/core/dist/state.js +136 -0
  165. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/core/dist/types.js +5 -0
  166. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/dom-query/dist/chunk-QZ7TP4HQ.js +4 -0
  167. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/dom-query/dist/computed-style.js +8 -0
  168. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/dom-query/dist/event.js +31 -0
  169. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/dom-query/dist/node.js +49 -0
  170. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/dom-query/dist/overflow.js +19 -0
  171. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/dom-query/dist/platform.js +16 -0
  172. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/dom-query/dist/query.js +6 -0
  173. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/dom-query/dist/raf.js +41 -0
  174. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/dom-query/dist/set.js +14 -0
  175. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/dom-query/dist/shared.js +7 -0
  176. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/focus-visible/dist/index.js +90 -0
  177. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/popper/dist/get-anchor.js +34 -0
  178. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/popper/dist/get-placement.js +187 -0
  179. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/popper/dist/get-styles.js +47 -0
  180. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/popper/dist/middleware.js +56 -0
  181. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/popper/dist/placement.js +7 -0
  182. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/presence/dist/presence.connect.js +16 -0
  183. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/presence/dist/presence.machine.js +147 -0
  184. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/tooltip/dist/tooltip.anatomy.js +6 -0
  185. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/tooltip/dist/tooltip.connect.js +119 -0
  186. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/tooltip/dist/tooltip.dom.js +15 -0
  187. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/tooltip/dist/tooltip.machine.js +375 -0
  188. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/tooltip/dist/tooltip.store.js +9 -0
  189. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/types/dist/prop-types.js +10 -0
  190. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/utils/dist/array.js +6 -0
  191. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/utils/dist/equal.js +27 -0
  192. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/utils/dist/functions.js +10 -0
  193. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/utils/dist/guard.js +15 -0
  194. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/utils/dist/object.js +13 -0
  195. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/utils/dist/store.js +25 -0
  196. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/utils/dist/warning.js +25 -0
  197. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/vue/dist/bindable.js +37 -0
  198. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/vue/dist/machine.js +205 -0
  199. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/vue/dist/normalize-props.js +30 -0
  200. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/vue/dist/refs.js +14 -0
  201. package/dist/packages/mdx-render-vue/dist/node_modules/@zag-js/vue/dist/track.js +19 -0
  202. package/dist/packages/mdx-render-vue/dist/node_modules/dompurify/dist/purify.es.js +659 -0
  203. package/dist/packages/mdx-render-vue/dist/registry.js +154 -0
  204. package/dist/packages/mdx-render-vue/dist/render/alert/Alert.vue.js +4 -0
  205. package/dist/packages/mdx-render-vue/dist/render/alert/Alert.vue2.js +37 -0
  206. package/dist/packages/mdx-render-vue/dist/render/audioplayer/AudioPlayerDefault.vue.js +102 -0
  207. package/dist/packages/mdx-render-vue/dist/render/audioplayer/AudioPlayerDefault.vue2.js +4 -0
  208. package/dist/packages/mdx-render-vue/dist/render/badge/Badge.vue.js +4 -0
  209. package/dist/packages/mdx-render-vue/dist/render/badge/Badge.vue2.js +25 -0
  210. package/dist/packages/mdx-render-vue/dist/render/button/Button.vue.js +4 -0
  211. package/dist/packages/mdx-render-vue/dist/render/button/Button.vue2.js +37 -0
  212. package/dist/packages/mdx-render-vue/dist/render/callout/CalloutDefault.vue.js +79 -0
  213. package/dist/packages/mdx-render-vue/dist/render/callout/CalloutDefault.vue2.js +4 -0
  214. package/dist/packages/mdx-render-vue/dist/render/callout/CalloutMinimal.vue.js +22 -0
  215. package/dist/packages/mdx-render-vue/dist/render/callout/CalloutMinimal.vue2.js +4 -0
  216. package/dist/packages/mdx-render-vue/dist/render/card/Card.vue.js +4 -0
  217. package/dist/packages/mdx-render-vue/dist/render/card/Card.vue2.js +24 -0
  218. package/dist/packages/mdx-render-vue/dist/render/codeblock/CodeBlockDefault.vue.js +6 -0
  219. package/dist/packages/mdx-render-vue/dist/render/codeblock/CodeBlockDefault.vue2.js +77 -0
  220. package/dist/packages/mdx-render-vue/dist/render/gallery/GalleryGrid.vue.js +103 -0
  221. package/dist/packages/mdx-render-vue/dist/render/gallery/GalleryGrid.vue2.js +4 -0
  222. package/dist/packages/mdx-render-vue/dist/render/gallery/GalleryLightbox.vue.js +6 -0
  223. package/dist/packages/mdx-render-vue/dist/render/gallery/GalleryLightbox.vue2.js +142 -0
  224. package/dist/packages/mdx-render-vue/dist/render/icon/Icon.vue.js +4 -0
  225. package/dist/packages/mdx-render-vue/dist/render/icon/Icon.vue2.js +23 -0
  226. package/dist/packages/mdx-render-vue/dist/render/tooltip/Tooltip.vue.js +4 -0
  227. package/dist/packages/mdx-render-vue/dist/render/tooltip/Tooltip.vue2.js +54 -0
  228. package/dist/packages/mdx-render-vue/dist/render/youtube/YouTubeDefault.vue.js +69 -0
  229. package/dist/packages/mdx-render-vue/dist/render/youtube/YouTubeDefault.vue2.js +4 -0
  230. package/dist/packages/mdx-schema/dist/composables/useMdxParsing.js +139 -0
  231. package/dist/packages/mdx-schema/dist/metadata/index.js +415 -0
  232. package/dist/packages/mdx-schema/dist/prepareProps.js +46 -0
  233. package/dist/packages/mdx-schema/dist/styles/index.js +119 -0
  234. package/dist/packages/mdx-schema/dist/types/index.js +26 -0
  235. package/dist/packages/sanitize/dist/html.js +41 -0
  236. package/dist/react/KbMdxContent.d.ts +35 -0
  237. package/dist/react/KbMdxContent.js +102 -0
  238. package/dist/react/context.d.ts +11 -0
  239. package/dist/react/context.js +5 -0
  240. package/dist/react/hooks/useImageRenderer.d.ts +6 -0
  241. package/dist/react/hooks/useImageRenderer.js +9 -0
  242. package/dist/react/hooks/useKbClient.d.ts +3 -0
  243. package/dist/react/hooks/useKbClient.js +7 -0
  244. package/dist/react/hooks/useKbContext.d.ts +3 -0
  245. package/dist/react/hooks/useKbContext.js +11 -0
  246. package/dist/react/hooks/useKbI18n.d.ts +7 -0
  247. package/dist/react/hooks/useKbI18n.js +8 -0
  248. package/dist/react/hooks/useKbLanguage.d.ts +21 -0
  249. package/dist/react/hooks/useKbLanguage.js +63 -0
  250. package/dist/react/hooks/useKbSearch.d.ts +20 -0
  251. package/dist/react/hooks/useKbSearch.js +22 -0
  252. package/dist/react/hooks/useMdxContent.d.ts +18 -0
  253. package/dist/react/hooks/useMdxContent.js +11 -0
  254. package/dist/react/index.d.ts +21 -0
  255. package/dist/react/index.js +20 -0
  256. package/dist/react/provider.d.ts +25 -0
  257. package/dist/react/provider.js +29 -0
  258. package/dist/react/server/index.d.ts +38 -0
  259. package/dist/react/server/index.js +26 -0
  260. package/dist/sdk.css +1 -0
  261. package/dist/vue/components/KbAccessGate.vue.d.ts +36 -0
  262. package/dist/vue/components/KbAccessGate.vue.js +74 -0
  263. package/dist/vue/components/KbAccessGate.vue2.js +4 -0
  264. package/dist/vue/components/KbArticleCard.vue.d.ts +34 -0
  265. package/dist/vue/components/KbArticleCard.vue.js +87 -0
  266. package/dist/vue/components/KbArticleCard.vue2.js +4 -0
  267. package/dist/vue/components/KbMdxContent.vue.d.ts +5 -0
  268. package/dist/vue/components/KbMdxContent.vue.js +7 -0
  269. package/dist/vue/components/KbMdxContent.vue2.js +82 -0
  270. package/dist/vue/composables/useArticles.d.ts +30 -0
  271. package/dist/vue/composables/useArticles.js +36 -0
  272. package/dist/vue/composables/useImageRenderer.d.ts +6 -0
  273. package/dist/vue/composables/useImageRenderer.js +9 -0
  274. package/dist/vue/composables/useKbAuth.d.ts +27 -0
  275. package/dist/vue/composables/useKbAuth.js +83 -0
  276. package/dist/vue/composables/useKbClient.d.ts +6 -0
  277. package/dist/vue/composables/useKbClient.js +13 -0
  278. package/dist/vue/composables/useKbComments.d.ts +37 -0
  279. package/dist/vue/composables/useKbComments.js +160 -0
  280. package/dist/vue/composables/useKbI18n.d.ts +6 -0
  281. package/dist/vue/composables/useKbI18n.js +8 -0
  282. package/dist/vue/composables/useKbLanguage.d.ts +22 -0
  283. package/dist/vue/composables/useKbLanguage.js +63 -0
  284. package/dist/vue/composables/useNavigation.d.ts +18 -0
  285. package/dist/vue/composables/useNavigation.js +20 -0
  286. package/dist/vue/composables/useSearch.d.ts +21 -0
  287. package/dist/vue/composables/useSearch.js +20 -0
  288. package/dist/vue/composables/useTags.d.ts +17 -0
  289. package/dist/vue/composables/useTags.js +36 -0
  290. package/dist/vue/index.d.ts +22 -0
  291. package/dist/vue/index.js +36 -0
  292. package/dist/vue/plugin.d.ts +30 -0
  293. package/dist/vue/plugin.js +17 -0
  294. package/package.json +97 -0
  295. package/src/core/article-seo.ts +101 -0
  296. package/src/core/auth.ts +138 -0
  297. package/src/core/blog-config.ts +30 -0
  298. package/src/core/client-types.ts +58 -0
  299. package/src/core/client.ts +287 -0
  300. package/src/core/i18n.ts +84 -0
  301. package/src/core/index.ts +147 -0
  302. package/src/core/markdown.ts +178 -0
  303. package/src/core/navigation.ts +152 -0
  304. package/src/core/queries.ts +414 -0
  305. package/src/core/retry.ts +19 -0
  306. package/src/core/seo.ts +374 -0
  307. package/src/core/theme.ts +128 -0
  308. package/src/core/translations/cs.json +225 -0
  309. package/src/core/translations/en.json +225 -0
  310. package/src/core/types.ts +231 -0
  311. package/src/core/view-model.ts +98 -0
  312. package/src/nuxt/composables/useAsyncKb.ts +119 -0
  313. package/src/nuxt/index.ts +6 -0
  314. package/src/react/KbMdxContent.tsx +215 -0
  315. package/src/react/context.ts +25 -0
  316. package/src/react/hooks/useImageRenderer.ts +15 -0
  317. package/src/react/hooks/useKbClient.ts +9 -0
  318. package/src/react/hooks/useKbContext.ts +13 -0
  319. package/src/react/hooks/useKbI18n.ts +15 -0
  320. package/src/react/hooks/useKbLanguage.ts +105 -0
  321. package/src/react/hooks/useKbSearch.ts +50 -0
  322. package/src/react/hooks/useMdxContent.tsx +33 -0
  323. package/src/react/index.ts +31 -0
  324. package/src/react/provider.tsx +70 -0
  325. package/src/react/server/index.ts +70 -0
  326. package/src/vue/components/KbAccessGate.vue +86 -0
  327. package/src/vue/components/KbArticleCard.vue +102 -0
  328. package/src/vue/components/KbMdxContent.vue +211 -0
  329. package/src/vue/composables/useArticles.ts +78 -0
  330. package/src/vue/composables/useImageRenderer.ts +12 -0
  331. package/src/vue/composables/useKbAuth.ts +131 -0
  332. package/src/vue/composables/useKbClient.ts +17 -0
  333. package/src/vue/composables/useKbComments.ts +281 -0
  334. package/src/vue/composables/useKbI18n.ts +11 -0
  335. package/src/vue/composables/useKbLanguage.ts +103 -0
  336. package/src/vue/composables/useNavigation.ts +38 -0
  337. package/src/vue/composables/useSearch.ts +52 -0
  338. package/src/vue/composables/useTags.ts +64 -0
  339. package/src/vue/index.ts +27 -0
  340. package/src/vue/plugin.ts +73 -0
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Framework-agnostic view-model builders.
3
+ *
4
+ * Per-item presentation logic (URLs, date formatting, tag links, access-level
5
+ * resolution) computed once in pure code so the Nuxt and Next.js blogs render
6
+ * identical data and only differ in template markup.
7
+ */
8
+
9
+ import type { Article, AccessLevel } from './types'
10
+ import { ACCESS_LEVEL_ORDER } from './types'
11
+ import { localizedHref, type SeoConfig } from './seo'
12
+
13
+ /**
14
+ * Normalize a date value to an ISO 8601 string for `<time datetime>` and
15
+ * machine-readable SEO fields. The KB list API (`accessibleKbArticles`) can
16
+ * return dates in a non-ISO `Date.toString()` form; this guarantees valid
17
+ * ISO 8601 regardless. Invalid dates fall back to the raw value.
18
+ */
19
+ export function toIsoDate(value: string | null | undefined): string | null {
20
+ if (!value) return null
21
+ const d = new Date(value)
22
+ return Number.isNaN(d.getTime()) ? value : d.toISOString()
23
+ }
24
+
25
+ /**
26
+ * Format an ISO date string for display using the article locale.
27
+ * `cs` → `cs-CZ`, anything else → `en-US` (the blog's two-locale convention).
28
+ */
29
+ export function formatArticleDate(iso: string, locale: string): string {
30
+ const intlLocale = locale === 'cs' ? 'cs-CZ' : 'en-US'
31
+ return new Date(iso).toLocaleDateString(intlLocale, {
32
+ year: 'numeric',
33
+ month: 'long',
34
+ day: 'numeric',
35
+ })
36
+ }
37
+
38
+ /**
39
+ * Resolve the most restrictive (highest-rank) access level from an article's
40
+ * access rights. Empty/missing rights → `public`. Security-relevant: both blogs
41
+ * must gate identically, so this is single-sourced.
42
+ */
43
+ export function resolveArticleAccessLevel(
44
+ accessRights: string[] | null | undefined,
45
+ ): AccessLevel {
46
+ if (!accessRights || accessRights.length === 0) return 'public'
47
+ let maxIndex = 0
48
+ for (const right of accessRights) {
49
+ const idx = ACCESS_LEVEL_ORDER.indexOf(right as AccessLevel)
50
+ if (idx > maxIndex) maxIndex = idx
51
+ }
52
+ return ACCESS_LEVEL_ORDER[maxIndex] ?? 'public'
53
+ }
54
+
55
+ /** Render-ready view model for an article card / list item. */
56
+ export interface ArticleListItemVM {
57
+ slug: string
58
+ /** Locale-aware article URL. */
59
+ href: string
60
+ title: string
61
+ description: string | null
62
+ /** Raw featured image URL (not absolutized — the card relies on the image proxy). */
63
+ image: string | null
64
+ /** ISO date used for `<time datetime>` (publishedAt, falling back to updatedAt). */
65
+ isoDate: string | null
66
+ /** Localized human date, or null when no date is available. */
67
+ formattedDate: string | null
68
+ tags: { label: string; slug: string; href: string }[]
69
+ }
70
+
71
+ export interface BuildArticleListItemOptions {
72
+ article: Article
73
+ config: SeoConfig
74
+ /** Locale currently being rendered. */
75
+ locale: string
76
+ }
77
+
78
+ export function buildArticleListItem(opts: BuildArticleListItemOptions): ArticleListItemVM {
79
+ const { article, config, locale } = opts
80
+ const slug = article.slug || article.filename.replace(/\.(md|mdx)$/, '')
81
+ const rawDate = article.publishedAt || article.updatedAt || null
82
+ const isoDate = toIsoDate(rawDate)
83
+
84
+ return {
85
+ slug,
86
+ href: localizedHref(`/articles/${slug}`, locale, config),
87
+ title: article.title || '',
88
+ description: article.description ?? null,
89
+ image: article.featuredImageUrl ?? null,
90
+ isoDate,
91
+ formattedDate: rawDate ? formatArticleDate(rawDate, locale) : null,
92
+ tags: (article.tags || []).map((tag) => ({
93
+ label: tag,
94
+ slug: tag,
95
+ href: localizedHref(`/topics/${tag}`, locale, config),
96
+ })),
97
+ }
98
+ }
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Nuxt SSR adapters for blog-sdk composables.
3
+ *
4
+ * These wrap the Vue composables with Nuxt's useAsyncData for
5
+ * server-side rendering and hydration.
6
+ *
7
+ * Usage in Nuxt pages:
8
+ * const { articles, totalCount } = await useAsyncArticleList('home', { status: 'published' })
9
+ */
10
+
11
+ // Note: These imports work in Nuxt apps where #imports is available.
12
+ // The composable functions reference useAsyncData from Nuxt's auto-imports.
13
+ // TypeScript types are declared inline to avoid hard dependency on nuxt types.
14
+
15
+ import type { Ref } from 'vue'
16
+ import { useArticleList, useArticle } from '../../vue/composables/useArticles'
17
+ import type { ArticleListParams } from '../../vue/composables/useArticles'
18
+ import { useNavigation } from '../../vue/composables/useNavigation'
19
+
20
+ // Nuxt's useAsyncData type (declared to avoid importing from #imports at compile time)
21
+ declare function useAsyncData<T>(
22
+ key: string,
23
+ handler: () => Promise<T>,
24
+ opts?: { watch?: unknown[] }
25
+ ): Promise<{ data: Ref<T | null>; pending: Ref<boolean>; error: Ref<Error | null> }>
26
+
27
+ /**
28
+ * SSR-hydrated article list.
29
+ *
30
+ * Wraps useArticleList with Nuxt's useAsyncData.
31
+ */
32
+ export async function useAsyncArticleList(
33
+ key: string,
34
+ params?: ArticleListParams,
35
+ watchDeps?: unknown[],
36
+ ) {
37
+ const composable = useArticleList(params)
38
+
39
+ const { data } = await useAsyncData(
40
+ key,
41
+ async () => {
42
+ await composable.fetch(params)
43
+ return {
44
+ articles: composable.articles.value,
45
+ totalCount: composable.totalCount.value,
46
+ }
47
+ },
48
+ watchDeps ? { watch: watchDeps } : undefined,
49
+ )
50
+
51
+ // Hydrate from useAsyncData result
52
+ if (data.value) {
53
+ composable.articles.value = data.value.articles
54
+ composable.totalCount.value = data.value.totalCount
55
+ }
56
+
57
+ return composable
58
+ }
59
+
60
+ /**
61
+ * SSR-hydrated single article.
62
+ *
63
+ * Wraps useArticle with Nuxt's useAsyncData.
64
+ */
65
+ export async function useAsyncArticle(
66
+ key: string,
67
+ filename: Ref<string> | string,
68
+ languageCode: Ref<string> | string,
69
+ watchDeps?: unknown[],
70
+ ) {
71
+ const composable = useArticle()
72
+
73
+ const getFilename = () => typeof filename === 'string' ? filename : filename.value
74
+ const getLang = () => typeof languageCode === 'string' ? languageCode : languageCode.value
75
+
76
+ const { data } = await useAsyncData(
77
+ key,
78
+ async () => {
79
+ await composable.fetch(getFilename(), getLang())
80
+ return composable.article.value
81
+ },
82
+ watchDeps ? { watch: watchDeps } : undefined,
83
+ )
84
+
85
+ if (data.value) {
86
+ composable.article.value = data.value
87
+ }
88
+
89
+ return composable
90
+ }
91
+
92
+ /**
93
+ * SSR-hydrated navigation menu.
94
+ *
95
+ * Wraps useNavigation with Nuxt's useAsyncData.
96
+ */
97
+ export async function useAsyncNavigation(
98
+ key: string,
99
+ params?: { scope?: string; locale?: string },
100
+ watchDeps?: unknown[],
101
+ ) {
102
+ const composable = useNavigation()
103
+
104
+ const { data } = await useAsyncData(
105
+ key,
106
+ async () => {
107
+ await composable.fetch(params)
108
+ return composable.tree.value
109
+ },
110
+ watchDeps ? { watch: watchDeps } : undefined,
111
+ )
112
+
113
+ if (data.value) {
114
+ composable.tree.value = data.value
115
+ }
116
+
117
+ return composable
118
+ }
119
+
@@ -0,0 +1,6 @@
1
+ // Nuxt SSR adapter — useAsyncData wrappers
2
+ export {
3
+ useAsyncArticleList,
4
+ useAsyncArticle,
5
+ useAsyncNavigation,
6
+ } from './composables/useAsyncKb'
@@ -0,0 +1,215 @@
1
+ /**
2
+ * React MDX renderer (SDK version) — Fix 3.
3
+ *
4
+ * Mirrors the Vue `KbMdxContent.vue` path: parses content (frontmatter strip
5
+ * + `HAS_MDX_RE` fast-path + `MDX_COMPONENT_PATTERN` walk), runs prepareProps
6
+ * on each item.props using getComponentMetadata, then renders via a consumer-
7
+ * supplied component registry passed via prop (or via context).
8
+ *
9
+ * Framework-neutral by design: the SDK does NOT depend on
10
+ * `@blogmcp/mdx-render-react`. Consumers that want the built-in render
11
+ * components can import from that package and pass the resulting map as
12
+ * `components`; consumers building a custom design system pass their own.
13
+ *
14
+ * Marked instance: configured with a pluggable image renderer (default from
15
+ * the SDK's `defaultImageHtml`) so consumers can swap in IPX / Cloudinary /
16
+ * etc. Mirrors the Vue path one-for-one.
17
+ */
18
+
19
+ import {
20
+ Fragment,
21
+ createElement,
22
+ type ComponentType,
23
+ type ReactNode,
24
+ } from 'react'
25
+ import { Marked } from 'marked'
26
+ import {
27
+ HAS_MDX_RE,
28
+ MDX_COMPONENT_PATTERN,
29
+ parseJsxProps,
30
+ stripFrontmatter,
31
+ } from '@blogmcp/mdx-schema/composables/parsing'
32
+ import { sanitizeHtml } from '@blogmcp/sanitize'
33
+ import { prepareProps, getComponentMetadata } from '../core'
34
+ import { defaultImageHtml } from '../core/markdown'
35
+ import type { ImageHtmlRenderer } from '../core/client-types'
36
+
37
+ /** Per-component map a consumer passes into `<KbMdxContent components={…} />`. */
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ export type KbMdxComponentRegistry = Record<string, ComponentType<any>>
40
+
41
+ export interface KbMdxContentProps {
42
+ /** Raw MDX/markdown source (frontmatter allowed; it is stripped). */
43
+ content: string
44
+ /**
45
+ * Consumer-supplied registry mapping schema component names → React
46
+ * components. When a component is missing, the renderer falls back to
47
+ * the yellow "Unknown component" box (same UX as the Vue path).
48
+ */
49
+ components?: KbMdxComponentRegistry
50
+ /** Optional custom image HTML renderer; defaults to the SDK's plain <img>. */
51
+ imageRenderer?: ImageHtmlRenderer
52
+ }
53
+
54
+ interface ParsedItem {
55
+ type: 'html' | 'component'
56
+ content?: string
57
+ name?: string
58
+ props?: Record<string, unknown>
59
+ children?: string
60
+ }
61
+
62
+ function buildMarked(imageRenderer: ImageHtmlRenderer): Marked {
63
+ return new Marked({
64
+ renderer: {
65
+ image({ href, title, text }) {
66
+ if (!href) return ''
67
+ return imageRenderer(href, text, title)
68
+ },
69
+ link({ href, title, text }) {
70
+ const titleAttr = title ? ` title="${title}"` : ''
71
+ if (href && /^https?:\/\//.test(href)) {
72
+ return `<a href="${href}"${titleAttr} target="_blank" rel="noopener noreferrer">${text}</a>`
73
+ }
74
+ return `<a href="${href}"${titleAttr}>${text}</a>`
75
+ },
76
+ },
77
+ hooks: {
78
+ postprocess(html) {
79
+ return html
80
+ .replace(/<table>/g, '<div class="overflow-x-auto -mx-4 px-4"><table>')
81
+ .replace(/<\/table>/g, '</table></div>')
82
+ .replace(/<th>/g, '<th scope="col">')
83
+ },
84
+ },
85
+ })
86
+ }
87
+
88
+ function parseContent(content: string, marked: Marked):
89
+ | { mode: 'html'; html: string; items: never[] }
90
+ | { mode: 'mdx'; items: ParsedItem[]; html: '' } {
91
+ if (!content) return { mode: 'html', html: '', items: [] }
92
+
93
+ const source = stripFrontmatter(content)
94
+
95
+ if (!HAS_MDX_RE.test(source)) {
96
+ return { mode: 'html', html: sanitizeHtml(marked.parse(source) as string), items: [] }
97
+ }
98
+
99
+ const componentRe = new RegExp(MDX_COMPONENT_PATTERN.source, 'g')
100
+ const items: ParsedItem[] = []
101
+ let lastIndex = 0
102
+ let match: RegExpExecArray | null
103
+
104
+ while ((match = componentRe.exec(source)) !== null) {
105
+ if (match.index > lastIndex) {
106
+ const md = source.slice(lastIndex, match.index)
107
+ if (md.trim()) {
108
+ items.push({ type: 'html', content: sanitizeHtml(marked.parse(md) as string) })
109
+ }
110
+ }
111
+ const name = match[1] || match[4] || ''
112
+ const propsStr = match[1] ? match[2] || '' : match[5] || ''
113
+ const children = match[3]
114
+ const rawProps = parseJsxProps(propsStr)
115
+ // Normalize against the schema's deprecation entries (parallel of the
116
+ // Vue path). Fix 2/3: the SDK guarantees normalized props REGARDLESS of
117
+ // which renderer the consumer wires.
118
+ const meta = getComponentMetadata(name)
119
+ const normalizedProps = meta ? prepareProps(rawProps, meta) : rawProps
120
+ items.push({
121
+ type: 'component',
122
+ name,
123
+ props: normalizedProps,
124
+ children: children?.trim(),
125
+ })
126
+ lastIndex = match.index + match[0].length
127
+ }
128
+
129
+ if (lastIndex < source.length) {
130
+ const remaining = source.slice(lastIndex)
131
+ if (remaining.trim()) {
132
+ items.push({ type: 'html', content: sanitizeHtml(marked.parse(remaining) as string) })
133
+ }
134
+ }
135
+
136
+ if (items.length === 0 && source.trim()) {
137
+ return { mode: 'html', html: sanitizeHtml(marked.parse(source) as string), items: [] }
138
+ }
139
+
140
+ return { mode: 'mdx', items, html: '' }
141
+ }
142
+
143
+ /**
144
+ * Render an MDX item tree as React nodes.
145
+ *
146
+ * Recurses into component children by re-running the parser on the raw
147
+ * child string (mirrors the Vue + mdx-render-react behavior). Children
148
+ * are normalized via the same prepareProps shim because they pass back
149
+ * through the same parser on every recursive call.
150
+ */
151
+ function renderItems(
152
+ items: ParsedItem[],
153
+ components: KbMdxComponentRegistry,
154
+ imageRenderer: ImageHtmlRenderer,
155
+ ): ReactNode[] {
156
+ const marked = buildMarked(imageRenderer)
157
+ return items.map((item, index) => {
158
+ if (item.type === 'html') {
159
+ return createElement('div', {
160
+ key: index,
161
+ dangerouslySetInnerHTML: { __html: item.content },
162
+ })
163
+ }
164
+ const Comp = components[item.name!]
165
+ if (!Comp) {
166
+ return createElement(
167
+ 'div',
168
+ {
169
+ key: index,
170
+ className:
171
+ 'bg-yellow-50 border border-yellow-200 rounded-lg p-4 my-4 text-yellow-800',
172
+ },
173
+ `Unknown component: ${item.name}`,
174
+ )
175
+ }
176
+ let childNode: ReactNode = undefined
177
+ if (item.children) {
178
+ const parsed = parseContent(item.children, marked)
179
+ if (parsed.mode === 'html') {
180
+ childNode = createElement('div', {
181
+ dangerouslySetInnerHTML: { __html: parsed.html },
182
+ })
183
+ } else {
184
+ childNode = renderItems(parsed.items, components, imageRenderer)
185
+ }
186
+ }
187
+ return createElement(Comp, { key: index, ...item.props }, childNode)
188
+ })
189
+ }
190
+
191
+ export function KbMdxContent({
192
+ content,
193
+ components = {},
194
+ imageRenderer,
195
+ }: KbMdxContentProps): ReactNode {
196
+ const renderer = imageRenderer ?? defaultImageHtml
197
+ const marked = buildMarked(renderer)
198
+ const parsed = parseContent(content, marked)
199
+
200
+ if (parsed.mode === 'html') {
201
+ return createElement('div', {
202
+ className: 'mdx-content',
203
+ dangerouslySetInnerHTML: { __html: parsed.html },
204
+ })
205
+ }
206
+
207
+ const nodes = renderItems(parsed.items, components, renderer)
208
+ return createElement(
209
+ 'div',
210
+ { className: 'mdx-content' },
211
+ nodes.map((node, i) => createElement(Fragment, { key: i }, node)),
212
+ )
213
+ }
214
+
215
+ export default KbMdxContent
@@ -0,0 +1,25 @@
1
+ 'use client'
2
+
3
+ /**
4
+ * React context for the KB Blog SDK (client side).
5
+ *
6
+ * Mirrors the four values the Vue plugin provides (client, auth, i18n, image
7
+ * renderer). Created by `<KbProvider>` and consumed by the hooks. Server-side
8
+ * data fetching in RSC does NOT use this — it calls `createServerKbClient()`
9
+ * from `@blogmcp/sdk/react/server` directly.
10
+ */
11
+
12
+ import { createContext } from 'react'
13
+ import type { KbClient } from '../core/client'
14
+ import type { AuthManager } from '../core/auth'
15
+ import type { TranslateFn } from '../core/i18n'
16
+ import type { ImageHtmlRenderer } from '../core/client-types'
17
+
18
+ export interface KbContextValue {
19
+ client: KbClient
20
+ auth: AuthManager
21
+ i18n: TranslateFn
22
+ imageRenderer: ImageHtmlRenderer
23
+ }
24
+
25
+ export const KbContext = createContext<KbContextValue | null>(null)
@@ -0,0 +1,15 @@
1
+ 'use client'
2
+
3
+ import { useContext } from 'react'
4
+ import type { ImageHtmlRenderer } from '../../core/client-types'
5
+ import { defaultImageHtml } from '../../core/markdown'
6
+ import { KbContext } from '../context'
7
+
8
+ /**
9
+ * Access the image HTML renderer from the nearest <KbProvider>.
10
+ * Falls back to a plain <img> renderer when used outside a provider.
11
+ */
12
+ export function useImageRenderer(): ImageHtmlRenderer {
13
+ const ctx = useContext(KbContext)
14
+ return ctx?.imageRenderer ?? defaultImageHtml
15
+ }
@@ -0,0 +1,9 @@
1
+ 'use client'
2
+
3
+ import type { KbClient } from '../../core/client'
4
+ import { useKbContext } from './useKbContext'
5
+
6
+ /** Access the KbClient from the nearest <KbProvider>. */
7
+ export function useKbClient(): KbClient {
8
+ return useKbContext().client
9
+ }
@@ -0,0 +1,13 @@
1
+ 'use client'
2
+
3
+ import { useContext } from 'react'
4
+ import { KbContext, type KbContextValue } from '../context'
5
+
6
+ /** Internal: read the KbProvider context or throw a helpful error. */
7
+ export function useKbContext(): KbContextValue {
8
+ const ctx = useContext(KbContext)
9
+ if (!ctx) {
10
+ throw new Error('useKb* hooks must be used within a <KbProvider>')
11
+ }
12
+ return ctx
13
+ }
@@ -0,0 +1,15 @@
1
+ 'use client'
2
+
3
+ import { useContext } from 'react'
4
+ import type { TranslateFn } from '../../core/i18n'
5
+ import { KbContext } from '../context'
6
+
7
+ /**
8
+ * Access the translation function from the nearest <KbProvider>.
9
+ * Falls back to returning the key as-is when used outside a provider
10
+ * (mirrors the Vue `useKbI18n` graceful fallback).
11
+ */
12
+ export function useKbI18n(): TranslateFn {
13
+ const ctx = useContext(KbContext)
14
+ return ctx?.i18n ?? ((key: string) => key)
15
+ }
@@ -0,0 +1,105 @@
1
+ 'use client'
2
+
3
+ import { useCallback, useMemo, useState } from 'react'
4
+ import type { Language, LocalizedTag } from '../../core/types'
5
+ import { retryWithBackoff } from '../../core/retry'
6
+ import { useKbClient } from './useKbClient'
7
+
8
+ const DEFAULT_LANGUAGES: Language[] = [
9
+ { id: '1', code: 'cs', name: 'Czech', nativeName: 'Čeština', isSource: true, isEnabled: true, sortOrder: 0 },
10
+ { id: '2', code: 'en', name: 'English', nativeName: 'English', isSource: false, isEnabled: true, sortOrder: 1 },
11
+ ]
12
+
13
+ export interface UseKbLanguageReturn {
14
+ currentLanguage: string
15
+ languages: Language[]
16
+ languagesLoaded: boolean
17
+ sourceLanguage: Language | null
18
+ targetLanguages: Language[]
19
+ currentLanguageName: string
20
+ isSourceLanguage: boolean
21
+ loadLanguages: () => Promise<void>
22
+ setLanguage: (code: string) => void
23
+ getLanguage: (code: string) => Language | undefined
24
+ fetchLocalizedTags: () => Promise<LocalizedTag[]>
25
+ }
26
+
27
+ /**
28
+ * Language-management hook (the React analogue of the Vue `useKbLanguage`).
29
+ *
30
+ * Framework-agnostic — doesn't depend on Next routing. Consumers pass the
31
+ * initial language and call `setLanguage()` for changes.
32
+ */
33
+ export function useKbLanguage(initialLocale = 'cs'): UseKbLanguageReturn {
34
+ const client = useKbClient()
35
+
36
+ const [currentLanguage, setCurrentLanguage] = useState(initialLocale)
37
+ const [languages, setLanguages] = useState<Language[]>([...DEFAULT_LANGUAGES])
38
+ const [languagesLoaded, setLanguagesLoaded] = useState(false)
39
+
40
+ const sourceLanguage = useMemo(
41
+ () => languages.find((l) => l.isSource) || null,
42
+ [languages],
43
+ )
44
+ const targetLanguages = useMemo(
45
+ () => languages.filter((l) => !l.isSource),
46
+ [languages],
47
+ )
48
+ const currentLanguageName = useMemo(() => {
49
+ const lang = languages.find((l) => l.code === currentLanguage)
50
+ return lang?.nativeName || lang?.name || currentLanguage
51
+ }, [languages, currentLanguage])
52
+ const isSourceLanguage = useMemo(
53
+ () => sourceLanguage?.code === currentLanguage,
54
+ [sourceLanguage, currentLanguage],
55
+ )
56
+
57
+ const getLanguage = useCallback(
58
+ (code: string) => languages.find((l) => l.code === code),
59
+ [languages],
60
+ )
61
+
62
+ const setLanguage = useCallback((code: string) => {
63
+ setCurrentLanguage(code)
64
+ }, [])
65
+
66
+ const loadLanguages = useCallback(async () => {
67
+ if (languagesLoaded) return
68
+ try {
69
+ const data = await retryWithBackoff(() => client.languages.list(), {
70
+ retries: 3,
71
+ initialDelay: 500,
72
+ })
73
+ setLanguages(data.kbLanguages || [])
74
+ setLanguagesLoaded(true)
75
+ } catch {
76
+ setLanguages([...DEFAULT_LANGUAGES])
77
+ }
78
+ }, [client, languagesLoaded])
79
+
80
+ const fetchLocalizedTags = useCallback(async (): Promise<LocalizedTag[]> => {
81
+ try {
82
+ const data = await retryWithBackoff(
83
+ () => client.tags.listLocalized(currentLanguage),
84
+ { retries: 3, initialDelay: 500 },
85
+ )
86
+ return data.localizedTags || []
87
+ } catch {
88
+ return []
89
+ }
90
+ }, [client, currentLanguage])
91
+
92
+ return {
93
+ currentLanguage,
94
+ languages,
95
+ languagesLoaded,
96
+ sourceLanguage,
97
+ targetLanguages,
98
+ currentLanguageName,
99
+ isSourceLanguage,
100
+ loadLanguages,
101
+ setLanguage,
102
+ getLanguage,
103
+ fetchLocalizedTags,
104
+ }
105
+ }
@@ -0,0 +1,50 @@
1
+ 'use client'
2
+
3
+ import { useCallback, useState } from 'react'
4
+ import type { SearchResult } from '../../core/types'
5
+ import { useKbClient } from './useKbClient'
6
+
7
+ export type SearchMode = 'SEMANTIC' | 'KEYWORD' | 'HYBRID'
8
+
9
+ export interface UseKbSearchReturn {
10
+ results: SearchResult[]
11
+ loading: boolean
12
+ error: Error | null
13
+ search: (params: {
14
+ query: string
15
+ tags?: string[]
16
+ contentType?: string
17
+ limit?: number
18
+ minSimilarity?: number
19
+ searchMode?: SearchMode
20
+ }) => Promise<void>
21
+ }
22
+
23
+ /**
24
+ * Reactive search hook (the React analogue of the Vue `useKbSearch`).
25
+ * Supports hybrid search (vector + BM25) via the `searchMode` parameter.
26
+ */
27
+ export function useKbSearch(): UseKbSearchReturn {
28
+ const client = useKbClient()
29
+ const [results, setResults] = useState<SearchResult[]>([])
30
+ const [loading, setLoading] = useState(false)
31
+ const [error, setError] = useState<Error | null>(null)
32
+
33
+ const search = useCallback<UseKbSearchReturn['search']>(
34
+ async (params) => {
35
+ setLoading(true)
36
+ setError(null)
37
+ try {
38
+ const data = await client.search.query(params)
39
+ setResults(data.searchKnowledgeBase)
40
+ } catch (e) {
41
+ setError(e instanceof Error ? e : new Error(String(e)))
42
+ } finally {
43
+ setLoading(false)
44
+ }
45
+ },
46
+ [client],
47
+ )
48
+
49
+ return { results, loading, error, search }
50
+ }