basklee-react 0.9.20 → 0.9.22
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 +1 -1
- package/templates/components/basklee/blog/BlogArticle.README.md +12 -7
- package/templates/components/basklee/blog/BlogArticle.module.css +86 -2
- package/templates/components/basklee/blog/BlogArticle.tsx +77 -17
- package/templates/components/basklee/blog/BlogPostCard.README.md +8 -7
- package/templates/components/basklee/blog/BlogPostCard.module.css +96 -0
- package/templates/components/basklee/blog/BlogPostCard.tsx +86 -16
- package/templates/lib/basklee/blogArticle.ts +8 -0
- package/templates/lib/basklee/blogCoverSlider.ts +261 -0
- package/templates/lib/basklee/blogImageViewer.ts +2 -1
- package/templates/lib/basklee/blogLabels.ts +6 -0
- package/templates/lib/basklee/blogPresentation.ts +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basklee-react",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.22",
|
|
4
4
|
"description": "Next.js 16 storefront for your Basklee marketplace: setup CLI, server API gateway, typed store and ready-made catalog, cart, checkout and account components in English, Russian and Spanish, plus an Android app build. Powered by Basklee: https://basklee.com",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,9 +15,12 @@ the component shows its unavailable state instead.
|
|
|
15
15
|
Full text appears only while both `is_full` and `has_full_access` are true.
|
|
16
16
|
Otherwise the component uses `post_preview_text` and links to `/tariffs` with
|
|
17
17
|
the selected locale. When `premium_tariff_ids` contains plan IDs, the link also
|
|
18
|
-
passes them in `ids`. The cover
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
passes them in `ids`. The cover shows the post's
|
|
19
|
+
preview pictures (`preview_images` in display order, else `preview_image_urls`)
|
|
20
|
+
in a reserved 3:2 area: one picture, or up to ten side by side that the reader
|
|
21
|
+
leafs through with the arrows, a swipe or the keyboard, with a counter
|
|
22
|
+
(«2 / 5»). A picture that fails to load leaves the row; when none loads, the
|
|
23
|
+
cover disappears. Article videos accept HTTP or HTTPS addresses and the
|
|
21
24
|
backend's `/ps3/...` paths. In an Android app build those paths (cover, videos,
|
|
22
25
|
images and videos inside the text) load from the storefront address.
|
|
23
26
|
|
|
@@ -136,10 +139,12 @@ separate.
|
|
|
136
139
|
Полный текст показывается, только когда `is_full` и `has_full_access` равны
|
|
137
140
|
`true`. В остальных случаях компонент использует `post_preview_text` и даёт
|
|
138
141
|
ссылку на `/tariffs` с выбранной локалью. Если в `premium_tariff_ids` есть
|
|
139
|
-
ID тарифов, ссылка также передаёт их в `ids`.
|
|
140
|
-
по `display_order
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
ID тарифов, ссылка также передаёт их в `ids`. В обложке — изображения анонса публикации
|
|
143
|
+
(`preview_images` по `display_order`, иначе `preview_image_urls`) в области с
|
|
144
|
+
пропорциями 3:2: одно изображение или до десяти в ряд, которые читатель листает
|
|
145
|
+
стрелками, пальцем или с клавиатуры; счётчик показывает «2 / 5». Изображение,
|
|
146
|
+
которое не загрузилось, уходит из ряда; если не загрузилось ни одно, обложка
|
|
147
|
+
исчезает. Компонент выводит только видео с адресами HTTP или HTTPS.
|
|
143
148
|
|
|
144
149
|
Обложка и изображения текста открываются крупно: нажатие, Enter или пробел на
|
|
145
150
|
изображении открывает `ProductReviewImageViewer` на нём, остальные изображения
|
|
@@ -53,14 +53,98 @@
|
|
|
53
53
|
letter-spacing: 0.08em;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/* The cover: the post's preview pictures side by side, swiped on a phone and
|
|
57
|
+
turned by the arrows (lib/basklee/blogCoverSlider). */
|
|
58
|
+
.covers {
|
|
59
|
+
position: relative;
|
|
60
|
+
aspect-ratio: 3 / 2;
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
background: var(--basklee-surface);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.coverTrack {
|
|
66
|
+
display: flex;
|
|
67
|
+
height: 100%;
|
|
68
|
+
overflow: auto hidden;
|
|
69
|
+
overscroll-behavior-x: contain;
|
|
70
|
+
scroll-snap-type: x mandatory;
|
|
71
|
+
scrollbar-width: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.coverTrack::-webkit-scrollbar {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
56
78
|
.cover {
|
|
57
79
|
box-sizing: border-box;
|
|
58
80
|
display: block;
|
|
81
|
+
flex: 0 0 100%;
|
|
59
82
|
width: 100%;
|
|
60
|
-
height:
|
|
61
|
-
aspect-ratio: 3 / 2;
|
|
83
|
+
height: 100%;
|
|
62
84
|
object-fit: cover;
|
|
85
|
+
scroll-snap-align: start;
|
|
86
|
+
scroll-snap-stop: always;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.coverTrack > [hidden],
|
|
90
|
+
.covers[data-blog-cover-single] > .coverStep,
|
|
91
|
+
.covers[data-blog-cover-single] > .coverCount,
|
|
92
|
+
.coverCount:empty {
|
|
93
|
+
display: none;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.coverStep {
|
|
97
|
+
position: absolute;
|
|
98
|
+
top: 50%;
|
|
99
|
+
display: flex;
|
|
100
|
+
width: 44px;
|
|
101
|
+
height: 44px;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
padding: 0;
|
|
105
|
+
border: 1px solid var(--basklee-border);
|
|
106
|
+
border-radius: 0;
|
|
107
|
+
background: var(--basklee-surface);
|
|
108
|
+
color: var(--basklee-text);
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
translate: 0 -50%;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.coverStep svg {
|
|
114
|
+
width: 20px;
|
|
115
|
+
height: 20px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.coverStep[data-blog-cover-step='-1'] {
|
|
119
|
+
left: 12px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.coverStep[data-blog-cover-step='1'] {
|
|
123
|
+
right: 12px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.coverStep:focus-visible {
|
|
127
|
+
outline: 2px solid var(--basklee-accent);
|
|
128
|
+
outline-offset: 2px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@media (hover: hover) {
|
|
132
|
+
.coverStep:hover {
|
|
133
|
+
border-color: var(--basklee-text);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.coverCount {
|
|
138
|
+
position: absolute;
|
|
139
|
+
right: 12px;
|
|
140
|
+
bottom: 12px;
|
|
141
|
+
padding: 2px 8px;
|
|
63
142
|
background: var(--basklee-surface);
|
|
143
|
+
color: var(--basklee-text);
|
|
144
|
+
font-size: 12px;
|
|
145
|
+
line-height: 20px;
|
|
146
|
+
font-variant-numeric: tabular-nums;
|
|
147
|
+
pointer-events: none;
|
|
64
148
|
}
|
|
65
149
|
|
|
66
150
|
.prose {
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { selectIsAuthenticated } from '@/stores/basklee';
|
|
18
18
|
import type { IBlogPost } from '@/interfaces/basklee/blog/IBlogApi';
|
|
19
19
|
import {
|
|
20
|
-
|
|
20
|
+
blogArticleCovers,
|
|
21
21
|
blogArticleField,
|
|
22
22
|
blogArticleMediaUrl,
|
|
23
23
|
blogArticlePlansHref,
|
|
@@ -62,6 +62,7 @@ import {
|
|
|
62
62
|
blogMediaFallbackLabels,
|
|
63
63
|
guardBlogMedia,
|
|
64
64
|
} from '@/lib/basklee/blogMediaFallback';
|
|
65
|
+
import { watchBlogCoverSlider } from '@/lib/basklee/blogCoverSlider';
|
|
65
66
|
import { ProductReviewImageViewer } from '@/components/basklee/products/ProductReviewImageViewer';
|
|
66
67
|
import { ProductCard } from '@/components/basklee/products/ProductCard';
|
|
67
68
|
import {
|
|
@@ -133,7 +134,7 @@ export function BlogArticle({
|
|
|
133
134
|
const [mounted, setMounted] = useState(false);
|
|
134
135
|
const [coverFailed, setCoverFailed] = useState(false);
|
|
135
136
|
const articleRef = useRef<HTMLDivElement>(null);
|
|
136
|
-
const coverRef = useRef<
|
|
137
|
+
const coverRef = useRef<HTMLDivElement>(null);
|
|
137
138
|
// The cover and the text images open larger in the viewer.
|
|
138
139
|
const [viewer, setViewer] = useState<{ images: IBlogViewerImage[]; index: number }>();
|
|
139
140
|
const requestRef = useRef<AbortController | undefined>(undefined);
|
|
@@ -161,7 +162,9 @@ export function BlogArticle({
|
|
|
161
162
|
() => mounted ? safeBlogArticleHtml(articleSource) : '',
|
|
162
163
|
[articleSource, mounted],
|
|
163
164
|
);
|
|
164
|
-
|
|
165
|
+
// Every preview picture of the post: the cover is leafed through when there are several.
|
|
166
|
+
const covers = blogArticleCovers(post);
|
|
167
|
+
const coverKey = covers.join('\n');
|
|
165
168
|
const showSkeleton = !post && !settled && !error;
|
|
166
169
|
// Product cards the author placed in the text (see blogProductPlacements).
|
|
167
170
|
const [placements, setPlacements] = useState<IBlogProductPlacement[]>([]);
|
|
@@ -228,7 +231,17 @@ export function BlogArticle({
|
|
|
228
231
|
|
|
229
232
|
useEffect(() => {
|
|
230
233
|
setCoverFailed(false);
|
|
231
|
-
}, [
|
|
234
|
+
}, [coverKey]);
|
|
235
|
+
|
|
236
|
+
// The cover's arrows and counter, and its pictures that do not load (blogCoverSlider).
|
|
237
|
+
useEffect(
|
|
238
|
+
() =>
|
|
239
|
+
watchBlogCoverSlider(coverRef.current, {
|
|
240
|
+
eager: true,
|
|
241
|
+
onEmpty: () => setCoverFailed(true),
|
|
242
|
+
}),
|
|
243
|
+
[coverKey, coverFailed, mounted],
|
|
244
|
+
);
|
|
232
245
|
|
|
233
246
|
// Pictures, videos and YouTube players of the text that do not load get a placeholder.
|
|
234
247
|
useEffect(() => {
|
|
@@ -244,7 +257,7 @@ export function BlogArticle({
|
|
|
244
257
|
blogViewerImages([coverRef.current, articleRef.current]),
|
|
245
258
|
labels.imageOpen,
|
|
246
259
|
);
|
|
247
|
-
}, [html,
|
|
260
|
+
}, [html, coverKey, coverFailed, mounted, labels.imageOpen, post?.id]);
|
|
248
261
|
|
|
249
262
|
// The text's placement blocks after each render; missing products come
|
|
250
263
|
// with one request per 35.
|
|
@@ -294,7 +307,7 @@ export function BlogArticle({
|
|
|
294
307
|
index,
|
|
295
308
|
images: images.map((image) => {
|
|
296
309
|
const shown = blogViewerImage(image);
|
|
297
|
-
return
|
|
310
|
+
return coverRef.current?.contains(image) ? { ...shown, alt: shown.alt || title } : shown;
|
|
298
311
|
}),
|
|
299
312
|
});
|
|
300
313
|
};
|
|
@@ -381,18 +394,65 @@ export function BlogArticle({
|
|
|
381
394
|
<span>{post.read_time_min} {labels.minutes}</span>
|
|
382
395
|
) : null}
|
|
383
396
|
</div>
|
|
384
|
-
{
|
|
385
|
-
<
|
|
397
|
+
{covers.length && !coverFailed ? (
|
|
398
|
+
<div
|
|
386
399
|
ref={coverRef}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
400
|
+
className={styles.covers}
|
|
401
|
+
data-blog-cover
|
|
402
|
+
>
|
|
403
|
+
<div
|
|
404
|
+
className={styles.coverTrack}
|
|
405
|
+
data-blog-cover-track
|
|
406
|
+
>
|
|
407
|
+
{covers.map((address, index) => (
|
|
408
|
+
<img
|
|
409
|
+
key={address}
|
|
410
|
+
src={index ? undefined : address}
|
|
411
|
+
data-src={index ? address : undefined}
|
|
412
|
+
alt=""
|
|
413
|
+
width={3}
|
|
414
|
+
height={2}
|
|
415
|
+
decoding="async"
|
|
416
|
+
className={styles.cover}
|
|
417
|
+
data-blog-article-cover
|
|
418
|
+
onError={() => {
|
|
419
|
+
if (covers.length < 2) {
|
|
420
|
+
setCoverFailed(true);
|
|
421
|
+
}
|
|
422
|
+
}}
|
|
423
|
+
/>
|
|
424
|
+
))}
|
|
425
|
+
</div>
|
|
426
|
+
{covers.length > 1 ? (
|
|
427
|
+
<>
|
|
428
|
+
{[-1, 1].map((step) => (
|
|
429
|
+
<button
|
|
430
|
+
key={step}
|
|
431
|
+
type="button"
|
|
432
|
+
className={styles.coverStep}
|
|
433
|
+
data-blog-cover-step={step}
|
|
434
|
+
aria-label={step < 0 ? labels.imagePrevious : labels.imageNext}
|
|
435
|
+
>
|
|
436
|
+
<svg
|
|
437
|
+
viewBox="0 0 24 24"
|
|
438
|
+
fill="none"
|
|
439
|
+
stroke="currentColor"
|
|
440
|
+
strokeWidth="1.5"
|
|
441
|
+
strokeLinecap="round"
|
|
442
|
+
strokeLinejoin="round"
|
|
443
|
+
aria-hidden="true"
|
|
444
|
+
>
|
|
445
|
+
<path d={step < 0 ? 'M15 5l-7 7 7 7' : 'M9 5l7 7-7 7'} />
|
|
446
|
+
</svg>
|
|
447
|
+
</button>
|
|
448
|
+
))}
|
|
449
|
+
<span
|
|
450
|
+
className={styles.coverCount}
|
|
451
|
+
data-blog-cover-count
|
|
452
|
+
/>
|
|
453
|
+
</>
|
|
454
|
+
) : null}
|
|
455
|
+
</div>
|
|
396
456
|
) : null}
|
|
397
457
|
</header>
|
|
398
458
|
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
`BlogPostCard` uses `post` when supplied for server rendering; otherwise it
|
|
6
6
|
reads the post identified by `postId` from the browse store. It
|
|
7
7
|
shows the localized plain-text title and preview, publication date, reading
|
|
8
|
-
time and a subscription mark for a non-public article. The
|
|
9
|
-
preview
|
|
10
|
-
uses a deterministic pattern and the title's
|
|
8
|
+
time and a subscription mark for a non-public article. The cover has a
|
|
9
|
+
reserved 3:2 size. Every preview picture of the post is in the cover, in display order, ten at most: the first comes with the page, the others load when the reader comes to the cover. With several pictures the cover shows a mark for each and, where there is a mouse, arrows; on a phone it is swiped. An arrow turns the picture and does not open the article. A picture that fails to load leaves the row. A post without a
|
|
10
|
+
picture, or with none that loads, uses a deterministic pattern and the title's
|
|
11
|
+
first letter.
|
|
11
12
|
|
|
12
13
|
`layout` selects the portrait, list or hero arrangement. With `articlePath`,
|
|
13
14
|
the card is a normal link to `<articlePath>/<postId>` with the current locale;
|
|
@@ -29,10 +30,10 @@ Both forms call `onSelect` with the complete post from the browse store.
|
|
|
29
30
|
`BlogPostCard` использует `post`, если публикация передана для серверной
|
|
30
31
|
отрисовки; иначе он получает из browse store публикацию с указанным `postId`.
|
|
31
32
|
Карточка показывает локализованные название и анонс без HTML, дату публикации,
|
|
32
|
-
время чтения и отметку подписки для непубличной статьи.
|
|
33
|
-
изображение
|
|
34
|
-
нет или
|
|
35
|
-
названия.
|
|
33
|
+
время чтения и отметку подписки для непубличной статьи. Обложка занимает
|
|
34
|
+
зарезервированную область 3:2. В обложке — все изображения анонса публикации по порядку, не больше десяти: первое приходит со страницей, остальные загружаются, когда читатель подходит к обложке. Если изображений несколько, обложка показывает отметку на каждое и, где есть мышь, стрелки; на телефоне её листают пальцем. Стрелка листает изображение и не открывает статью. Изображение, которое не загрузилось, уходит из ряда. Если изображений
|
|
35
|
+
нет или ни одно не загрузилось, компонент показывает постоянный узор и первую
|
|
36
|
+
букву названия.
|
|
36
37
|
|
|
37
38
|
`layout` выбирает вертикальный вид, строку или крупную карточку. Если передан
|
|
38
39
|
`articlePath`, карточка становится обычной ссылкой на
|
|
@@ -34,14 +34,110 @@
|
|
|
34
34
|
background: var(--basklee-surface);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/* The preview pictures side by side: swiped on a phone, turned by the arrows
|
|
38
|
+
with a mouse (lib/basklee/blogCoverSlider). */
|
|
39
|
+
.track {
|
|
40
|
+
display: flex;
|
|
41
|
+
height: 100%;
|
|
42
|
+
overflow: auto hidden;
|
|
43
|
+
overscroll-behavior-x: contain;
|
|
44
|
+
scroll-snap-type: x mandatory;
|
|
45
|
+
scrollbar-width: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.track::-webkit-scrollbar {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
37
52
|
.cover img {
|
|
38
53
|
display: block;
|
|
54
|
+
flex: 0 0 100%;
|
|
39
55
|
width: 100%;
|
|
40
56
|
height: 100%;
|
|
41
57
|
object-fit: cover;
|
|
58
|
+
scroll-snap-align: start;
|
|
59
|
+
scroll-snap-stop: always;
|
|
42
60
|
transition: opacity 160ms ease;
|
|
43
61
|
}
|
|
44
62
|
|
|
63
|
+
.track > [hidden],
|
|
64
|
+
.dots > [hidden],
|
|
65
|
+
.cover[data-blog-cover-single] > .step,
|
|
66
|
+
.cover[data-blog-cover-single] > .dots {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.step {
|
|
71
|
+
position: absolute;
|
|
72
|
+
top: 50%;
|
|
73
|
+
display: flex;
|
|
74
|
+
width: 32px;
|
|
75
|
+
height: 32px;
|
|
76
|
+
align-items: center;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
border: 1px solid var(--basklee-border);
|
|
79
|
+
background: var(--basklee-surface);
|
|
80
|
+
color: var(--basklee-text);
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
opacity: 0;
|
|
83
|
+
translate: 0 -50%;
|
|
84
|
+
transition: opacity 150ms;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.step svg {
|
|
88
|
+
width: 16px;
|
|
89
|
+
height: 16px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.step[data-blog-cover-step='-1'] {
|
|
93
|
+
left: 8px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.step[data-blog-cover-step='1'] {
|
|
97
|
+
right: 8px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.card:focus-visible .step {
|
|
101
|
+
opacity: 1;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@media (hover: hover) {
|
|
105
|
+
.card:hover .step {
|
|
106
|
+
opacity: 1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* A finger swipes the pictures. */
|
|
111
|
+
@media (hover: none) {
|
|
112
|
+
.step {
|
|
113
|
+
display: none;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.dots {
|
|
118
|
+
position: absolute;
|
|
119
|
+
right: 0;
|
|
120
|
+
bottom: 8px;
|
|
121
|
+
left: 0;
|
|
122
|
+
display: flex;
|
|
123
|
+
justify-content: center;
|
|
124
|
+
gap: 6px;
|
|
125
|
+
pointer-events: none;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.dots > i {
|
|
129
|
+
width: 6px;
|
|
130
|
+
height: 6px;
|
|
131
|
+
border-radius: 50%;
|
|
132
|
+
background: var(--basklee-surface);
|
|
133
|
+
box-shadow: 0 0 0 1px var(--basklee-text);
|
|
134
|
+
opacity: 0.5;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.dots > i[data-current] {
|
|
138
|
+
opacity: 1;
|
|
139
|
+
}
|
|
140
|
+
|
|
45
141
|
@media (hover: hover) {
|
|
46
142
|
.card:hover .cover img {
|
|
47
143
|
opacity: 0.85;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useEffect, useState, type MouseEvent } from 'react';
|
|
3
|
+
import { useEffect, useRef, useState, type MouseEvent } from 'react';
|
|
4
4
|
import {
|
|
5
5
|
useBaskleeBrowse,
|
|
6
6
|
useBaskleeSelections,
|
|
@@ -9,12 +9,13 @@ import type { IBlogPostPreview } from '@/interfaces/basklee/blog/IBlogPostPrevie
|
|
|
9
9
|
import {
|
|
10
10
|
blogCoverInitial,
|
|
11
11
|
blogCoverPattern,
|
|
12
|
-
|
|
12
|
+
blogPostCovers,
|
|
13
13
|
blogPostIsPaid,
|
|
14
14
|
blogPostPreview,
|
|
15
15
|
blogPostTitle,
|
|
16
16
|
} from '@/lib/basklee/blogPresentation';
|
|
17
17
|
import { blogLabels } from '@/lib/basklee/blogLabels';
|
|
18
|
+
import { watchBlogCoverSlider } from '@/lib/basklee/blogCoverSlider';
|
|
18
19
|
import styles from './BlogPostCard.module.css';
|
|
19
20
|
|
|
20
21
|
export interface BlogPostCardProps {
|
|
@@ -41,20 +42,40 @@ export function BlogPostCard({
|
|
|
41
42
|
const [coverFailed, setCoverFailed] = useState(false);
|
|
42
43
|
const title = post ? blogPostTitle(post, locale) : String(postId);
|
|
43
44
|
const preview = post ? blogPostPreview(post, locale) : '';
|
|
44
|
-
|
|
45
|
-
const
|
|
45
|
+
// Every preview picture of the post: the cover is leafed through when there are several.
|
|
46
|
+
const covers = blogPostCovers(post);
|
|
47
|
+
const coverKey = covers.join('\n');
|
|
48
|
+
const coverRef = useRef<HTMLSpanElement>(null);
|
|
49
|
+
const showCover = covers.length > 0 && !coverFailed;
|
|
46
50
|
const href = articlePath
|
|
47
51
|
? `${articlePath.replace(/\/+$/, '')}/${postId}?locale=${encodeURIComponent(locale)}`
|
|
48
52
|
: '';
|
|
49
53
|
|
|
50
54
|
useEffect(() => {
|
|
51
55
|
setCoverFailed(false);
|
|
52
|
-
}, [
|
|
56
|
+
}, [coverKey]);
|
|
57
|
+
|
|
58
|
+
// The arrows, the marks and the pictures that do not load (blogCoverSlider).
|
|
59
|
+
useEffect(
|
|
60
|
+
() =>
|
|
61
|
+
watchBlogCoverSlider(coverRef.current, {
|
|
62
|
+
onEmpty: () => setCoverFailed(true),
|
|
63
|
+
}),
|
|
64
|
+
[coverKey, showCover],
|
|
65
|
+
);
|
|
53
66
|
|
|
54
67
|
if (!post) {
|
|
55
68
|
return null;
|
|
56
69
|
}
|
|
57
70
|
|
|
71
|
+
// One picture that does not load is the fallback at once; of several, the
|
|
72
|
+
// broken one leaves the row (blogCoverSlider).
|
|
73
|
+
function onCoverError() {
|
|
74
|
+
if (covers.length < 2) {
|
|
75
|
+
setCoverFailed(true);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
58
79
|
function select(event: MouseEvent<HTMLAnchorElement | HTMLButtonElement>) {
|
|
59
80
|
if (!event.defaultPrevented) {
|
|
60
81
|
onSelect?.(post!);
|
|
@@ -63,24 +84,73 @@ export function BlogPostCard({
|
|
|
63
84
|
|
|
64
85
|
const content = (
|
|
65
86
|
<>
|
|
66
|
-
<span
|
|
87
|
+
<span
|
|
88
|
+
ref={coverRef}
|
|
89
|
+
className={styles.cover}
|
|
90
|
+
data-blog-cover
|
|
91
|
+
>
|
|
67
92
|
{showCover ? (
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
<span
|
|
94
|
+
className={styles.track}
|
|
95
|
+
data-blog-cover-track
|
|
96
|
+
>
|
|
97
|
+
{/* The first picture comes with the page; the others load when the reader comes to the cover. */}
|
|
98
|
+
{covers.map((address, index) => (
|
|
99
|
+
<img
|
|
100
|
+
key={address}
|
|
101
|
+
src={index ? undefined : address}
|
|
102
|
+
data-src={index ? address : undefined}
|
|
103
|
+
alt=""
|
|
104
|
+
width={600}
|
|
105
|
+
height={400}
|
|
106
|
+
loading="lazy"
|
|
107
|
+
decoding="async"
|
|
108
|
+
data-blog-card-cover
|
|
109
|
+
onError={onCoverError}
|
|
110
|
+
/>
|
|
111
|
+
))}
|
|
112
|
+
</span>
|
|
78
113
|
) : (
|
|
79
114
|
<CoverFallback
|
|
80
115
|
postId={post.id}
|
|
81
116
|
title={title}
|
|
82
117
|
/>
|
|
83
118
|
)}
|
|
119
|
+
{showCover && covers.length > 1 ? (
|
|
120
|
+
<>
|
|
121
|
+
{[-1, 1].map((step) => (
|
|
122
|
+
<span
|
|
123
|
+
key={step}
|
|
124
|
+
className={styles.step}
|
|
125
|
+
data-blog-cover-step={step}
|
|
126
|
+
aria-hidden="true"
|
|
127
|
+
>
|
|
128
|
+
<svg
|
|
129
|
+
viewBox="0 0 24 24"
|
|
130
|
+
fill="none"
|
|
131
|
+
stroke="currentColor"
|
|
132
|
+
strokeWidth="1.5"
|
|
133
|
+
strokeLinecap="round"
|
|
134
|
+
strokeLinejoin="round"
|
|
135
|
+
>
|
|
136
|
+
<path d={step < 0 ? 'M15 5l-7 7 7 7' : 'M9 5l7 7-7 7'} />
|
|
137
|
+
</svg>
|
|
138
|
+
</span>
|
|
139
|
+
))}
|
|
140
|
+
<span
|
|
141
|
+
className={styles.dots}
|
|
142
|
+
data-blog-cover-dots
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
>
|
|
145
|
+
{covers.map((address) => (
|
|
146
|
+
<i
|
|
147
|
+
key={address}
|
|
148
|
+
data-blog-cover-dot
|
|
149
|
+
/>
|
|
150
|
+
))}
|
|
151
|
+
</span>
|
|
152
|
+
</>
|
|
153
|
+
) : null}
|
|
84
154
|
{blogPostIsPaid(post) ? (
|
|
85
155
|
<span className={styles.paid}>{labels.subscription}</span>
|
|
86
156
|
) : null}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { blogPreviewImages } from '@/lib/basklee/blogCoverSlider';
|
|
1
2
|
import { EBlogAccessType } from '@/interfaces/basklee/blog/IBlogApi';
|
|
2
3
|
import type {
|
|
3
4
|
IBlogPost,
|
|
@@ -62,6 +63,13 @@ export function blogArticleField(
|
|
|
62
63
|
return getAvailableNestedValueFromObject(post?.locale, locale, field) || '';
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
/** Every preview picture of the article: its cover is leafed through when there are several. */
|
|
67
|
+
export function blogArticleCovers(post: IBlogPost | undefined) {
|
|
68
|
+
return blogPreviewImages(post, (address) =>
|
|
69
|
+
appMediaUrl(safePublicUrl(address), APP_ORIGIN),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
65
73
|
export function blogArticleCover(post: IBlogPost | undefined) {
|
|
66
74
|
const images = [...(post?.preview_images ?? [])].sort(
|
|
67
75
|
(left, right) => left.display_order - right.display_order,
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The preview pictures of a post as a row a reader can leaf through: in the
|
|
3
|
+
* journal's cards and at the top of the article. A post has one picture or
|
|
4
|
+
* several (the panel's «Preview» switch on its images); with several, the
|
|
5
|
+
* cover gets arrows and marks, and on a phone it is swiped.
|
|
6
|
+
*
|
|
7
|
+
* The component draws the markup in its own look; this file gives the list of
|
|
8
|
+
* pictures and makes the markup work:
|
|
9
|
+
*
|
|
10
|
+
* <span data-blog-cover> the cover (the root)
|
|
11
|
+
* <span data-blog-cover-track> a row that scrolls sideways, snap on every picture
|
|
12
|
+
* <img src="…"> the first picture
|
|
13
|
+
* <img data-src="…"> the others: loaded when the reader comes to the cover
|
|
14
|
+
* </span>
|
|
15
|
+
* <span data-blog-cover-step="-1"></span> back; `data-blog-cover-step="1"` forward
|
|
16
|
+
* <span data-blog-cover-dots>
|
|
17
|
+
* <i data-blog-cover-dot></i> … one mark per picture; the shown one gets `data-current`
|
|
18
|
+
* </span>
|
|
19
|
+
* <span data-blog-cover-count></span> «2 / 5»
|
|
20
|
+
* </span>
|
|
21
|
+
*
|
|
22
|
+
* The root gets `data-blog-cover-index` and `data-blog-cover-total`, and
|
|
23
|
+
* `data-blog-cover-single` while one picture is left: arrows and marks are
|
|
24
|
+
* hidden by that attribute. A picture that does not load leaves the row (its
|
|
25
|
+
* slide and one mark get `hidden`, and the image viewer skips it); when none
|
|
26
|
+
* is left, `onEmpty` is called.
|
|
27
|
+
*/
|
|
28
|
+
export const BLOG_PREVIEW_IMAGES_MAX = 10;
|
|
29
|
+
|
|
30
|
+
interface IBlogPreviewImagesPost {
|
|
31
|
+
preview_images?: { image_url?: string | null; display_order?: number | null }[] | null;
|
|
32
|
+
preview_image_urls?: (string | null | undefined)[] | null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The addresses of a post's preview pictures in their order, each passed
|
|
37
|
+
* through `clean` (the component's own check of a public address); empty and
|
|
38
|
+
* repeated ones are left out.
|
|
39
|
+
*/
|
|
40
|
+
export function blogPreviewImages(
|
|
41
|
+
post: IBlogPreviewImagesPost | null | undefined,
|
|
42
|
+
clean: (address: string) => string | null | undefined = (address) => address,
|
|
43
|
+
) {
|
|
44
|
+
const ordered = [...(post?.preview_images ?? [])]
|
|
45
|
+
.sort((left, right) => (left.display_order ?? 0) - (right.display_order ?? 0))
|
|
46
|
+
.map((image) => image.image_url);
|
|
47
|
+
const listed = ordered.some(Boolean) ? ordered : [...(post?.preview_image_urls ?? [])];
|
|
48
|
+
const images: string[] = [];
|
|
49
|
+
|
|
50
|
+
for (const address of listed) {
|
|
51
|
+
const image = address ? clean(address) : '';
|
|
52
|
+
|
|
53
|
+
if (image && !images.includes(image)) {
|
|
54
|
+
images.push(image);
|
|
55
|
+
}
|
|
56
|
+
if (images.length === BLOG_PREVIEW_IMAGES_MAX) {
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return images;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface IBlogCoverSliderOptions {
|
|
65
|
+
/** Load every picture at once (the article); otherwise when the reader comes to the cover (a card). */
|
|
66
|
+
eager?: boolean;
|
|
67
|
+
/** The shown picture changed: its position from 0 and how many there are. */
|
|
68
|
+
onChange?: (index: number, total: number) => void;
|
|
69
|
+
/** No picture of the cover loads. */
|
|
70
|
+
onEmpty?: () => void;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Makes a cover's arrows, marks and counter work. Returns the function that
|
|
75
|
+
* stops it; call that before the cover is drawn again and when it goes away.
|
|
76
|
+
*/
|
|
77
|
+
export function watchBlogCoverSlider(
|
|
78
|
+
root: HTMLElement | null | undefined,
|
|
79
|
+
options: IBlogCoverSliderOptions = {},
|
|
80
|
+
) {
|
|
81
|
+
// Where the page is not a browser's (a server render, a test), nothing is watched.
|
|
82
|
+
const track = root && typeof root.querySelector === 'function'
|
|
83
|
+
? root.querySelector<HTMLElement>('[data-blog-cover-track]')
|
|
84
|
+
: null;
|
|
85
|
+
|
|
86
|
+
if (!root || !track) {
|
|
87
|
+
return () => {};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const cover = root;
|
|
91
|
+
const row = track;
|
|
92
|
+
let armed = false;
|
|
93
|
+
let frame = 0;
|
|
94
|
+
let active = true;
|
|
95
|
+
let reported = -1;
|
|
96
|
+
|
|
97
|
+
const slides = () => [...row.children].filter((slide) => !(slide as HTMLElement).hidden) as HTMLElement[];
|
|
98
|
+
const picture = (slide: Element) => (slide.tagName === 'IMG' ? slide : slide.querySelector('img')) as HTMLImageElement | null;
|
|
99
|
+
const clamp = (index: number, total: number) => Math.min(Math.max(index, 0), Math.max(total - 1, 0));
|
|
100
|
+
|
|
101
|
+
function current() {
|
|
102
|
+
const width = row.clientWidth;
|
|
103
|
+
|
|
104
|
+
return width ? clamp(Math.round(Math.abs(row.scrollLeft) / width), slides().length) : 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function arm() {
|
|
108
|
+
if (armed) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
armed = true;
|
|
112
|
+
for (const image of cover.querySelectorAll<HTMLImageElement>('img[data-src]')) {
|
|
113
|
+
const address = image.getAttribute('data-src');
|
|
114
|
+
|
|
115
|
+
if (address && !image.getAttribute('src')) {
|
|
116
|
+
image.setAttribute('src', address);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function show() {
|
|
122
|
+
const total = slides().length;
|
|
123
|
+
const index = clamp(current(), total);
|
|
124
|
+
const dots = [...cover.querySelectorAll<HTMLElement>('[data-blog-cover-dot]')];
|
|
125
|
+
|
|
126
|
+
cover.setAttribute('data-blog-cover-index', String(index));
|
|
127
|
+
cover.setAttribute('data-blog-cover-total', String(total));
|
|
128
|
+
cover.toggleAttribute('data-blog-cover-single', total < 2);
|
|
129
|
+
dots.forEach((dot, position) => {
|
|
130
|
+
dot.hidden = position >= total;
|
|
131
|
+
dot.toggleAttribute('data-current', position === index);
|
|
132
|
+
});
|
|
133
|
+
for (const counter of cover.querySelectorAll('[data-blog-cover-count]')) {
|
|
134
|
+
counter.textContent = total > 1 ? `${index + 1} / ${total}` : '';
|
|
135
|
+
}
|
|
136
|
+
if (index !== reported) {
|
|
137
|
+
reported = index;
|
|
138
|
+
options.onChange?.(index, total);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function go(step: number) {
|
|
143
|
+
const total = slides().length;
|
|
144
|
+
|
|
145
|
+
if (total < 2) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
arm();
|
|
149
|
+
|
|
150
|
+
// Past the last picture the row starts again, and before the first it goes to the last.
|
|
151
|
+
const next = (current() + step + total) % total;
|
|
152
|
+
const calm = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
153
|
+
const left = next * row.clientWidth;
|
|
154
|
+
|
|
155
|
+
if (typeof row.scrollTo === 'function') {
|
|
156
|
+
row.scrollTo({ left, behavior: calm ? 'auto' : 'smooth' });
|
|
157
|
+
} else {
|
|
158
|
+
row.scrollLeft = left;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function fail(image: HTMLImageElement) {
|
|
163
|
+
const slide = [...row.children].find((item) => item === image || item.contains(image)) as HTMLElement | undefined;
|
|
164
|
+
|
|
165
|
+
if (!slide || slide.hidden) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
slide.hidden = true;
|
|
169
|
+
slide.setAttribute('data-blog-cover-failed', '');
|
|
170
|
+
// The article's image viewer leaves it out too (blogImageViewer).
|
|
171
|
+
slide.setAttribute('data-blog-image-viewer-skip', '');
|
|
172
|
+
if (slides().length) {
|
|
173
|
+
show();
|
|
174
|
+
} else {
|
|
175
|
+
options.onEmpty?.();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function onClick(event: Event) {
|
|
180
|
+
const target = event.target as Element | null;
|
|
181
|
+
const step = target && typeof target.closest === 'function' ? target.closest('[data-blog-cover-step]') : null;
|
|
182
|
+
|
|
183
|
+
if (!step || !cover.contains(step)) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
// An arrow of a card stands inside the card's link: the click turns the picture and opens nothing.
|
|
187
|
+
// Heard on the way down (capture), so it is stopped even when the cover is the link itself.
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
event.stopPropagation();
|
|
190
|
+
go(Number(step.getAttribute('data-blog-cover-step')) < 0 ? -1 : 1);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function onError(event: Event) {
|
|
194
|
+
const image = event.target as HTMLImageElement | null;
|
|
195
|
+
|
|
196
|
+
if (image && image.tagName === 'IMG' && row.contains(image)) {
|
|
197
|
+
fail(image);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function onScroll() {
|
|
202
|
+
// However the row was moved (a finger, a trackpad, the keyboard), the pictures it comes to are loaded.
|
|
203
|
+
arm();
|
|
204
|
+
if (frame) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
frame = requestFrame(() => {
|
|
208
|
+
frame = 0;
|
|
209
|
+
if (active) {
|
|
210
|
+
show();
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
cover.addEventListener('click', onClick, true);
|
|
216
|
+
cover.addEventListener('error', onError, true);
|
|
217
|
+
cover.addEventListener('pointerenter', arm);
|
|
218
|
+
cover.addEventListener('touchstart', arm, { passive: true });
|
|
219
|
+
cover.addEventListener('focusin', arm);
|
|
220
|
+
row.addEventListener('scroll', onScroll, { passive: true });
|
|
221
|
+
|
|
222
|
+
if (options.eager) {
|
|
223
|
+
arm();
|
|
224
|
+
}
|
|
225
|
+
// A failure can end before this starts to listen (a cached one, before the page comes alive).
|
|
226
|
+
for (const slide of [...row.children]) {
|
|
227
|
+
const image = picture(slide);
|
|
228
|
+
|
|
229
|
+
if (image && image.getAttribute('src') && image.complete && image.naturalWidth === 0) {
|
|
230
|
+
fail(image);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
show();
|
|
234
|
+
|
|
235
|
+
return () => {
|
|
236
|
+
active = false;
|
|
237
|
+
if (frame) {
|
|
238
|
+
cancelFrame(frame);
|
|
239
|
+
}
|
|
240
|
+
cover.removeEventListener('click', onClick, true);
|
|
241
|
+
cover.removeEventListener('error', onError, true);
|
|
242
|
+
cover.removeEventListener('pointerenter', arm);
|
|
243
|
+
cover.removeEventListener('touchstart', arm);
|
|
244
|
+
cover.removeEventListener('focusin', arm);
|
|
245
|
+
row.removeEventListener('scroll', onScroll);
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function requestFrame(run: () => void) {
|
|
250
|
+
return typeof requestAnimationFrame === 'function'
|
|
251
|
+
? requestAnimationFrame(run)
|
|
252
|
+
: (setTimeout(run, 16) as unknown as number);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function cancelFrame(frame: number) {
|
|
256
|
+
if (typeof cancelAnimationFrame === 'function') {
|
|
257
|
+
cancelAnimationFrame(frame);
|
|
258
|
+
} else {
|
|
259
|
+
clearTimeout(frame);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -79,6 +79,7 @@ function isImage(node: ParentNode): node is HTMLImageElement {
|
|
|
79
79
|
return (node as Element).tagName === 'IMG';
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
// `data-src`: a picture of the cover that has not been loaded yet (blogCoverSlider).
|
|
82
83
|
function imageSource(image: HTMLImageElement) {
|
|
83
|
-
return image.currentSrc || image.getAttribute('src') || '';
|
|
84
|
+
return image.currentSrc || image.getAttribute('src') || image.getAttribute('data-src') || '';
|
|
84
85
|
}
|
|
@@ -41,6 +41,8 @@ const en = {
|
|
|
41
41
|
`${count} ${count === 1 ? 'article' : 'articles'}`,
|
|
42
42
|
noFiltered: 'No articles match the selected filters.',
|
|
43
43
|
imageOpen: 'Open image',
|
|
44
|
+
imagePrevious: 'Previous picture',
|
|
45
|
+
imageNext: 'Next picture',
|
|
44
46
|
imageViewer: 'Image viewer',
|
|
45
47
|
};
|
|
46
48
|
|
|
@@ -104,6 +106,8 @@ const ru: typeof en = {
|
|
|
104
106
|
articleCount: russianArticleCount,
|
|
105
107
|
noFiltered: 'Нет статей по выбранным фильтрам.',
|
|
106
108
|
imageOpen: 'Открыть изображение',
|
|
109
|
+
imagePrevious: 'Предыдущее изображение',
|
|
110
|
+
imageNext: 'Следующее изображение',
|
|
107
111
|
imageViewer: 'Просмотр изображения',
|
|
108
112
|
};
|
|
109
113
|
|
|
@@ -150,6 +154,8 @@ const es: typeof en = {
|
|
|
150
154
|
`${count} ${count === 1 ? 'artículo' : 'artículos'}`,
|
|
151
155
|
noFiltered: 'Ningún artículo coincide con los filtros seleccionados.',
|
|
152
156
|
imageOpen: 'Abrir la imagen',
|
|
157
|
+
imagePrevious: 'Imagen anterior',
|
|
158
|
+
imageNext: 'Imagen siguiente',
|
|
153
159
|
imageViewer: 'Visor de imágenes',
|
|
154
160
|
};
|
|
155
161
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
safePublicUrl,
|
|
11
11
|
} from '@/lib/basklee/presentation';
|
|
12
12
|
import { APP_ORIGIN, appMediaUrl } from '@/lib/basklee/nativeApp';
|
|
13
|
+
import { blogPreviewImages } from '@/lib/basklee/blogCoverSlider';
|
|
13
14
|
|
|
14
15
|
export function blogPostTitle(post: IBlogPostPreview, locale: string) {
|
|
15
16
|
return (
|
|
@@ -35,6 +36,13 @@ export function blogPostCover(post: IBlogPostPreview) {
|
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
/** Every preview picture of the post: its cover is leafed through when there are several. */
|
|
40
|
+
export function blogPostCovers(post: IBlogPostPreview | undefined) {
|
|
41
|
+
return blogPreviewImages(post, (address) =>
|
|
42
|
+
appMediaUrl(safePublicUrl(address), APP_ORIGIN),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
export function blogPostIsPaid(post: IBlogPostPreview) {
|
|
39
47
|
const access = post.access_type?.int;
|
|
40
48
|
return access !== undefined && access !== EBlogAccessType.ACCESS_PUBLIC;
|