@thg-altitude/schemaorg 1.0.12 → 1.0.14

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.12",
3
+ "version": "1.0.14",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,7 +14,7 @@ Astro.props.breadcrumbs?.forEach((item,index) => {
14
14
  "item" : {
15
15
  "@type":"Thing",
16
16
  "@id":item?.pagePath?.includes("p/") || item?.displayName === "Home" ? `${url}${item?.pagePath}` : `${url}/c${item?.pagePath}`
17
- },
17
+ }
18
18
  })
19
19
  })
20
20
 
@@ -1,4 +1,9 @@
1
1
  ---
2
+ let url = import.meta.env.DEV
3
+ ? Astro.url.origin
4
+ : `${Astro.request.headers.get(
5
+ 'X-Forwarded-Proto'
6
+ )}://${Astro.request.headers.get('X-Forwarded-Host')}`
2
7
  let socialLinkArray = []
3
8
  Astro.props.socialLinks.forEach((link)=>{
4
9
  socialLinkArray.push(link)
@@ -9,6 +14,7 @@ let schema = {
9
14
  "@type":"Organization",
10
15
  "@context": "https://schema.org",
11
16
  "name": Astro.props.name,
17
+ "url":url,
12
18
  "sameAs": socialLinkArray,
13
19
  "logo": Astro.props.logo
14
20
  };
@@ -17,6 +17,24 @@ Astro.props.variants?.forEach((variant)=>{
17
17
  })
18
18
  })
19
19
 
20
+ let reviewsArray = []
21
+ Astro.props.reviews?.forEach((review)=>{
22
+ reviewsArray.push({
23
+ "@type": "Review",
24
+ "reviewRating": {
25
+ "@type": "Rating",
26
+ "ratingValue": review?.elements?.[0]?.score,
27
+ "bestRating": "5"
28
+ },
29
+ "author": {
30
+ "@type": "Person",
31
+ "name": review?.authorName
32
+ },
33
+ "datePublished": review?.posted,
34
+ "reviewBody": review?.elements?.[1]?.value
35
+ })
36
+ })
37
+
20
38
  let schema = {
21
39
  "@type": "Product",
22
40
  "@context": "https://schema.org",
@@ -29,6 +47,12 @@ let schema = {
29
47
  "@type": "Brand",
30
48
  "name": Astro.props.brand,
31
49
  },
50
+ "aggregateRating": {
51
+ "@type": "AggregateRating",
52
+ "ratingValue": Astro.props.reviewsAverage,
53
+ "reviewCount": Astro.props.reviewsCount
54
+ },
55
+ "review": reviewsArray,
32
56
  "offers": offersArray
33
57
  };
34
58