@btst/stack 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -709
- package/dist/api/index.cjs +2 -1
- package/dist/api/index.d.cts +4 -3
- package/dist/api/index.d.mts +4 -3
- package/dist/api/index.d.ts +4 -3
- package/dist/api/index.mjs +1 -1
- package/dist/client/components/compose.cjs +68 -0
- package/dist/client/components/compose.mjs +65 -0
- package/dist/client/components/error-boundary.cjs +24 -0
- package/dist/client/components/error-boundary.mjs +22 -0
- package/dist/client/components/index.cjs +10 -0
- package/dist/client/components/index.d.cts +52 -0
- package/dist/client/components/index.d.mts +52 -0
- package/dist/client/components/index.d.ts +52 -0
- package/dist/client/components/index.mjs +2 -0
- package/dist/client/index.cjs +24 -5
- package/dist/client/index.d.cts +125 -8
- package/dist/client/index.d.mts +125 -8
- package/dist/client/index.d.ts +125 -8
- package/dist/client/index.mjs +21 -4
- package/dist/client/meta-utils.cjs +162 -0
- package/dist/client/meta-utils.mjs +160 -0
- package/dist/client/path-utils.cjs +15 -0
- package/dist/client/path-utils.mjs +13 -0
- package/dist/client/sitemap-utils.cjs +14 -0
- package/dist/client/sitemap-utils.mjs +12 -0
- package/dist/context/index.cjs +6 -63
- package/dist/context/index.d.cts +21 -24
- package/dist/context/index.d.mts +21 -24
- package/dist/context/index.d.ts +21 -24
- package/dist/context/index.mjs +1 -61
- package/dist/context/provider.cjs +51 -0
- package/dist/context/provider.mjs +46 -0
- package/dist/index.cjs +2 -3
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +1 -2
- package/dist/plugins/api/index.cjs +13 -0
- package/dist/plugins/api/index.d.cts +40 -0
- package/dist/plugins/api/index.d.mts +40 -0
- package/dist/plugins/api/index.d.ts +40 -0
- package/dist/plugins/api/index.mjs +8 -0
- package/dist/plugins/blog/api/index.cjs +11 -0
- package/dist/plugins/blog/api/index.d.cts +7 -0
- package/dist/plugins/blog/api/index.d.mts +7 -0
- package/dist/plugins/blog/api/index.d.ts +7 -0
- package/dist/plugins/blog/api/index.mjs +2 -0
- package/dist/plugins/blog/api/plugin.cjs +569 -0
- package/dist/plugins/blog/api/plugin.mjs +565 -0
- package/dist/plugins/blog/client/components/forms/image-field.cjs +133 -0
- package/dist/plugins/blog/client/components/forms/image-field.mjs +131 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.cjs +106 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.mjs +104 -0
- package/dist/plugins/blog/client/components/forms/post-forms.cjs +401 -0
- package/dist/plugins/blog/client/components/forms/post-forms.mjs +398 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.cjs +71 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.mjs +65 -0
- package/dist/plugins/blog/client/components/index.cjs +17 -0
- package/dist/plugins/blog/client/components/index.d.cts +22 -0
- package/dist/plugins/blog/client/components/index.d.mts +22 -0
- package/dist/plugins/blog/client/components/index.d.ts +22 -0
- package/dist/plugins/blog/client/components/index.mjs +12 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.cjs +62 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.mjs +60 -0
- package/dist/plugins/blog/client/components/loading/index.cjs +20 -0
- package/dist/plugins/blog/client/components/loading/index.mjs +16 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.cjs +26 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.mjs +24 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.cjs +13 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.mjs +11 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.cjs +22 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.mjs +20 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.cjs +56 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.mjs +54 -0
- package/dist/plugins/blog/client/components/pages/404-page.cjs +19 -0
- package/dist/plugins/blog/client/components/pages/404-page.mjs +17 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.cjs +57 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.mjs +55 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/home-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/home-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.cjs +37 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.cjs +53 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.mjs +51 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.mjs +35 -0
- package/dist/plugins/blog/client/components/pages/post-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.cjs +101 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.mjs +99 -0
- package/dist/plugins/blog/client/components/pages/post-page.mjs +37 -0
- package/dist/plugins/blog/client/components/pages/tag-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/tag-page.mjs +37 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/default-error.cjs +18 -0
- package/dist/plugins/blog/client/components/shared/default-error.mjs +16 -0
- package/dist/plugins/blog/client/components/shared/defaults.cjs +13 -0
- package/dist/plugins/blog/client/components/shared/defaults.mjs +10 -0
- package/dist/plugins/blog/client/components/shared/empty-list.cjs +21 -0
- package/dist/plugins/blog/client/components/shared/empty-list.mjs +19 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.cjs +53 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.mjs +51 -0
- package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.cjs +324 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.mjs +315 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.cjs +161 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.mjs +158 -0
- package/dist/plugins/blog/client/components/shared/page-header.cjs +40 -0
- package/dist/plugins/blog/client/components/shared/page-header.mjs +38 -0
- package/dist/plugins/blog/client/components/shared/page-layout.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/page-layout.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.cjs +23 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.mjs +21 -0
- package/dist/plugins/blog/client/components/shared/post-card.cjs +279 -0
- package/dist/plugins/blog/client/components/shared/post-card.mjs +277 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.cjs +74 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.mjs +72 -0
- package/dist/plugins/blog/client/components/shared/posts-list.cjs +48 -0
- package/dist/plugins/blog/client/components/shared/posts-list.mjs +46 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.cjs +59 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.mjs +57 -0
- package/dist/plugins/blog/client/components/shared/search-input.cjs +136 -0
- package/dist/plugins/blog/client/components/shared/search-input.mjs +117 -0
- package/dist/plugins/blog/client/components/shared/search-modal.cjs +135 -0
- package/dist/plugins/blog/client/components/shared/search-modal.mjs +116 -0
- package/dist/plugins/blog/client/components/shared/tags-list.cjs +22 -0
- package/dist/plugins/blog/client/components/shared/tags-list.mjs +20 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.cjs +50 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.mjs +48 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.cjs +380 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.mjs +368 -0
- package/dist/plugins/blog/client/hooks/index.cjs +17 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.mts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.ts +150 -0
- package/dist/plugins/blog/client/hooks/index.mjs +1 -0
- package/dist/plugins/blog/client/hooks/use-debounce.cjs +16 -0
- package/dist/plugins/blog/client/hooks/use-debounce.mjs +14 -0
- package/dist/plugins/blog/client/index.cjs +7 -0
- package/dist/plugins/blog/client/index.d.cts +414 -0
- package/dist/plugins/blog/client/index.d.mts +414 -0
- package/dist/plugins/blog/client/index.d.ts +414 -0
- package/dist/plugins/blog/client/index.mjs +1 -0
- package/dist/plugins/blog/client/localization/blog-card.cjs +7 -0
- package/dist/plugins/blog/client/localization/blog-card.mjs +5 -0
- package/dist/plugins/blog/client/localization/blog-common.cjs +10 -0
- package/dist/plugins/blog/client/localization/blog-common.mjs +8 -0
- package/dist/plugins/blog/client/localization/blog-forms.cjs +40 -0
- package/dist/plugins/blog/client/localization/blog-forms.mjs +38 -0
- package/dist/plugins/blog/client/localization/blog-list.cjs +18 -0
- package/dist/plugins/blog/client/localization/blog-list.mjs +16 -0
- package/dist/plugins/blog/client/localization/blog-post.cjs +13 -0
- package/dist/plugins/blog/client/localization/blog-post.mjs +11 -0
- package/dist/plugins/blog/client/localization/index.cjs +17 -0
- package/dist/plugins/blog/client/localization/index.mjs +15 -0
- package/dist/plugins/blog/client/plugin.cjs +462 -0
- package/dist/plugins/blog/client/plugin.mjs +460 -0
- package/dist/plugins/blog/client.css +3 -0
- package/dist/plugins/blog/db.cjs +90 -0
- package/dist/plugins/blog/db.mjs +88 -0
- package/dist/plugins/blog/query-keys.cjs +181 -0
- package/dist/plugins/blog/query-keys.d.cts +530 -0
- package/dist/plugins/blog/query-keys.d.mts +530 -0
- package/dist/plugins/blog/query-keys.d.ts +530 -0
- package/dist/plugins/blog/query-keys.mjs +179 -0
- package/dist/plugins/blog/schemas.cjs +39 -0
- package/dist/plugins/blog/schemas.mjs +35 -0
- package/dist/plugins/blog/style.css +22 -0
- package/dist/plugins/blog/utils.cjs +97 -0
- package/dist/plugins/blog/utils.mjs +87 -0
- package/dist/plugins/client/index.cjs +15 -0
- package/dist/plugins/client/index.d.cts +57 -0
- package/dist/plugins/client/index.d.mts +57 -0
- package/dist/plugins/client/index.d.ts +57 -0
- package/dist/plugins/client/index.mjs +9 -0
- package/dist/{shared/stack.3OUyGp_E.mjs → plugins/utils.mjs} +1 -1
- package/dist/shared/{stack.DORw_1ps.d.cts → stack.ByOugz9d.d.cts} +17 -1
- package/dist/shared/{stack.DORw_1ps.d.mts → stack.ByOugz9d.d.mts} +17 -1
- package/dist/shared/{stack.DORw_1ps.d.ts → stack.ByOugz9d.d.ts} +17 -1
- package/dist/shared/stack.CoPoHVfV.d.cts +76 -0
- package/dist/shared/stack.CoPoHVfV.d.mts +76 -0
- package/dist/shared/stack.CoPoHVfV.d.ts +76 -0
- package/package.json +102 -14
- package/src/__tests__/plugins.test.tsx +539 -0
- package/src/__tests__/sitemap.test.ts +60 -0
- package/src/api/index.ts +75 -0
- package/src/client/components/compose.tsx +116 -0
- package/src/client/components/error-boundary.tsx +30 -0
- package/src/client/components/index.tsx +2 -0
- package/src/client/index.ts +109 -0
- package/src/client/meta-utils.ts +228 -0
- package/src/client/path-utils.ts +38 -0
- package/src/client/sitemap-utils.ts +46 -0
- package/src/context/index.ts +1 -0
- package/src/context/provider.tsx +157 -0
- package/src/index.ts +1 -0
- package/src/plugins/api/index.ts +50 -0
- package/src/plugins/blog/api/index.ts +2 -0
- package/src/plugins/blog/api/plugin.ts +759 -0
- package/src/plugins/blog/client/components/forms/image-field.tsx +165 -0
- package/src/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/src/plugins/blog/client/components/forms/markdown-editor.tsx +136 -0
- package/src/plugins/blog/client/components/forms/post-forms.tsx +531 -0
- package/src/plugins/blog/client/components/forms/tags-multiselect.tsx +79 -0
- package/src/plugins/blog/client/components/index.tsx +11 -0
- package/src/plugins/blog/client/components/loading/form-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/loading/index.tsx +27 -0
- package/src/plugins/blog/client/components/loading/list-page-skeleton.tsx +38 -0
- package/src/plugins/blog/client/components/loading/page-header-skeleton.tsx +10 -0
- package/src/plugins/blog/client/components/loading/post-card-skeleton.tsx +30 -0
- package/src/plugins/blog/client/components/loading/post-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/pages/404-page.tsx +23 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +60 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.tsx +40 -0
- package/src/plugins/blog/client/components/pages/home-page.internal.tsx +71 -0
- package/src/plugins/blog/client/components/pages/home-page.tsx +42 -0
- package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +59 -0
- package/src/plugins/blog/client/components/pages/new-post-page.tsx +36 -0
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +142 -0
- package/src/plugins/blog/client/components/pages/post-page.tsx +38 -0
- package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +74 -0
- package/src/plugins/blog/client/components/pages/tag-page.tsx +38 -0
- package/src/plugins/blog/client/components/shared/better-blog-attribution.tsx +19 -0
- package/src/plugins/blog/client/components/shared/default-error.tsx +20 -0
- package/src/plugins/blog/client/components/shared/defaults.tsx +9 -0
- package/src/plugins/blog/client/components/shared/empty-list.tsx +25 -0
- package/src/plugins/blog/client/components/shared/error-placeholder.tsx +20 -0
- package/src/plugins/blog/client/components/shared/highlight-text.tsx +80 -0
- package/src/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/src/plugins/blog/client/components/shared/markdown-content.tsx +448 -0
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +234 -0
- package/src/plugins/blog/client/components/shared/page-header.tsx +35 -0
- package/src/plugins/blog/client/components/shared/page-layout.tsx +23 -0
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +32 -0
- package/src/plugins/blog/client/components/shared/post-card.tsx +308 -0
- package/src/plugins/blog/client/components/shared/post-navigation.tsx +98 -0
- package/src/plugins/blog/client/components/shared/posts-list.tsx +67 -0
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +79 -0
- package/src/plugins/blog/client/components/shared/search-input.tsx +146 -0
- package/src/plugins/blog/client/components/shared/search-modal.tsx +162 -0
- package/src/plugins/blog/client/components/shared/tags-list.tsx +34 -0
- package/src/plugins/blog/client/components/shared/use-route-lifecycle.tsx +68 -0
- package/src/plugins/blog/client/hooks/blog-hooks.tsx +623 -0
- package/src/plugins/blog/client/hooks/index.tsx +1 -0
- package/src/plugins/blog/client/hooks/use-debounce.ts +43 -0
- package/src/plugins/blog/client/index.ts +9 -0
- package/src/plugins/blog/client/localization/blog-card.ts +3 -0
- package/src/plugins/blog/client/localization/blog-common.ts +7 -0
- package/src/plugins/blog/client/localization/blog-forms.ts +45 -0
- package/src/plugins/blog/client/localization/blog-list.ts +14 -0
- package/src/plugins/blog/client/localization/blog-post.ts +9 -0
- package/src/plugins/blog/client/localization/index.ts +15 -0
- package/src/plugins/blog/client/overrides.ts +123 -0
- package/src/plugins/blog/client/plugin.tsx +672 -0
- package/src/plugins/blog/client.css +3 -0
- package/src/plugins/blog/db.ts +90 -0
- package/src/plugins/blog/query-keys.ts +267 -0
- package/src/plugins/blog/schemas.ts +39 -0
- package/src/plugins/blog/style.css +22 -0
- package/src/plugins/blog/types.ts +37 -0
- package/src/plugins/blog/utils.ts +144 -0
- package/src/plugins/client/index.ts +53 -0
- package/src/plugins/index.ts +0 -0
- package/src/plugins/utils.ts +35 -0
- package/src/types.ts +209 -0
- package/dist/plugins/index.cjs +0 -15
- package/dist/plugins/index.d.cts +0 -64
- package/dist/plugins/index.d.mts +0 -64
- package/dist/plugins/index.d.ts +0 -64
- package/dist/plugins/index.mjs +0 -11
- package/dist/shared/stack.DrUAVfIH.d.cts +0 -17
- package/dist/shared/stack.DrUAVfIH.d.mts +0 -17
- package/dist/shared/stack.DrUAVfIH.d.ts +0 -17
- /package/dist/{shared/stack.CktCg4PJ.cjs → plugins/utils.cjs} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const context = require('@btst/stack/context');
|
|
6
|
+
const button = require('@workspace/ui/components/button');
|
|
7
|
+
const lucideReact = require('lucide-react');
|
|
8
|
+
const defaults = require('./defaults.cjs');
|
|
9
|
+
|
|
10
|
+
function PostNavigation({
|
|
11
|
+
previousPost,
|
|
12
|
+
nextPost,
|
|
13
|
+
ref
|
|
14
|
+
}) {
|
|
15
|
+
const { Link } = context.usePluginOverrides("blog", {
|
|
16
|
+
Link: defaults.DefaultLink
|
|
17
|
+
});
|
|
18
|
+
const basePath = context.useBasePath();
|
|
19
|
+
const blogPath = `${basePath}/blog`;
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
21
|
+
ref && /* @__PURE__ */ jsxRuntime.jsx("div", { ref }),
|
|
22
|
+
(previousPost || nextPost) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
23
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t mt-4 pt-4 w-full" }),
|
|
24
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col sm:flex-row gap-4 w-full justify-between", children: [
|
|
25
|
+
previousPost ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
26
|
+
Link,
|
|
27
|
+
{
|
|
28
|
+
"data-testid": "previous-post-link",
|
|
29
|
+
href: `${blogPath}/${previousPost.slug}`,
|
|
30
|
+
className: "flex-1 sm:max-w-1/3",
|
|
31
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
+
button.Button,
|
|
33
|
+
{
|
|
34
|
+
variant: "outline",
|
|
35
|
+
className: "w-full justify-start py-4 px-4 whitespace-normal! h-full hover:cursor-pointer",
|
|
36
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 w-full min-w-0", children: [
|
|
37
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4 shrink-0" }),
|
|
38
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-start min-w-0 flex-1", children: [
|
|
39
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Previous" }),
|
|
40
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold line-clamp-2 text-sm leading-tight transition-colors text-start", children: previousPost.title })
|
|
41
|
+
] })
|
|
42
|
+
] })
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1" }),
|
|
47
|
+
nextPost ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
48
|
+
Link,
|
|
49
|
+
{
|
|
50
|
+
"data-testid": "next-post-link",
|
|
51
|
+
href: `${blogPath}/${nextPost.slug}`,
|
|
52
|
+
className: "flex-1 sm:max-w-1/3",
|
|
53
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
54
|
+
button.Button,
|
|
55
|
+
{
|
|
56
|
+
variant: "outline",
|
|
57
|
+
className: "w-full justify-end py-4 px-4 whitespace-normal! h-full hover:cursor-pointer",
|
|
58
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 w-full min-w-0", children: [
|
|
59
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-end min-w-0 flex-1", children: [
|
|
60
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Next" }),
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold line-clamp-2 text-sm leading-tight transition-colors text-start", children: nextPost.title })
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 shrink-0" })
|
|
64
|
+
] })
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1" })
|
|
69
|
+
] })
|
|
70
|
+
] })
|
|
71
|
+
] });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
exports.PostNavigation = PostNavigation;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { usePluginOverrides, useBasePath } from '@btst/stack/context';
|
|
4
|
+
import { Button } from '@workspace/ui/components/button';
|
|
5
|
+
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
6
|
+
import { DefaultLink } from './defaults.mjs';
|
|
7
|
+
|
|
8
|
+
function PostNavigation({
|
|
9
|
+
previousPost,
|
|
10
|
+
nextPost,
|
|
11
|
+
ref
|
|
12
|
+
}) {
|
|
13
|
+
const { Link } = usePluginOverrides("blog", {
|
|
14
|
+
Link: DefaultLink
|
|
15
|
+
});
|
|
16
|
+
const basePath = useBasePath();
|
|
17
|
+
const blogPath = `${basePath}/blog`;
|
|
18
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
+
ref && /* @__PURE__ */ jsx("div", { ref }),
|
|
20
|
+
(previousPost || nextPost) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
21
|
+
/* @__PURE__ */ jsx("div", { className: "border-t mt-4 pt-4 w-full" }),
|
|
22
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col sm:flex-row gap-4 w-full justify-between", children: [
|
|
23
|
+
previousPost ? /* @__PURE__ */ jsx(
|
|
24
|
+
Link,
|
|
25
|
+
{
|
|
26
|
+
"data-testid": "previous-post-link",
|
|
27
|
+
href: `${blogPath}/${previousPost.slug}`,
|
|
28
|
+
className: "flex-1 sm:max-w-1/3",
|
|
29
|
+
children: /* @__PURE__ */ jsx(
|
|
30
|
+
Button,
|
|
31
|
+
{
|
|
32
|
+
variant: "outline",
|
|
33
|
+
className: "w-full justify-start py-4 px-4 whitespace-normal! h-full hover:cursor-pointer",
|
|
34
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 w-full min-w-0", children: [
|
|
35
|
+
/* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4 shrink-0" }),
|
|
36
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start min-w-0 flex-1", children: [
|
|
37
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Previous" }),
|
|
38
|
+
/* @__PURE__ */ jsx("div", { className: "font-semibold line-clamp-2 text-sm leading-tight transition-colors text-start", children: previousPost.title })
|
|
39
|
+
] })
|
|
40
|
+
] })
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
) : /* @__PURE__ */ jsx("div", { className: "flex-1" }),
|
|
45
|
+
nextPost ? /* @__PURE__ */ jsx(
|
|
46
|
+
Link,
|
|
47
|
+
{
|
|
48
|
+
"data-testid": "next-post-link",
|
|
49
|
+
href: `${blogPath}/${nextPost.slug}`,
|
|
50
|
+
className: "flex-1 sm:max-w-1/3",
|
|
51
|
+
children: /* @__PURE__ */ jsx(
|
|
52
|
+
Button,
|
|
53
|
+
{
|
|
54
|
+
variant: "outline",
|
|
55
|
+
className: "w-full justify-end py-4 px-4 whitespace-normal! h-full hover:cursor-pointer",
|
|
56
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 w-full min-w-0", children: [
|
|
57
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-end min-w-0 flex-1", children: [
|
|
58
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Next" }),
|
|
59
|
+
/* @__PURE__ */ jsx("div", { className: "font-semibold line-clamp-2 text-sm leading-tight transition-colors text-start", children: nextPost.title })
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })
|
|
62
|
+
] })
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
) : /* @__PURE__ */ jsx("div", { className: "flex-1" })
|
|
67
|
+
] })
|
|
68
|
+
] })
|
|
69
|
+
] });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { PostNavigation };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
const context = require('@btst/stack/context');
|
|
5
|
+
const button = require('@workspace/ui/components/button');
|
|
6
|
+
const emptyList = require('./empty-list.cjs');
|
|
7
|
+
const searchInput = require('./search-input.cjs');
|
|
8
|
+
const postCard = require('./post-card.cjs');
|
|
9
|
+
const index = require('../../localization/index.cjs');
|
|
10
|
+
|
|
11
|
+
function PostsList({
|
|
12
|
+
posts,
|
|
13
|
+
onLoadMore,
|
|
14
|
+
hasMore,
|
|
15
|
+
isLoadingMore
|
|
16
|
+
}) {
|
|
17
|
+
const { localization } = context.usePluginOverrides("blog", {
|
|
18
|
+
localization: index.BLOG_LOCALIZATION
|
|
19
|
+
});
|
|
20
|
+
const { PostCard } = context.usePluginOverrides("blog");
|
|
21
|
+
const PostCardComponent = PostCard || postCard.PostCard;
|
|
22
|
+
if (posts.length === 0) {
|
|
23
|
+
return /* @__PURE__ */ jsxRuntime.jsx(emptyList.EmptyList, { message: localization.BLOG_LIST_EMPTY });
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full space-y-6", children: [
|
|
26
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center pb-6", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
|
+
searchInput.SearchInput,
|
|
28
|
+
{
|
|
29
|
+
placeholder: localization.BLOG_LIST_SEARCH_PLACEHOLDER,
|
|
30
|
+
buttonText: localization.BLOG_LIST_SEARCH_BUTTON,
|
|
31
|
+
emptyMessage: localization.BLOG_LIST_SEARCH_EMPTY
|
|
32
|
+
}
|
|
33
|
+
) }),
|
|
34
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3", children: posts.map((post) => /* @__PURE__ */ jsxRuntime.jsx(PostCardComponent, { post }, post.id)) }),
|
|
35
|
+
onLoadMore && hasMore && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
|
+
button.Button,
|
|
37
|
+
{
|
|
38
|
+
onClick: onLoadMore,
|
|
39
|
+
disabled: isLoadingMore,
|
|
40
|
+
variant: "outline",
|
|
41
|
+
size: "lg",
|
|
42
|
+
children: isLoadingMore ? localization.BLOG_LIST_LOADING_MORE : localization.BLOG_LIST_LOAD_MORE
|
|
43
|
+
}
|
|
44
|
+
) })
|
|
45
|
+
] });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
exports.PostsList = PostsList;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { usePluginOverrides } from '@btst/stack/context';
|
|
3
|
+
import { Button } from '@workspace/ui/components/button';
|
|
4
|
+
import { EmptyList } from './empty-list.mjs';
|
|
5
|
+
import { SearchInput } from './search-input.mjs';
|
|
6
|
+
import { PostCard } from './post-card.mjs';
|
|
7
|
+
import { BLOG_LOCALIZATION } from '../../localization/index.mjs';
|
|
8
|
+
|
|
9
|
+
function PostsList({
|
|
10
|
+
posts,
|
|
11
|
+
onLoadMore,
|
|
12
|
+
hasMore,
|
|
13
|
+
isLoadingMore
|
|
14
|
+
}) {
|
|
15
|
+
const { localization } = usePluginOverrides("blog", {
|
|
16
|
+
localization: BLOG_LOCALIZATION
|
|
17
|
+
});
|
|
18
|
+
const { PostCard: PostCard$1 } = usePluginOverrides("blog");
|
|
19
|
+
const PostCardComponent = PostCard$1 || PostCard;
|
|
20
|
+
if (posts.length === 0) {
|
|
21
|
+
return /* @__PURE__ */ jsx(EmptyList, { message: localization.BLOG_LIST_EMPTY });
|
|
22
|
+
}
|
|
23
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full space-y-6", children: [
|
|
24
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-center pb-6", children: /* @__PURE__ */ jsx(
|
|
25
|
+
SearchInput,
|
|
26
|
+
{
|
|
27
|
+
placeholder: localization.BLOG_LIST_SEARCH_PLACEHOLDER,
|
|
28
|
+
buttonText: localization.BLOG_LIST_SEARCH_BUTTON,
|
|
29
|
+
emptyMessage: localization.BLOG_LIST_SEARCH_EMPTY
|
|
30
|
+
}
|
|
31
|
+
) }),
|
|
32
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3", children: posts.map((post) => /* @__PURE__ */ jsx(PostCardComponent, { post }, post.id)) }),
|
|
33
|
+
onLoadMore && hasMore && /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
|
|
34
|
+
Button,
|
|
35
|
+
{
|
|
36
|
+
onClick: onLoadMore,
|
|
37
|
+
disabled: isLoadingMore,
|
|
38
|
+
variant: "outline",
|
|
39
|
+
size: "lg",
|
|
40
|
+
children: isLoadingMore ? localization.BLOG_LIST_LOADING_MORE : localization.BLOG_LIST_LOAD_MORE
|
|
41
|
+
}
|
|
42
|
+
) })
|
|
43
|
+
] });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { PostsList };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const context = require('@btst/stack/context');
|
|
6
|
+
const carousel = require('@workspace/ui/components/carousel');
|
|
7
|
+
const postCard = require('./post-card.cjs');
|
|
8
|
+
const defaults = require('./defaults.cjs');
|
|
9
|
+
const index = require('../../localization/index.cjs');
|
|
10
|
+
|
|
11
|
+
function RecentPostsCarousel({ posts, ref }) {
|
|
12
|
+
const { PostCard, Link, localization } = context.usePluginOverrides("blog", {
|
|
13
|
+
PostCard: postCard.PostCard,
|
|
14
|
+
Link: defaults.DefaultLink,
|
|
15
|
+
localization: index.BLOG_LOCALIZATION
|
|
16
|
+
});
|
|
17
|
+
const PostCardComponent = PostCard || postCard.PostCard;
|
|
18
|
+
const basePath = context.useBasePath();
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
|
|
20
|
+
ref && /* @__PURE__ */ jsxRuntime.jsx("div", { ref }),
|
|
21
|
+
posts && posts.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
22
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 py-4 w-full text-start border-t", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-4 flex items-center justify-between", children: [
|
|
23
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-semibold", children: localization.BLOG_POST_KEEP_READING }),
|
|
24
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
25
|
+
Link,
|
|
26
|
+
{
|
|
27
|
+
href: `${basePath}/blog`,
|
|
28
|
+
className: "text-sm text-muted-foreground hover:text-foreground transition-colors",
|
|
29
|
+
children: localization.BLOG_POST_VIEW_ALL
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
] }) }),
|
|
33
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "recent-posts-carousel", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
34
|
+
carousel.Carousel,
|
|
35
|
+
{
|
|
36
|
+
opts: {
|
|
37
|
+
align: "start",
|
|
38
|
+
loop: false
|
|
39
|
+
},
|
|
40
|
+
className: "w-full",
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ jsxRuntime.jsx(carousel.CarouselContent, { className: "-ml-2 md:-ml-4", children: posts.map((post) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
43
|
+
carousel.CarouselItem,
|
|
44
|
+
{
|
|
45
|
+
className: "pl-2 md:pl-4 md:basis-1/2 lg:basis-1/3",
|
|
46
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PostCardComponent, { post })
|
|
47
|
+
},
|
|
48
|
+
post.id
|
|
49
|
+
)) }),
|
|
50
|
+
/* @__PURE__ */ jsxRuntime.jsx(carousel.CarouselPrevious, { className: "-left-4 lg:-left-12 hover:cursor-pointer" }),
|
|
51
|
+
/* @__PURE__ */ jsxRuntime.jsx(carousel.CarouselNext, { className: "-right-4 lg:-right-12 hover:cursor-pointer" })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
) })
|
|
55
|
+
] })
|
|
56
|
+
] });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.RecentPostsCarousel = RecentPostsCarousel;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { usePluginOverrides, useBasePath } from '@btst/stack/context';
|
|
4
|
+
import { Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext } from '@workspace/ui/components/carousel';
|
|
5
|
+
import { PostCard } from './post-card.mjs';
|
|
6
|
+
import { DefaultLink } from './defaults.mjs';
|
|
7
|
+
import { BLOG_LOCALIZATION } from '../../localization/index.mjs';
|
|
8
|
+
|
|
9
|
+
function RecentPostsCarousel({ posts, ref }) {
|
|
10
|
+
const { PostCard: PostCard$1, Link, localization } = usePluginOverrides("blog", {
|
|
11
|
+
PostCard: PostCard,
|
|
12
|
+
Link: DefaultLink,
|
|
13
|
+
localization: BLOG_LOCALIZATION
|
|
14
|
+
});
|
|
15
|
+
const PostCardComponent = PostCard$1 || PostCard;
|
|
16
|
+
const basePath = useBasePath();
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
18
|
+
ref && /* @__PURE__ */ jsx("div", { ref }),
|
|
19
|
+
posts && posts.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
20
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 py-4 w-full text-start border-t", children: /* @__PURE__ */ jsxs("div", { className: "mt-4 flex items-center justify-between", children: [
|
|
21
|
+
/* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: localization.BLOG_POST_KEEP_READING }),
|
|
22
|
+
/* @__PURE__ */ jsx(
|
|
23
|
+
Link,
|
|
24
|
+
{
|
|
25
|
+
href: `${basePath}/blog`,
|
|
26
|
+
className: "text-sm text-muted-foreground hover:text-foreground transition-colors",
|
|
27
|
+
children: localization.BLOG_POST_VIEW_ALL
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
] }) }),
|
|
31
|
+
/* @__PURE__ */ jsx("div", { "data-testid": "recent-posts-carousel", children: /* @__PURE__ */ jsxs(
|
|
32
|
+
Carousel,
|
|
33
|
+
{
|
|
34
|
+
opts: {
|
|
35
|
+
align: "start",
|
|
36
|
+
loop: false
|
|
37
|
+
},
|
|
38
|
+
className: "w-full",
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx(CarouselContent, { className: "-ml-2 md:-ml-4", children: posts.map((post) => /* @__PURE__ */ jsx(
|
|
41
|
+
CarouselItem,
|
|
42
|
+
{
|
|
43
|
+
className: "pl-2 md:pl-4 md:basis-1/2 lg:basis-1/3",
|
|
44
|
+
children: /* @__PURE__ */ jsx(PostCardComponent, { post })
|
|
45
|
+
},
|
|
46
|
+
post.id
|
|
47
|
+
)) }),
|
|
48
|
+
/* @__PURE__ */ jsx(CarouselPrevious, { className: "-left-4 lg:-left-12 hover:cursor-pointer" }),
|
|
49
|
+
/* @__PURE__ */ jsx(CarouselNext, { className: "-right-4 lg:-right-12 hover:cursor-pointer" })
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
) })
|
|
53
|
+
] })
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { RecentPostsCarousel };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const React = require('react');
|
|
8
|
+
const blogHooks = require('../../hooks/blog-hooks.cjs');
|
|
9
|
+
const utils = require('../../../utils.cjs');
|
|
10
|
+
const highlightText = require('./highlight-text.cjs');
|
|
11
|
+
const searchModal = require('./search-modal.cjs');
|
|
12
|
+
const context = require('@btst/stack/context');
|
|
13
|
+
|
|
14
|
+
function _interopNamespaceCompat(e) {
|
|
15
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
16
|
+
const n = Object.create(null);
|
|
17
|
+
if (e) {
|
|
18
|
+
for (const k in e) {
|
|
19
|
+
n[k] = e[k];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return n;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
|
|
27
|
+
|
|
28
|
+
const renderBlogResult = (item, index, query) => {
|
|
29
|
+
const q = (query || "").toLowerCase();
|
|
30
|
+
const excerptMatches = item.processedExcerpt ? item.processedExcerpt.toLowerCase().includes(q) : false;
|
|
31
|
+
const contentMatches = item.processedContent ? item.processedContent.toLowerCase().includes(q) : false;
|
|
32
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
33
|
+
"button",
|
|
34
|
+
{
|
|
35
|
+
"data-testid": "search-result",
|
|
36
|
+
type: "button",
|
|
37
|
+
className: "flex w-full cursor-pointer flex-col gap-2 rounded-sm border-border border-b px-4 py-3 text-left transition-colors hover:bg-accent",
|
|
38
|
+
onClick: () => item.onClick?.(),
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
41
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
42
|
+
highlightText.HighlightText,
|
|
43
|
+
{
|
|
44
|
+
text: item.title,
|
|
45
|
+
searchQuery: query,
|
|
46
|
+
className: "flex-1 font-medium text-sm leading-5"
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
item.publishedAt && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "whitespace-nowrap text-muted-foreground text-xs", children: new Date(item.publishedAt).toLocaleDateString() })
|
|
50
|
+
] }),
|
|
51
|
+
excerptMatches && /* @__PURE__ */ jsxRuntime.jsx(
|
|
52
|
+
highlightText.HighlightText,
|
|
53
|
+
{
|
|
54
|
+
text: item.processedExcerpt || "",
|
|
55
|
+
searchQuery: query,
|
|
56
|
+
className: "text-muted-foreground text-xs leading-4",
|
|
57
|
+
maxLength: 120
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
contentMatches && /* @__PURE__ */ jsxRuntime.jsx(
|
|
61
|
+
highlightText.HighlightText,
|
|
62
|
+
{
|
|
63
|
+
text: item.processedContent,
|
|
64
|
+
searchQuery: query,
|
|
65
|
+
className: "text-muted-foreground text-xs leading-4",
|
|
66
|
+
maxLength: 120
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
!excerptMatches && !contentMatches && /* @__PURE__ */ jsxRuntime.jsx(
|
|
70
|
+
highlightText.HighlightText,
|
|
71
|
+
{
|
|
72
|
+
text: item.processedExcerpt || item.processedContent,
|
|
73
|
+
searchQuery: query,
|
|
74
|
+
className: "text-muted-foreground text-xs leading-4",
|
|
75
|
+
maxLength: 120
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
item.id
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
function SearchInput({
|
|
84
|
+
className,
|
|
85
|
+
triggerClassName,
|
|
86
|
+
placeholder,
|
|
87
|
+
buttonText,
|
|
88
|
+
emptyMessage
|
|
89
|
+
}) {
|
|
90
|
+
const { navigate } = context.usePluginOverrides("blog");
|
|
91
|
+
const basePath = context.useBasePath();
|
|
92
|
+
const [currentQuery, setCurrentQuery] = React__namespace.useState("");
|
|
93
|
+
const { data: searchResults = [], isLoading } = blogHooks.usePostSearch({
|
|
94
|
+
query: currentQuery,
|
|
95
|
+
enabled: currentQuery.trim().length > 0,
|
|
96
|
+
debounceMs: 300,
|
|
97
|
+
published: true
|
|
98
|
+
});
|
|
99
|
+
const formattedResults = React__namespace.useMemo(() => {
|
|
100
|
+
return searchResults.map((post) => ({
|
|
101
|
+
id: post.id,
|
|
102
|
+
title: post.title,
|
|
103
|
+
slug: post.slug,
|
|
104
|
+
publishedAt: post.publishedAt,
|
|
105
|
+
authorName: "",
|
|
106
|
+
processedContent: utils.stripMarkdown(utils.stripHtml(post.content || "")),
|
|
107
|
+
processedExcerpt: utils.stripMarkdown(utils.stripHtml(post.excerpt || "")),
|
|
108
|
+
onClick: () => navigate(`${basePath}/blog/${post.slug}`)
|
|
109
|
+
}));
|
|
110
|
+
}, [searchResults, navigate, basePath]);
|
|
111
|
+
const handleSearch = React__namespace.useCallback(
|
|
112
|
+
(query) => {
|
|
113
|
+
setCurrentQuery(query);
|
|
114
|
+
return [];
|
|
115
|
+
},
|
|
116
|
+
[]
|
|
117
|
+
);
|
|
118
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
119
|
+
searchModal.SearchModal,
|
|
120
|
+
{
|
|
121
|
+
placeholder,
|
|
122
|
+
buttonText,
|
|
123
|
+
emptyMessage,
|
|
124
|
+
searchFn: handleSearch,
|
|
125
|
+
renderResult: renderBlogResult,
|
|
126
|
+
results: formattedResults,
|
|
127
|
+
isLoading,
|
|
128
|
+
className,
|
|
129
|
+
triggerClassName,
|
|
130
|
+
keyboardShortcut: "\u2318K"
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
exports.SearchInput = SearchInput;
|
|
136
|
+
exports.default = SearchInput;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { usePostSearch } from '../../hooks/blog-hooks.mjs';
|
|
5
|
+
import { stripMarkdown, stripHtml } from '../../../utils.mjs';
|
|
6
|
+
import { HighlightText } from './highlight-text.mjs';
|
|
7
|
+
import { SearchModal } from './search-modal.mjs';
|
|
8
|
+
import { usePluginOverrides, useBasePath } from '@btst/stack/context';
|
|
9
|
+
|
|
10
|
+
const renderBlogResult = (item, index, query) => {
|
|
11
|
+
const q = (query || "").toLowerCase();
|
|
12
|
+
const excerptMatches = item.processedExcerpt ? item.processedExcerpt.toLowerCase().includes(q) : false;
|
|
13
|
+
const contentMatches = item.processedContent ? item.processedContent.toLowerCase().includes(q) : false;
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
15
|
+
"button",
|
|
16
|
+
{
|
|
17
|
+
"data-testid": "search-result",
|
|
18
|
+
type: "button",
|
|
19
|
+
className: "flex w-full cursor-pointer flex-col gap-2 rounded-sm border-border border-b px-4 py-3 text-left transition-colors hover:bg-accent",
|
|
20
|
+
onClick: () => item.onClick?.(),
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
23
|
+
/* @__PURE__ */ jsx(
|
|
24
|
+
HighlightText,
|
|
25
|
+
{
|
|
26
|
+
text: item.title,
|
|
27
|
+
searchQuery: query,
|
|
28
|
+
className: "flex-1 font-medium text-sm leading-5"
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
item.publishedAt && /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap text-muted-foreground text-xs", children: new Date(item.publishedAt).toLocaleDateString() })
|
|
32
|
+
] }),
|
|
33
|
+
excerptMatches && /* @__PURE__ */ jsx(
|
|
34
|
+
HighlightText,
|
|
35
|
+
{
|
|
36
|
+
text: item.processedExcerpt || "",
|
|
37
|
+
searchQuery: query,
|
|
38
|
+
className: "text-muted-foreground text-xs leading-4",
|
|
39
|
+
maxLength: 120
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
contentMatches && /* @__PURE__ */ jsx(
|
|
43
|
+
HighlightText,
|
|
44
|
+
{
|
|
45
|
+
text: item.processedContent,
|
|
46
|
+
searchQuery: query,
|
|
47
|
+
className: "text-muted-foreground text-xs leading-4",
|
|
48
|
+
maxLength: 120
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
!excerptMatches && !contentMatches && /* @__PURE__ */ jsx(
|
|
52
|
+
HighlightText,
|
|
53
|
+
{
|
|
54
|
+
text: item.processedExcerpt || item.processedContent,
|
|
55
|
+
searchQuery: query,
|
|
56
|
+
className: "text-muted-foreground text-xs leading-4",
|
|
57
|
+
maxLength: 120
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
item.id
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
function SearchInput({
|
|
66
|
+
className,
|
|
67
|
+
triggerClassName,
|
|
68
|
+
placeholder,
|
|
69
|
+
buttonText,
|
|
70
|
+
emptyMessage
|
|
71
|
+
}) {
|
|
72
|
+
const { navigate } = usePluginOverrides("blog");
|
|
73
|
+
const basePath = useBasePath();
|
|
74
|
+
const [currentQuery, setCurrentQuery] = React.useState("");
|
|
75
|
+
const { data: searchResults = [], isLoading } = usePostSearch({
|
|
76
|
+
query: currentQuery,
|
|
77
|
+
enabled: currentQuery.trim().length > 0,
|
|
78
|
+
debounceMs: 300,
|
|
79
|
+
published: true
|
|
80
|
+
});
|
|
81
|
+
const formattedResults = React.useMemo(() => {
|
|
82
|
+
return searchResults.map((post) => ({
|
|
83
|
+
id: post.id,
|
|
84
|
+
title: post.title,
|
|
85
|
+
slug: post.slug,
|
|
86
|
+
publishedAt: post.publishedAt,
|
|
87
|
+
authorName: "",
|
|
88
|
+
processedContent: stripMarkdown(stripHtml(post.content || "")),
|
|
89
|
+
processedExcerpt: stripMarkdown(stripHtml(post.excerpt || "")),
|
|
90
|
+
onClick: () => navigate(`${basePath}/blog/${post.slug}`)
|
|
91
|
+
}));
|
|
92
|
+
}, [searchResults, navigate, basePath]);
|
|
93
|
+
const handleSearch = React.useCallback(
|
|
94
|
+
(query) => {
|
|
95
|
+
setCurrentQuery(query);
|
|
96
|
+
return [];
|
|
97
|
+
},
|
|
98
|
+
[]
|
|
99
|
+
);
|
|
100
|
+
return /* @__PURE__ */ jsx(
|
|
101
|
+
SearchModal,
|
|
102
|
+
{
|
|
103
|
+
placeholder,
|
|
104
|
+
buttonText,
|
|
105
|
+
emptyMessage,
|
|
106
|
+
searchFn: handleSearch,
|
|
107
|
+
renderResult: renderBlogResult,
|
|
108
|
+
results: formattedResults,
|
|
109
|
+
isLoading,
|
|
110
|
+
className,
|
|
111
|
+
triggerClassName,
|
|
112
|
+
keyboardShortcut: "\u2318K"
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { SearchInput, SearchInput as default };
|