basklee-nuxt 0.9.2 → 0.9.3
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basklee-nuxt",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "Nuxt 4 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.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,7 +8,7 @@ The supplied storefront uses this component at `/journal`.
|
|
|
8
8
|
|
|
9
9
|
## Contract and dependencies
|
|
10
10
|
|
|
11
|
-
The supplied `app/pages/journal/[id].vue` loads the article during the server render with `blog_posts_get` and `filters.id = postId`, using the visitor's cookies, and passes it in `initialPost`; the browser shows it without another request. Without `initialPost` (after client-side navigation) the component sends the same request itself. Full text appears only when both `is_full` and `has_full_access` are true; otherwise the preview and the access panel remain. Article HTML is sanitized with DOMPurify in `app/utils/basklee/blogArticleHtml.ts` and keeps what the marketplace blog editor writes: headings, paragraphs and line breaks, bold, italic, underline, strikethrough, subscript and superscript, links, bullet, numbered and task lists, quotes, dividers, inline code and code blocks, tables with merged cells, images and galleries, video and audio with controls, collapsible sections, alignment, text color, highlight, font and size. External links open in a new tab with `rel="noopener noreferrer"`; editor links to other articles open `/journal/<id>`. Formulas are shown as their LaTeX source. Wide tables and code blocks scroll inside the article, and floated images stack on narrow screens. Products the author places in the text appear at those positions: an empty block with `data-product-id="12"` shows one product card, `data-product-ids="12,15,9"` a row of up to 24 cards. The block keeps the editor's float or centred style, and `data-product-hidden-badges` (`new`, `popular`, `good-deal`) turns card badges off. Products missing from `related_products` are loaded with `products_search` and `filters.id_in`, up to 35 IDs per request, and stored with `store.setProduct()`; a block whose products are not found stays hidden. Article text styles do not reach the cards, and in a narrow article a floated card stands alone in the middle. The helper is `app/utils/basklee/blogProductPlacements.ts`.
|
|
11
|
+
The supplied `app/pages/journal/[id].vue` loads the article during the server render with `blog_posts_get` and `filters.id = postId`, using the visitor's cookies, and passes it in `initialPost`; the browser shows it without another request. Without `initialPost` (after client-side navigation) the component sends the same request itself. Full text appears only when both `is_full` and `has_full_access` are true; otherwise the preview and the access panel remain. Article HTML is sanitized with DOMPurify in `app/utils/basklee/blogArticleHtml.ts` and keeps what the marketplace blog editor writes: headings, paragraphs and line breaks, bold, italic, underline, strikethrough, subscript and superscript, links, bullet, numbered and task lists, quotes, dividers, inline code and code blocks, tables with merged cells, images and galleries, video and audio with controls, YouTube players, collapsible sections, alignment, text color, highlight, font and size. External links open in a new tab with `rel="noopener noreferrer"`; editor links to other articles open `/journal/<id>`. Formulas are shown as their LaTeX source. Wide tables and code blocks scroll inside the article, and floated images stack on narrow screens. Products the author places in the text appear at those positions: an empty block with `data-product-id="12"` shows one product card, `data-product-ids="12,15,9"` a row of up to 24 cards. The block keeps the editor's float or centred style, and `data-product-hidden-badges` (`new`, `popular`, `good-deal`) turns card badges off. Products missing from `related_products` are loaded with `products_search` and `filters.id_in`, up to 35 IDs per request, and stored with `store.setProduct()`; a block whose products are not found stays hidden. Article text styles do not reach the cards, and in a narrow article a floated card stands alone in the middle. The helper is `app/utils/basklee/blogProductPlacements.ts`. A YouTube player the editor inserts is an `<iframe>` with a `youtube.com` or `youtube-nocookie.com` `/embed/<id>` address: it is kept, played from `youtube-nocookie.com` at the article's width in 16:9, with fixed `allow`, `loading="lazy"` and referrer attributes, and an optional start second. Other frames, scripts, forms, event attributes and other styles are removed. The server render shows the text as plain paragraphs, which search engines can read; the formatted HTML replaces them in the browser.
|
|
12
12
|
|
|
13
13
|
Reading accounting for an accessible paid article starts after interaction with its visible text. `blog_reading_start` starts a session; `blog_reading_heartbeat` follows the returned interval. Leaving, losing focus, hiding the text or 60 seconds without interaction stops requests. Resuming and delayed timers start a fresh baseline. Confirmed loss of access removes full text and offers a refresh.
|
|
14
14
|
|
|
@@ -880,6 +880,18 @@
|
|
|
880
880
|
width: 100%;
|
|
881
881
|
}
|
|
882
882
|
|
|
883
|
+
/* A YouTube player from the editor: the article's width, 16:9. */
|
|
884
|
+
.op-feature-prose :deep(iframe.blog-post-editor-youtube:where(:not([data-product-id] *, [data-product-ids] *))) {
|
|
885
|
+
display: block;
|
|
886
|
+
width: 100%;
|
|
887
|
+
height: auto;
|
|
888
|
+
margin: 1.5rem 0;
|
|
889
|
+
clear: both;
|
|
890
|
+
aspect-ratio: 16 / 9;
|
|
891
|
+
border: 0;
|
|
892
|
+
background: #000;
|
|
893
|
+
}
|
|
894
|
+
|
|
883
895
|
.op-feature-prose :deep(figcaption:where(:not([data-product-id] *, [data-product-ids] *))) {
|
|
884
896
|
margin-top: 0.5rem;
|
|
885
897
|
font-size: 0.875rem;
|
|
@@ -14,8 +14,9 @@ type TStylePatterns = Record<string, RegExp>;
|
|
|
14
14
|
* the backend, so the storefront sanitizes it before display. The allowlist
|
|
15
15
|
* matches what that editor writes: text formatting, headings, lists and task
|
|
16
16
|
* lists, quotes, code blocks, tables, images and galleries, videos,
|
|
17
|
-
* collapsible sections, formulas and alignment, color and size styles
|
|
18
|
-
*
|
|
17
|
+
* collapsible sections, formulas and alignment, color and size styles,
|
|
18
|
+
* and YouTube players. A frame is kept only when its address is a YouTube
|
|
19
|
+
* embed (see blogYoutubeEmbedSource); every other frame is removed.
|
|
19
20
|
*/
|
|
20
21
|
|
|
21
22
|
export const blogArticleTags = [
|
|
@@ -31,6 +32,7 @@ export const blogArticleTags = [
|
|
|
31
32
|
'img', 'figure', 'figcaption',
|
|
32
33
|
'video', 'audio', 'source', 'track',
|
|
33
34
|
'details', 'summary',
|
|
35
|
+
'iframe',
|
|
34
36
|
];
|
|
35
37
|
|
|
36
38
|
const attributes = [
|
|
@@ -46,6 +48,7 @@ const attributes = [
|
|
|
46
48
|
'data-code-scheme', 'data-gallery-width', 'data-list-offset',
|
|
47
49
|
'data-float', 'data-blog-video', 'data-details-content',
|
|
48
50
|
'data-product-id', 'data-product-ids', 'data-product-hidden-badges',
|
|
51
|
+
'allow', 'allowfullscreen', 'referrerpolicy',
|
|
49
52
|
];
|
|
50
53
|
|
|
51
54
|
const marginLength = '(-?\\d+(\\.\\d+)?(px|em|rem|%)?|auto)';
|
|
@@ -57,6 +60,7 @@ const editorClasses = new Set([
|
|
|
57
60
|
'blog-code-block',
|
|
58
61
|
'blog-post-editor-image',
|
|
59
62
|
'blog-post-editor-video',
|
|
63
|
+
'blog-post-editor-youtube',
|
|
60
64
|
]);
|
|
61
65
|
|
|
62
66
|
// The editor's named text and background colors.
|
|
@@ -104,6 +108,53 @@ const editorArticlePath =
|
|
|
104
108
|
|
|
105
109
|
const authorRelTokens = new Set(['nofollow', 'sponsored', 'ugc']);
|
|
106
110
|
|
|
111
|
+
// A YouTube player the editor inserts: youtube.com or youtube-nocookie.com,
|
|
112
|
+
// /embed/ and an 11-character video ID, optionally a start second.
|
|
113
|
+
const youtubeEmbed =
|
|
114
|
+
/^https:\/\/(?:www\.)?youtube(?:-nocookie)?\.com\/embed\/([\w-]{11})(?:\?([^#]*))?$/i;
|
|
115
|
+
|
|
116
|
+
export const blogYoutubeAllow =
|
|
117
|
+
'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share';
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The privacy-enhanced player address for a YouTube embed address, or an
|
|
121
|
+
* empty string for anything else (other sites, other YouTube pages).
|
|
122
|
+
*/
|
|
123
|
+
export function blogYoutubeEmbedSource(value: string) {
|
|
124
|
+
const match = youtubeEmbed.exec(value.trim());
|
|
125
|
+
|
|
126
|
+
if (!match) {
|
|
127
|
+
return '';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const start = /(?:^|&)start=(\d{1,6})(?:&|$)/.exec(match[2] ?? '')?.[1];
|
|
131
|
+
|
|
132
|
+
return `https://www.youtube-nocookie.com/embed/${match[1]}${start && Number(start) > 0 ? `?start=${Number(start)}` : ''}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function prepareYoutubeFrame(node: Element) {
|
|
136
|
+
const source = blogYoutubeEmbedSource(node.getAttribute('src') ?? '');
|
|
137
|
+
|
|
138
|
+
if (!source) {
|
|
139
|
+
node.remove();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const title = node.getAttribute('title')?.trim() || 'YouTube video';
|
|
144
|
+
|
|
145
|
+
for (const attribute of [...node.getAttributeNames()]) {
|
|
146
|
+
node.removeAttribute(attribute);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
node.setAttribute('class', 'blog-post-editor-youtube');
|
|
150
|
+
node.setAttribute('src', source);
|
|
151
|
+
node.setAttribute('title', title);
|
|
152
|
+
node.setAttribute('allow', blogYoutubeAllow);
|
|
153
|
+
node.setAttribute('allowfullscreen', '');
|
|
154
|
+
node.setAttribute('loading', 'lazy');
|
|
155
|
+
node.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');
|
|
156
|
+
}
|
|
157
|
+
|
|
107
158
|
function normalizedHeadingText(value: string) {
|
|
108
159
|
return htmlTextParagraphs(value)
|
|
109
160
|
.join(' ')
|
|
@@ -230,6 +281,11 @@ let mediaOrigin = '';
|
|
|
230
281
|
function prepareElement(node: Element) {
|
|
231
282
|
const name = node.nodeName;
|
|
232
283
|
|
|
284
|
+
if (name === 'IFRAME') {
|
|
285
|
+
prepareYoutubeFrame(node);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
233
289
|
if (name === 'A') {
|
|
234
290
|
prepareLink(node);
|
|
235
291
|
}
|