@thg-altitude/schemaorg 1.0.1 → 1.0.3

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/index.js CHANGED
@@ -1,5 +1,15 @@
1
1
  import Product from './src/components/Product.astro'
2
+ import Breadcrumb from './src/components/Breadcrumb.astro'
3
+ import CollectionPage from './src/components/CollectionPage.astro'
4
+ import Organization from './src/components/Organization.astro'
5
+ import ProductCollection from './src/components/ProductCollection.astro'
6
+ import WebSite from './src/components/WebSite.astro'
2
7
 
3
8
  export {
4
- Product
9
+ Product,
10
+ Breadcrumb,
11
+ CollectionPage,
12
+ Organization,
13
+ ProductCollection,
14
+ WebSite
5
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thg-altitude/schemaorg",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,9 @@
1
1
  ---
2
+ let url = import.meta.env.DEV
3
+ ? Astro.url.origin
4
+ : `${Astro.request.headers.get(
5
+ 'X-forward-Proto'
6
+ )}://${Astro.request.headers.get('X-forward-Host')}`
2
7
  let itemListElement = []
3
8
  Astro.props.breadcrumbs.forEach((item,index) => {
4
9
  itemListElement.push({
@@ -6,7 +11,7 @@ Astro.props.breadcrumbs.forEach((item,index) => {
6
11
  "position": index + 1,
7
12
  "item" : {
8
13
  "@type" : "Thing",
9
- "@id" : item?.pagePath,
14
+ "@id" : item.pagePath.includes("p/") || item.displayName === "Home" ? `${url}${item?.pagePath}` : `${url}/c${item?.pagePath}`,
10
15
  "name" : item?.displayName
11
16
  }
12
17
  })
@@ -16,6 +21,7 @@ let schema = {
16
21
  "@type": "BreadcrumbList",
17
22
  "itemListElement": itemListElement
18
23
  };
24
+
19
25
  ---
20
26
 
21
27
  <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>
@@ -1,10 +1,9 @@
1
1
  ---
2
2
  let schema = {
3
3
  "@type": "CollectionPage",
4
- "name": Astro.props.title,
4
+ "name": Astro.props.name,
5
5
  "description": Astro.props.description,
6
6
  };
7
-
8
7
  ---
9
8
 
10
9
  <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>
@@ -1,10 +1,15 @@
1
1
  ---
2
+ let url = import.meta.env.DEV
3
+ ? Astro.url.origin
4
+ : `${Astro.request.headers.get(
5
+ 'X-forward-Proto'
6
+ )}://${Astro.request.headers.get('X-forward-Host')}`
2
7
  let offersArray = []
3
8
  Astro.props.variants.forEach((variant)=>{
4
9
  offersArray.push({
5
10
  "@type": "Offer",
6
11
  "sku": variant.sku,
7
- "url": Astro.props.variants.length > 1 ? `${Astro.props.url}?variation=${variant.sku}`: Astro.props.url,
12
+ "url": Astro.props.variants.length > 1 ? `${url}${Astro.props.url}?variation=${variant.sku}`: `${url}${Astro.props.url}`,
8
13
  "price": variant?.price?.price?.amount,
9
14
  "priceCurrency": Astro.props.currency,
10
15
  "itemCondition": "http://schema.org/NewCondition",
@@ -15,11 +20,11 @@ Astro.props.variants.forEach((variant)=>{
15
20
  let schema = {
16
21
  "@type": "Product",
17
22
  "@context": "https://schema.org",
18
- "@id": Astro.props.sku,
23
+ "@id": `${url}${Astro.props.url}`,
19
24
  "sku": Astro.props.sku,
20
25
  "name": Astro.props.name,
21
26
  "description": Astro.props.description,
22
- "image": Astro.props.image,
27
+ "image": `https://img.cf-thgaltitude.com/?url=${Astro.props.image}`,
23
28
  "brand": {
24
29
  "@type": "Brand",
25
30
  "name": Astro.props.brand,
@@ -1,4 +1,9 @@
1
1
  ---
2
+ let url = import.meta.env.DEV
3
+ ? Astro.url.origin
4
+ : `${Astro.request.headers.get(
5
+ 'X-forward-Proto'
6
+ )}://${Astro.request.headers.get('X-forward-Host')}`
2
7
  let itemListElement = []
3
8
  Astro.props.list.forEach((product,index) => {
4
9
  itemListElement.push({
@@ -7,9 +12,9 @@ Astro.props.list.forEach((product,index) => {
7
12
  "item" : {
8
13
  "@type" : "Product",
9
14
  "name" : product?.title,
10
- "url": product.url,
15
+ "url": `${url}${product.url}`,
11
16
  "sku": product.sku,
12
- "image":product.image[0].largeProduct,
17
+ "image":`https://img.cf-thgaltitude.com/?url=${product.images[0].largeProduct}`,
13
18
  "offers":{
14
19
  "@type":"Offer",
15
20
  "availability": "https://schema.org/InStock",
@@ -1,10 +1,14 @@
1
1
  ---
2
+ let url = import.meta.env.DEV
3
+ ? Astro.url.origin
4
+ : `${Astro.request.headers.get(
5
+ 'X-forward-Proto'
6
+ )}://${Astro.request.headers.get('X-forward-Host')}`
2
7
  let schema = {
3
8
  "@type":"WebSite",
4
9
  "@context": "https://schema.org",
5
- "url": Astro.props.domain
10
+ "url": url
6
11
  };
7
-
8
12
  ---
9
13
 
10
14
  <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>