basklee-react 0.9.8 → 0.9.9
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
CHANGED
|
@@ -521,6 +521,7 @@ server render. Public product, article and tariff details load through the
|
|
|
521
521
|
maintained API client. Page metadata uses those returned records and follows
|
|
522
522
|
client navigation and language selection. Home-page event clicks open enrollment
|
|
523
523
|
for the returned event, preserving its return path through sign-in.
|
|
524
|
+
A product page takes the product's SEO tab: its heading is the page title (the product name without one), its meta description and keywords fill their tags, and its own Open Graph and Twitter Cards tags are added in the page's language only, replacing a default tag of the same name.
|
|
524
525
|
Pages with a canonical address also link the same page in the other storefront languages (`hreflang`) and set `og:type` and `og:locale`; a journal article adds its publication date (`article:published_time`) and schema.org `BlogPosting` data. The store icon (`logos.ico`) is the page's `<link rel="icon">`. An unknown `?locale` opens the default language.
|
|
525
526
|
|
|
526
527
|
List pages (journal, categories, stores) link their previous and next pages as real links (`?page=2`). Each later page has its own canonical address and a title with its page number; a journal page past the last one answers 404.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basklee-react",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
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",
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IDomainSeoOg,
|
|
3
|
+
IDomainSeoTwitter,
|
|
4
|
+
} from '@/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonSEO';
|
|
1
5
|
import type { ITransformValue } from '@/interfaces/basklee/shared/ITransformValue';
|
|
2
6
|
|
|
3
7
|
export interface IProduct {
|
|
8
|
+
/** The product's own Open Graph / Twitter Cards tags (single product only). */
|
|
9
|
+
og?: IDomainSeoOg[];
|
|
10
|
+
twitter?: IDomainSeoTwitter[];
|
|
4
11
|
id: number;
|
|
5
12
|
product_group_id: number;
|
|
6
13
|
whishlist_id?: number | null;
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
type StorefrontSeoPage,
|
|
27
27
|
} from '@/lib/basklee/pageSeo';
|
|
28
28
|
import { structuredDataJson } from '@/lib/basklee/productStructuredData';
|
|
29
|
-
import { getStorefrontSeo } from '@/lib/basklee/seo';
|
|
29
|
+
import { getProductSocialMeta, getStorefrontSeo } from '@/lib/basklee/seo';
|
|
30
30
|
import { findCatalogCategory } from '@/lib/basklee/catalog';
|
|
31
31
|
import { blogPostCover } from '@/lib/basklee/blogPresentation';
|
|
32
32
|
import { browseLabels } from '@/lib/basklee/browseLabels';
|
|
@@ -135,6 +135,9 @@ export function storefrontMetadata(
|
|
|
135
135
|
}
|
|
136
136
|
const values: MetadataValues = {};
|
|
137
137
|
let image: string | undefined;
|
|
138
|
+
// A product's own og:title / og:description (the panel's SEO tab) replace
|
|
139
|
+
// the link preview's title and description; its other tags are said as is.
|
|
140
|
+
let ownOg: { title?: string; description?: string } = {};
|
|
138
141
|
let published: string | undefined;
|
|
139
142
|
let modified: string | undefined;
|
|
140
143
|
const tags: MetaTags = [];
|
|
@@ -192,11 +195,27 @@ export function storefrontMetadata(
|
|
|
192
195
|
const product = records.product;
|
|
193
196
|
const field = <Key extends keyof IProductLocale>(name: Key) =>
|
|
194
197
|
getAvailableNestedValueFromObject(product.locale, locale, name);
|
|
195
|
-
|
|
198
|
+
// The panel's SEO tab: its heading is the page title and its keywords the
|
|
199
|
+
// keywords tag; without them the product's name and the page's own words.
|
|
200
|
+
values.title = plainText(field('product_title') ?? '') || field('product_name');
|
|
196
201
|
values.description = plainText(
|
|
197
202
|
field('meta_description') || field('short_description'),
|
|
198
203
|
).slice(0, 160);
|
|
204
|
+
values.keywords = plainText(field('meta_keywords') ?? '') || undefined;
|
|
199
205
|
image = product.images?.full?.[0] ?? product.images?.small?.[0];
|
|
206
|
+
const own = getProductSocialMeta(product, locale);
|
|
207
|
+
const ownProperty = (name: string) =>
|
|
208
|
+
own.find((tag) => 'property' in tag && tag.property === name)?.content;
|
|
209
|
+
ownOg = {
|
|
210
|
+
title: ownProperty('og:title'),
|
|
211
|
+
description: ownProperty('og:description'),
|
|
212
|
+
};
|
|
213
|
+
tags.push(
|
|
214
|
+
...own.filter(
|
|
215
|
+
(tag) =>
|
|
216
|
+
!('property' in tag && ['og:title', 'og:description'].includes(tag.property)),
|
|
217
|
+
),
|
|
218
|
+
);
|
|
200
219
|
} else if (page === 'publication' && records.post) {
|
|
201
220
|
values.title = getAvailableNestedValueFromObject(
|
|
202
221
|
records.post.locale,
|
|
@@ -284,8 +303,8 @@ export function storefrontMetadata(
|
|
|
284
303
|
...(icon ? { icons: { icon } } : {}),
|
|
285
304
|
openGraph: {
|
|
286
305
|
...openGraph,
|
|
287
|
-
title: content.title,
|
|
288
|
-
description: content.description,
|
|
306
|
+
title: ownOg.title ?? content.title,
|
|
307
|
+
description: ownOg.description ?? content.description,
|
|
289
308
|
...(ogLocale ? { locale: ogLocale } : {}),
|
|
290
309
|
...(canonical ? { url: canonical } : {}),
|
|
291
310
|
...(image ? { images: [image] } : {}),
|
|
@@ -319,8 +338,8 @@ export function storefrontMetadata(
|
|
|
319
338
|
description: content.description,
|
|
320
339
|
keywords: content.keywords,
|
|
321
340
|
robots,
|
|
322
|
-
'og:title': content.title,
|
|
323
|
-
'og:description': content.description,
|
|
341
|
+
'og:title': ownOg.title ?? content.title,
|
|
342
|
+
'og:description': ownOg.description ?? content.description,
|
|
324
343
|
'og:image': image,
|
|
325
344
|
'og:url': canonical,
|
|
326
345
|
'og:type': ogType,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IAppLoadCommonSeo } from '@/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonSEO';
|
|
2
2
|
import { getAvailableNestedValueFromObject } from '@/lib/basklee/presentation';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
export type StorefrontSeoMeta =
|
|
5
5
|
{ name: string; content: string } | { property: string; content: string };
|
|
6
|
+
type SeoMeta = StorefrontSeoMeta;
|
|
6
7
|
|
|
7
8
|
export function getStorefrontSeo(
|
|
8
9
|
incomingData: IAppLoadCommonSeo[],
|
|
@@ -50,3 +51,28 @@ export function getStorefrontSeo(
|
|
|
50
51
|
}
|
|
51
52
|
return { title, meta };
|
|
52
53
|
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A product's own Open Graph and Twitter Cards tags (the panel's SEO tab) for
|
|
57
|
+
* its page head. Only the page's own language counts: a tag written in English
|
|
58
|
+
* is left out of the Russian page rather than replacing its Russian title.
|
|
59
|
+
*/
|
|
60
|
+
export function getProductSocialMeta(
|
|
61
|
+
product: Partial<Pick<IAppLoadCommonSeo, 'og' | 'twitter'>> | undefined,
|
|
62
|
+
locale: string,
|
|
63
|
+
): StorefrontSeoMeta[] {
|
|
64
|
+
const meta: StorefrontSeoMeta[] = [];
|
|
65
|
+
for (const tag of product?.og ?? []) {
|
|
66
|
+
const content = tag.locale?.[locale]?.og_content_value?.trim();
|
|
67
|
+
if (content) {
|
|
68
|
+
meta.push({ property: tag.og_property_name, content });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const tag of product?.twitter ?? []) {
|
|
72
|
+
const content = tag.locale?.[locale]?.extra_meta_content?.trim();
|
|
73
|
+
if (content) {
|
|
74
|
+
meta.push({ name: tag.extra_meta_name, content });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return meta;
|
|
78
|
+
}
|