@thg-altitude/schemaorg 1.0.17 → 1.0.19

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": "@thg-altitude/schemaorg",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,7 +8,7 @@ let offersArray = []
8
8
  Astro.props.variants?.forEach((variant)=>{
9
9
  offersArray.push({
10
10
  "@type": "Offer",
11
- "sku": variant.sku,
11
+ "sku": variant.sku.toString(),
12
12
  "url": Astro.props.variants.length > 1 ? `${url}${Astro.props.url}?variation=${variant?.sku}`: `${url}${Astro.props.url}`,
13
13
  "price": variant?.price?.price?.amount,
14
14
  "priceCurrency": Astro.props.currency,
@@ -35,11 +35,17 @@ Astro.props.reviews?.forEach((review)=>{
35
35
  })
36
36
  })
37
37
 
38
+ let aggregateRating = Astro.props.reviewsCount > 0 ? {
39
+ "@type": "AggregateRating",
40
+ "ratingValue": Astro.props.reviewsAverage,
41
+ "reviewCount": Astro.props.reviewsCount
42
+ } : undefined
43
+
38
44
  let schema = {
39
45
  "@type": "Product",
40
46
  "@context": "https://schema.org",
41
- "@id": `${url}${Astro.props.url}`,
42
- "sku": Astro.props.sku,
47
+ "@id": Astro.props.sku.toString(),
48
+ "sku": Astro.props.sku.toString(),
43
49
  "name": Astro.props.name,
44
50
  "description": Astro.props.description,
45
51
  "image": `${import.meta.env.IMAGE_PROXY_URL}?url=${Astro.props.image}&format=webp&width=1500&height=1500&fit=cover`,
@@ -47,12 +53,8 @@ let schema = {
47
53
  "@type": "Brand",
48
54
  "name": Astro.props.brand,
49
55
  },
50
- "aggregateRating": {
51
- "@type": "AggregateRating",
52
- "ratingValue": Astro.props.reviewsAverage,
53
- "reviewCount": Astro.props.reviewsCount
54
- },
55
- "review": reviewsArray,
56
+ "aggregateRating": aggregateRating,
57
+ "review": reviewsArray.length ? reviewsArray : null,
56
58
  "offers": offersArray
57
59
  };
58
60