@scayle/storefront-product-detail 1.2.0 → 1.3.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # @scayle/storefront-product-detail
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **\[SEO\]** Moved the product image from the `ProductGroup` JSONLD to the `Product` JSONLD to better align with [Google's recommendation](https://developers.google.com/search/docs/appearance/structured-data/merchant-listing).
8
+
9
+ Instead of passing all product images to `useProductSeoData`, the primary product image is expected to be included in the passed `variants`.
10
+
11
+ ```ts
12
+ useProductSeoData({
13
+ name: 'Name',
14
+ brand: 'Brand',
15
+ productDescription: 'Description',
16
+ variants: variants.value.map((variant) => {
17
+ return generateProductSchema({
18
+ productName: 'Name',
19
+ variant,
20
+ url: `${$config.public.baseUrl}${route.fullPath}`,
21
+ size,
22
+ })
23
+ }),
24
+ images: images.value,
25
+ productId: product.value?.id || 0,
26
+ color: formatColors(colors.value),
27
+ variesBy: variants.value.length > 1
28
+ ? ['https://schema.org/size']
29
+ : undefined,
30
+ })
31
+
32
+ // Will become
33
+
34
+ useProductSeoData({
35
+ name: 'Name',
36
+ brand: 'Brand',
37
+ productDescription: 'Description',
38
+ variants: variants.value.map((variant) => {
39
+ return generateProductSchema({
40
+ productName: 'Name',
41
+ variant,
42
+ url: `${$config.public.baseUrl}${route.fullPath}`,
43
+ size,
44
+ images: images.value[0],
45
+ })
46
+ }),
47
+ productId: product.value?.id || 0,
48
+ color: formatColors(colors.value),
49
+ variesBy: variants.value.length > 1
50
+ ? ['https://schema.org/size']
51
+ : undefined,
52
+ })
53
+ ```
54
+
3
55
  ## 1.2.0
4
56
 
5
57
  ### Minor Changes
package/dist/module.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@scayle/storefront-product-detail",
3
3
  "configKey": "product-detail",
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "compatibility": {
6
6
  "bridge": false,
7
7
  "nuxt": ">=3.13"
8
8
  },
9
9
  "builder": {
10
10
  "@nuxt/module-builder": "1.0.1",
11
- "unbuild": "2.0.0"
11
+ "unbuild": "3.5.0"
12
12
  }
13
13
  }
package/dist/module.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineNuxtModule, createResolver, addImportsDir } from '@nuxt/kit';
2
2
 
3
3
  const PACKAGE_NAME = "@scayle/storefront-product-detail";
4
- const PACKAGE_VERSION = "1.2.0";
4
+ const PACKAGE_VERSION = "1.3.0";
5
5
  const module = defineNuxtModule({
6
6
  meta: {
7
7
  name: PACKAGE_NAME,
@@ -16,8 +16,6 @@ interface ProductInfo {
16
16
  color: string;
17
17
  /** Array of product variants. */
18
18
  variants: WithContext<Product>[];
19
- /** Array of image URLs for the product. */
20
- images: string[];
21
19
  variesBy?: ProductGroup['variesBy'];
22
20
  }
23
21
  export interface UseProductSeoDataReturn {
@@ -19,7 +19,6 @@ export function useProductSeoData(breadcrumbs, urlParams, productInfo) {
19
19
  productId: info.productId.toString(),
20
20
  name: info.name,
21
21
  description: info.productDescription,
22
- images: info.images,
23
22
  brandName: info.brand,
24
23
  color: info.color,
25
24
  variants: info.variants,
@@ -3,22 +3,43 @@ import type { Product, WithContext, ProductGroup } from 'schema-dts';
3
3
  /**
4
4
  * Generates an object following the schema.org `Product` type with context.
5
5
  *
6
+ * @param params - Options for generating the schema product.
7
+ * @param params.productName - Name of the product.
8
+ * @param params.variant - Variant of the product.
9
+ * @param params.url - URL of the product.
10
+ * @param params.image - URL of the product image.
11
+ * @param params.size - Size of the product.
12
+ *
6
13
  * @see https://schema.org/Product Used to specify `@type` of the returned schema.
7
14
  * @see https://schema.org/Brand Used to define schema of `brand`.
8
15
  *
9
16
  * @returns An object following the schema.org `Product` type with context.
10
17
  */
11
- export declare const generateProductSchema: ({ productName, variant, url, size, }: {
18
+ export declare const generateProductSchema: ({ productName, variant, url, image, size, }: {
12
19
  productName: string;
13
20
  variant: Variant;
14
21
  url: string;
22
+ image: string;
15
23
  size?: string;
16
24
  }) => WithContext<Product>;
17
- export declare const generateProductGroupSchema: ({ productId, name, description, images, brandName, color, variants, variesBy, }: {
25
+ /**
26
+ * Generates an object following the schema.org `ProductGroup` type with context.
27
+ *
28
+ * @param params - Options for generating the schema product group.
29
+ * @param params.productId - ID of the product group.
30
+ * @param params.name - Name of the product group.
31
+ * @param params.description - Description of the product group.
32
+ * @param params.brandName - Name of the brand.
33
+ * @param params.color - Color of the product group.
34
+ * @param params.variants - Variants of the product group.
35
+ * @param params.variesBy - Varies by of the product group.
36
+ *
37
+ * @returns An object following the schema.org `ProductGroup` type with context.
38
+ */
39
+ export declare const generateProductGroupSchema: ({ productId, name, description, brandName, color, variants, variesBy, }: {
18
40
  productId: string;
19
41
  name: string;
20
42
  description: string;
21
- images: string[];
22
43
  brandName: string;
23
44
  color: string;
24
45
  variants: Product[];
@@ -20,6 +20,7 @@ export const generateProductSchema = ({
20
20
  productName,
21
21
  variant,
22
22
  url,
23
+ image,
23
24
  size
24
25
  }) => {
25
26
  return {
@@ -27,14 +28,14 @@ export const generateProductSchema = ({
27
28
  "@type": "Product",
28
29
  name: `${productName} (${size})`,
29
30
  size,
30
- offers: generateSchemaProductOffer({ variant, baseUrl: url })
31
+ offers: generateSchemaProductOffer({ variant, baseUrl: url }),
32
+ image
31
33
  };
32
34
  };
33
35
  export const generateProductGroupSchema = ({
34
36
  productId,
35
37
  name,
36
38
  description,
37
- images,
38
39
  brandName,
39
40
  color,
40
41
  variants,
@@ -46,7 +47,6 @@ export const generateProductGroupSchema = ({
46
47
  productGroupID: productId,
47
48
  name: `${name}, ${color}`,
48
49
  description,
49
- image: images,
50
50
  brand: {
51
51
  "@type": "Brand",
52
52
  name: brandName
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-product-detail",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Collection of essential composables and utilities to work with product detail",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "build": "nuxt-module-build build",
32
32
  "dev": "nuxi dev playground",
33
33
  "dev:build": "nuxi build playground",
34
- "prep": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
34
+ "prep": "nuxt-module-build prepare && nuxi prepare playground",
35
35
  "lint": "eslint .",
36
36
  "lint:ci": "eslint . --format gitlab",
37
37
  "lint:fix": "eslint . --fix",
@@ -54,28 +54,28 @@
54
54
  "vue": "^3.5.13"
55
55
  },
56
56
  "devDependencies": {
57
- "@arethetypeswrong/cli": "0.17.4",
58
- "@nuxt/kit": "3.15.4",
57
+ "@arethetypeswrong/cli": "0.18.0",
58
+ "@nuxt/kit": "3.16.2",
59
59
  "@nuxt/module-builder": "1.0.1",
60
- "@nuxt/schema": "3.15.4",
61
- "@nuxt/test-utils": "3.17.2",
62
- "@scayle/eslint-config-storefront": "4.5.0",
63
- "@scayle/storefront-nuxt": "8.24.0",
64
- "@types/node": "22.14.1",
60
+ "@nuxt/schema": "3.16.2",
61
+ "@nuxt/test-utils": "3.18.0",
62
+ "@scayle/eslint-config-storefront": "4.5.1",
63
+ "@scayle/storefront-nuxt": "8.25.3",
64
+ "@types/node": "22.15.17",
65
65
  "@vue/test-utils": "2.4.6",
66
66
  "@vueuse/core": "13.1.0",
67
67
  "dprint": "0.49.1",
68
- "eslint-formatter-gitlab": "5.1.0",
69
- "eslint": "9.24.0",
70
- "happy-dom": "17.4.4",
71
- "nuxt": "3.15.4",
68
+ "eslint-formatter-gitlab": "6.0.0",
69
+ "eslint": "9.26.0",
70
+ "happy-dom": "17.4.6",
71
+ "nuxt": "3.16.2",
72
72
  "publint": "0.2.12",
73
73
  "schema-dts": "1.1.5",
74
74
  "typescript": "5.8.3",
75
- "unbuild": "2.0.0",
76
- "vitest": "3.1.1",
77
- "vue-router": "4.5.0",
78
- "vue-tsc": "2.2.8",
75
+ "unbuild": "3.5.0",
76
+ "vitest": "3.1.3",
77
+ "vue-router": "4.5.1",
78
+ "vue-tsc": "2.2.10",
79
79
  "vue": "3.5.13"
80
80
  }
81
81
  }