basklee-svelte 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
@@ -527,6 +527,7 @@ data and actions; `basklee/COMPONENTS.md` lists their customer paths.
527
527
  Page titles, descriptions and link-preview metadata follow the current page
528
528
  and selected language, including client navigation. Public events and banner
529
529
  images come from Application Load.
530
+ 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.
530
531
  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.
531
532
 
532
533
  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-svelte",
3
- "version": "0.9.8",
3
+ "version": "0.9.9",
4
4
  "description": "SvelteKit 2 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,6 +15,7 @@ import {
15
15
  storefrontPublicOrigin,
16
16
  } from '@/lib/utils/basklee/pageSeo';
17
17
  import type { StorefrontSeoPage } from '@/lib/utils/basklee/pageSeo';
18
+ import type { StorefrontSeoMeta } from '@/lib/utils/basklee/seo';
18
19
  import { structuredDataJson } from '@/lib/utils/basklee/productStructuredData';
19
20
 
20
21
  export function useBaskleePageSeo(
@@ -35,6 +36,12 @@ export function useBaskleePageSeo(
35
36
  * canonical address (preview, filtered, noindex) gets none.
36
37
  */
37
38
  structuredData?: (canonical: string, origin: string) => unknown;
39
+ /**
40
+ * The record's own tags (a product's Open Graph and Twitter Cards tags
41
+ * from the panel's SEO tab). They are said after the page's own tags,
42
+ * so a tag of the same name (og:title, og:description) replaces it.
43
+ */
44
+ meta?: MaybeRefOrGetter<StorefrontSeoMeta[] | undefined>;
38
45
  } = {},
39
46
  ) {
40
47
  const store = useBaskleeStore();
@@ -102,6 +109,7 @@ export function useBaskleePageSeo(
102
109
  : '',
103
110
  );
104
111
  useSeoMeta(seo);
112
+ useHead(() => ({ meta: toValue(values.meta) ?? [] }));
105
113
  useHead(() => ({
106
114
  link: canonical.value
107
115
  ? [
@@ -1,6 +1,13 @@
1
+ import type {
2
+ IDomainSeoOg,
3
+ IDomainSeoTwitter,
4
+ } from '@/lib/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonSEO';
1
5
  import type { ITransformValue } from '@/lib/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;
@@ -1,8 +1,9 @@
1
1
  import type { IAppLoadCommonSeo } from '@/lib/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonSEO';
2
2
  import { getAvailableNestedValueFromObject } from '@/lib/utils/basklee/presentation';
3
3
 
4
- type SeoMeta =
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
+ }
@@ -3,6 +3,7 @@
3
3
  import { computed, ref, watch } from '@/lib/basklee/reactivity.svelte';
4
4
  import { navigateTo, useRoute } from '@/lib/basklee/navigation.svelte';
5
5
  import { useBaskleePageSeo } from '@/lib/composables/useBaskleePageSeo.svelte';
6
+ import { getProductSocialMeta } from '@/lib/utils/basklee/seo';
6
7
  import { useBaskleeMissingPage } from '@/lib/composables/useBaskleeMissingPage.svelte';
7
8
  import { useBaskleeServerData } from '@/lib/composables/useBaskleeServerData.svelte';
8
9
  import { requestProductPage } from '@/lib/utils/basklee/productPage';
@@ -100,9 +101,22 @@
100
101
  ).slice(0, 160),
101
102
  );
102
103
 
104
+ // The panel's SEO tab: its heading is the page title and its keywords the
105
+ // keywords tag; without them the product's name and the page's own words.
106
+ const productSeo = (key: 'product_title' | 'meta_keywords') =>
107
+ plainText(
108
+ getAvailableNestedValueFromObject(
109
+ product.value?.locale,
110
+ store.localeCode,
111
+ key,
112
+ ),
113
+ );
114
+
103
115
  useBaskleePageSeo('product', () => store.localeCode, {
104
- title: () => productName.value,
116
+ title: () => productSeo('product_title') || productName.value,
105
117
  description: () => productSummary.value,
118
+ keywords: () => productSeo('meta_keywords') || undefined,
119
+ meta: () => getProductSocialMeta(product.value, store.localeCode),
106
120
  image: () => image.value,
107
121
  robots: () => (previewKey.value ? 'noindex, nofollow' : undefined),
108
122
  structuredData: (canonical, origin) =>