@thg-altitude/schemaorg 1.0.7 → 1.0.8

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.7",
3
+ "version": "1.0.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,23 +5,23 @@ let url = import.meta.env.DEV
5
5
  'X-Forwarded-Proto'
6
6
  )}://${Astro.request.headers.get('X-Forwarded-Host')}`
7
7
  let itemListElement = []
8
- Astro.props.breadcrumbs.forEach((item,index) => {
8
+
9
+ Astro.props.breadcrumbs?.forEach((item,index) => {
9
10
  itemListElement.push({
10
11
  "@type": "ListItem",
11
12
  "position": index + 1,
12
13
  "item" : {
13
14
  "@type": "Thing",
14
- "@id" : item.pagePath.includes("p/") || item.displayName === "Home" ? `${url}${item?.pagePath}` : `${url}/c${item?.pagePath}`,
15
+ "@id" : item?.pagePath?.includes("p/") || item?.displayName === "Home" ? `${url}${item?.pagePath}` : `${url}/c${item?.pagePath}`,
15
16
  "name" : item?.displayName
16
17
  }
17
18
  })
18
- });
19
+ })
19
20
 
20
21
  let schema = {
21
22
  "@type": "BreadcrumbList",
22
23
  "itemListElement": itemListElement
23
24
  };
24
-
25
25
  ---
26
26
 
27
27
  <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>
@@ -5,15 +5,15 @@ let url = import.meta.env.DEV
5
5
  'X-forwarded-Proto'
6
6
  )}://${Astro.request.headers.get('X-forwarded-Host')}`
7
7
  let offersArray = []
8
- Astro.props.variants.forEach((variant)=>{
8
+ Astro.props.variants?.forEach((variant)=>{
9
9
  offersArray.push({
10
10
  "@type": "Offer",
11
11
  "sku": variant.sku,
12
- "url": Astro.props.variants.length > 1 ? `${url}${Astro.props.url}?variation=${variant.sku}`: `${url}${Astro.props.url}`,
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,
15
15
  "itemCondition": "http://schema.org/NewCondition",
16
- "availability": variant.inStock ? "https://schema.org/InStock" : "https://schema.org/OutOfStock"
16
+ "availability": variant?.inStock ? "https://schema.org/InStock" : "https://schema.org/OutOfStock"
17
17
  })
18
18
  })
19
19
 
@@ -24,7 +24,7 @@ let schema = {
24
24
  "sku": Astro.props.sku,
25
25
  "name": Astro.props.name,
26
26
  "description": Astro.props.description,
27
- "image": `${import.meta.env.IMAGE_PROXY_URL}?url=${Astro.props.image}`,
27
+ "image": `${import.meta.env.IMAGE_PROXY_URL}?url=${Astro.props.image}&format=webp&width=1500&height=1500&fit=cover`,
28
28
  "brand": {
29
29
  "@type": "Brand",
30
30
  "name": Astro.props.brand,
@@ -12,19 +12,17 @@ Astro.props.list.forEach((product,index) => {
12
12
  "item" : {
13
13
  "@type" : "Product",
14
14
  "name" : product?.title,
15
- "url": `${url}${product.url}`,
16
- "sku": product.sku,
17
- "image":`${import.meta.env.IMAGE_PROXY_URL}?url=${product.images[0].original}`,
15
+ "url": `${url}${product?.url}`,
16
+ "sku": product?.sku,
17
+ "image":product?.images[0]?.original ? `${import.meta.env.IMAGE_PROXY_URL}?url=${product?.images[0]?.original}&format=webp&width=1500&height=1500&fit=cover` : null,
18
18
  "offers":{
19
19
  "@type":"Offer",
20
20
  "availability": "https://schema.org/InStock",
21
- "price":product.defaultVariant ? product.defaultVariant.price.price.amount : product.cheapestVariant.price.price.amount,
21
+ "price":product?.defaultVariant ? product?.defaultVariant?.price?.price?.amount : product?.cheapestVariant?.price?.price?.amount,
22
22
  "priceCurrency": Astro.props.currency
23
-
24
23
  }
25
24
  }
26
25
  })
27
-
28
26
  });
29
27
 
30
28
  let schema = {
@@ -35,7 +33,5 @@ let schema = {
35
33
  "itemListElement": itemListElement,
36
34
  }
37
35
  };
38
-
39
36
  ---
40
-
41
37
  <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>
@@ -2,8 +2,8 @@
2
2
  let url = import.meta.env.DEV
3
3
  ? Astro.url.origin
4
4
  : `${Astro.request.headers.get(
5
- 'X-forwarded-Proto'
6
- )}://${Astro.request.headers.get('X-forwarded-Host')}`
5
+ 'X-Forwarded-Proto'
6
+ )}://${Astro.request.headers.get('X-Forwarded-Host')}`
7
7
  let schema = {
8
8
  "@type":"WebSite",
9
9
  "@context": "https://schema.org",
@@ -1,41 +0,0 @@
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')}`
7
- let itemListElement = []
8
- Astro.props.list.forEach((product,index) => {
9
- itemListElement.push({
10
- "type": "ListItem",
11
- "position": index + 1,
12
- "item" : {
13
- "@type" : "Product",
14
- "name" : product?.title,
15
- "url": `${url}${product.url}`,
16
- "sku": product.sku,
17
- "image":`${import.meta.env.IMAGE_PROXY_URL}?url=${product.images[0].original}`,
18
- "offers":{
19
- "@type":"Offer",
20
- "availability": "https://schema.org/InStock",
21
- "price":product.defaultVariant ? product.defaultVariant.price.price.amount : product.cheapestVariant.price.price.amount,
22
- "priceCurrency": Astro.props.currency
23
-
24
- }
25
- }
26
- })
27
-
28
- });
29
-
30
- let schema = {
31
- "@type":"ProductCollection",
32
- "@context": "https://schema.org",
33
- "mainEntity":{
34
- "@type":"ItemList",
35
- "itemListElement": itemListElement,
36
- }
37
- };
38
-
39
- ---
40
-
41
- <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>