astro-tractstack 2.0.0-rc.42 → 2.0.0-rc.44
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/package.json
CHANGED
|
@@ -78,7 +78,7 @@ export default function SearchModal({
|
|
|
78
78
|
>
|
|
79
79
|
<Portal>
|
|
80
80
|
<Dialog.Backdrop className="fixed inset-0 z-50 bg-black bg-opacity-50 backdrop-blur-sm" />
|
|
81
|
-
<Dialog.Positioner className="fixed inset-0 z-50 mx-auto max-w-
|
|
81
|
+
<Dialog.Positioner className="fixed inset-0 z-50 mx-auto max-w-5xl p-2 pt-16 md:p-4">
|
|
82
82
|
<Dialog.Content
|
|
83
83
|
className="bg-mywhite mx-auto w-full overflow-hidden rounded-lg shadow-2xl"
|
|
84
84
|
style={{ height: '80vh' }}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { useState, useMemo } from 'react';
|
|
2
2
|
import { Pagination } from '@ark-ui/react/pagination';
|
|
3
|
-
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline';
|
|
4
3
|
import type { SearchResults as SearchResultsType } from '@/hooks/useSearch';
|
|
5
4
|
import type { FullContentMapItem } from '@/types/tractstack';
|
|
6
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getResourceUrl,
|
|
7
|
+
getResourceImage,
|
|
8
|
+
getResourceDescription,
|
|
9
|
+
} from '@/utils/customHelpers';
|
|
7
10
|
|
|
8
11
|
interface SearchResultsProps {
|
|
9
12
|
results: SearchResultsType;
|
|
@@ -84,12 +87,18 @@ export default function SearchResults({
|
|
|
84
87
|
item.slug,
|
|
85
88
|
item.categorySlug || ''
|
|
86
89
|
);
|
|
90
|
+
const description = getResourceDescription(
|
|
91
|
+
item.id,
|
|
92
|
+
item.slug,
|
|
93
|
+
item.categorySlug || ''
|
|
94
|
+
);
|
|
87
95
|
|
|
88
96
|
items.push({
|
|
89
97
|
id: item.id,
|
|
90
98
|
type: 'Resource',
|
|
91
99
|
title: item.title,
|
|
92
100
|
slug: item.slug,
|
|
101
|
+
description: description || undefined,
|
|
93
102
|
categorySlug: item.categorySlug || undefined,
|
|
94
103
|
url: resourceUrl,
|
|
95
104
|
imageSrc: resourceImage,
|
|
@@ -114,8 +123,8 @@ export default function SearchResults({
|
|
|
114
123
|
startIndex + ITEMS_PER_PAGE
|
|
115
124
|
);
|
|
116
125
|
|
|
117
|
-
const handlePageChange = (page: number) => {
|
|
118
|
-
setCurrentPage(page);
|
|
126
|
+
const handlePageChange = (details: { page: number }) => {
|
|
127
|
+
setCurrentPage(details.page);
|
|
119
128
|
};
|
|
120
129
|
|
|
121
130
|
const getResultBadge = (type: string, categorySlug?: string) => {
|
|
@@ -170,14 +179,32 @@ export default function SearchResults({
|
|
|
170
179
|
<a href={item.url} onClick={onResultClick} className="group block">
|
|
171
180
|
<div className="flex items-start gap-4">
|
|
172
181
|
<div
|
|
173
|
-
className="bg-mydarkgrey
|
|
174
|
-
style={{
|
|
182
|
+
className="bg-mydarkgrey flex-shrink-0 overflow-hidden rounded-lg p-1 md:hidden"
|
|
183
|
+
style={{
|
|
184
|
+
width: '100px',
|
|
185
|
+
height: '56px',
|
|
186
|
+
}}
|
|
187
|
+
data-mobile-size="100x56"
|
|
188
|
+
>
|
|
189
|
+
<img
|
|
190
|
+
src={item.imageSrc}
|
|
191
|
+
alt={item.title}
|
|
192
|
+
className="h-full w-full rounded object-contain"
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<div
|
|
197
|
+
className="bg-mydarkgrey hidden flex-shrink-0 overflow-hidden rounded-lg p-1 md:block"
|
|
198
|
+
style={{
|
|
199
|
+
width: '240px',
|
|
200
|
+
height: '135px',
|
|
201
|
+
}}
|
|
202
|
+
data-desktop-size="240x135"
|
|
175
203
|
>
|
|
176
204
|
<img
|
|
177
205
|
src={item.imageSrc}
|
|
178
206
|
alt={item.title}
|
|
179
|
-
className="h-full w-full object-contain"
|
|
180
|
-
style={{ width: '100%', height: '100%' }}
|
|
207
|
+
className="h-full w-full rounded object-contain"
|
|
181
208
|
/>
|
|
182
209
|
</div>
|
|
183
210
|
|
|
@@ -190,11 +217,13 @@ export default function SearchResults({
|
|
|
190
217
|
</h3>
|
|
191
218
|
</div>
|
|
192
219
|
|
|
193
|
-
{item.type === 'StoryFragment'
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
220
|
+
{(item.type === 'StoryFragment' ||
|
|
221
|
+
item.type === 'Resource') &&
|
|
222
|
+
item.description && (
|
|
223
|
+
<p className="mb-2 line-clamp-2 text-sm text-gray-600">
|
|
224
|
+
{item.description}
|
|
225
|
+
</p>
|
|
226
|
+
)}
|
|
198
227
|
|
|
199
228
|
{item.topics && item.topics.length > 0 && (
|
|
200
229
|
<div className="mb-2 flex flex-wrap gap-1">
|
|
@@ -217,6 +246,11 @@ export default function SearchResults({
|
|
|
217
246
|
<p className="truncate text-xs text-gray-500">
|
|
218
247
|
{item.url}
|
|
219
248
|
</p>
|
|
249
|
+
|
|
250
|
+
{/* Mobile badge row */}
|
|
251
|
+
<div className="mt-2 block md:hidden">
|
|
252
|
+
{getResultBadge(item.type, item.categorySlug)}
|
|
253
|
+
</div>
|
|
220
254
|
</div>
|
|
221
255
|
|
|
222
256
|
<div className="hidden flex-shrink-0 text-right md:block">
|
|
@@ -233,47 +267,42 @@ export default function SearchResults({
|
|
|
233
267
|
</div>
|
|
234
268
|
|
|
235
269
|
{totalPages > 1 && (
|
|
236
|
-
<div className="flex
|
|
270
|
+
<div className="mt-8 flex justify-center">
|
|
237
271
|
<Pagination.Root
|
|
238
272
|
count={allResultItems.length}
|
|
239
273
|
pageSize={ITEMS_PER_PAGE}
|
|
240
274
|
page={currentPage}
|
|
241
|
-
|
|
275
|
+
siblingCount={1}
|
|
276
|
+
onPageChange={handlePageChange}
|
|
277
|
+
className="flex flex-wrap items-center gap-2"
|
|
242
278
|
>
|
|
243
|
-
<Pagination.PrevTrigger className="text-mydarkgrey flex items-center rounded-md border border-gray-300 px-3 py-2 text-sm hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50">
|
|
244
|
-
<ChevronLeftIcon className="mr-1 h-4 w-4" />
|
|
245
|
-
Previous
|
|
246
|
-
</Pagination.PrevTrigger>
|
|
247
|
-
|
|
248
279
|
<Pagination.Context>
|
|
249
280
|
{(pagination) =>
|
|
250
281
|
pagination.pages.map((page, index) =>
|
|
251
282
|
page.type === 'page' ? (
|
|
252
283
|
<Pagination.Item
|
|
253
284
|
key={index}
|
|
254
|
-
|
|
255
|
-
type="page"
|
|
285
|
+
{...page}
|
|
256
286
|
className={`cursor-pointer rounded-md px-3 py-2 text-sm ${
|
|
257
287
|
page.value === currentPage
|
|
258
|
-
? 'bg-
|
|
259
|
-
: 'text-
|
|
288
|
+
? 'bg-gray-900 text-white'
|
|
289
|
+
: 'border border-gray-300 bg-white text-gray-700 hover:bg-gray-50'
|
|
260
290
|
}`}
|
|
261
291
|
>
|
|
262
292
|
{page.value}
|
|
263
293
|
</Pagination.Item>
|
|
264
294
|
) : (
|
|
265
|
-
<
|
|
266
|
-
|
|
267
|
-
|
|
295
|
+
<Pagination.Ellipsis
|
|
296
|
+
key={index}
|
|
297
|
+
index={index}
|
|
298
|
+
className="px-3 py-2 text-sm text-gray-500"
|
|
299
|
+
>
|
|
300
|
+
…
|
|
301
|
+
</Pagination.Ellipsis>
|
|
268
302
|
)
|
|
269
303
|
)
|
|
270
304
|
}
|
|
271
305
|
</Pagination.Context>
|
|
272
|
-
|
|
273
|
-
<Pagination.NextTrigger className="text-mydarkgrey flex items-center rounded-md border border-gray-300 px-3 py-2 text-sm hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50">
|
|
274
|
-
Next
|
|
275
|
-
<ChevronRightIcon className="ml-1 h-4 w-4" />
|
|
276
|
-
</Pagination.NextTrigger>
|
|
277
306
|
</Pagination.Root>
|
|
278
307
|
</div>
|
|
279
308
|
)}
|
|
@@ -85,13 +85,12 @@ const defaultSocialDesc =
|
|
|
85
85
|
description ||
|
|
86
86
|
brandConfig.OGDESC ||
|
|
87
87
|
`No-code website builder and content marketing platform`;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const socialLogoWithVersion = `${defaultSocialLogoURL}?v=${buildVersion}`;
|
|
88
|
+
const socialImageFullURL = brandConfig?.SITE_URL
|
|
89
|
+
? `${brandConfig.SITE_URL.replace(/\/$/, '')}${defaultSocialImageURL}`
|
|
90
|
+
: `${defaultSocialImageURL}`;
|
|
91
|
+
const socialLogoFullURL = brandConfig?.SITE_URL
|
|
92
|
+
? `${brandConfig.SITE_URL.replace(/\/$/, '')}${defaultSocialLogoURL}`
|
|
93
|
+
: `${defaultSocialLogoURL}`;
|
|
95
94
|
const gtagId = brandConfig?.GTAG || false;
|
|
96
95
|
const gtagUrl =
|
|
97
96
|
typeof gtagId === `string` && gtagId.length > 1
|
|
@@ -144,14 +143,14 @@ const enableBunny = import.meta.env.PUBLIC_ENABLE_BUNNY === 'true';
|
|
|
144
143
|
<meta property="og:type" content="website" />
|
|
145
144
|
<meta property="og:description" content={defaultSocialDesc} />
|
|
146
145
|
<meta property="og:url" content={fullCanonicalUrl} />
|
|
147
|
-
<meta property="og:image" content={
|
|
148
|
-
<meta property="og:logo" content={
|
|
146
|
+
<meta property="og:image" content={socialImageFullURL} />
|
|
147
|
+
<meta property="og:logo" content={socialLogoFullURL} />
|
|
149
148
|
|
|
150
149
|
<meta property="twitter:card" content="summary_large_image" />
|
|
151
150
|
<meta property="twitter:url" content={fullCanonicalUrl} />
|
|
152
151
|
<meta property="twitter:title" content={defaultSocialTitle} />
|
|
153
152
|
<meta property="twitter:description" content={defaultSocialDesc} />
|
|
154
|
-
<meta property="twitter:image" content={
|
|
153
|
+
<meta property="twitter:image" content={socialImageFullURL} />
|
|
155
154
|
|
|
156
155
|
{
|
|
157
156
|
pubDatetime && (
|
|
@@ -22,6 +22,15 @@ export function getResourceImage(
|
|
|
22
22
|
return '/static.jpg';
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export function getResourceDescription(
|
|
26
|
+
id: string,
|
|
27
|
+
slug: string,
|
|
28
|
+
category: string
|
|
29
|
+
): string | null {
|
|
30
|
+
console.log(`please define getResourceDescription`, id, slug, category);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
// Initialize search data - override in custom implementation
|
|
26
35
|
export function initSearch(): void {
|
|
27
36
|
// Default implementation does nothing
|