@thg-altitude/schemaorg 1.0.0 → 1.0.1

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.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,21 @@
1
+ ---
2
+ let itemListElement = []
3
+ Astro.props.breadcrumbs.forEach((item,index) => {
4
+ itemListElement.push({
5
+ "type": "ListItem",
6
+ "position": index + 1,
7
+ "item" : {
8
+ "@type" : "Thing",
9
+ "@id" : item?.pagePath,
10
+ "name" : item?.displayName
11
+ }
12
+ })
13
+ });
14
+
15
+ let schema = {
16
+ "@type": "BreadcrumbList",
17
+ "itemListElement": itemListElement
18
+ };
19
+ ---
20
+
21
+ <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>
@@ -0,0 +1,10 @@
1
+ ---
2
+ let schema = {
3
+ "@type": "CollectionPage",
4
+ "name": Astro.props.title,
5
+ "description": Astro.props.description,
6
+ };
7
+
8
+ ---
9
+
10
+ <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>
@@ -0,0 +1,17 @@
1
+ ---
2
+ let socialLinkArray = []
3
+ Astro.props.socialLinks.forEach((link)=>{
4
+ socialLinkArray.push(link)
5
+ })
6
+
7
+
8
+ let schema = {
9
+ "@type":"Organization",
10
+ "@context": "https://schema.org",
11
+ "name": Astro.props.name,
12
+ "sameAs": socialLinkArray
13
+ };
14
+
15
+ ---
16
+
17
+ <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>
@@ -1,4 +1,17 @@
1
1
  ---
2
+ let offersArray = []
3
+ Astro.props.variants.forEach((variant)=>{
4
+ offersArray.push({
5
+ "@type": "Offer",
6
+ "sku": variant.sku,
7
+ "url": Astro.props.variants.length > 1 ? `${Astro.props.url}?variation=${variant.sku}`: Astro.props.url,
8
+ "price": variant?.price?.price?.amount,
9
+ "priceCurrency": Astro.props.currency,
10
+ "itemCondition": "http://schema.org/NewCondition",
11
+ "availability": variant.inStock ? "https://schema.org/InStock" : "https://schema.org/OutOfStock"
12
+ })
13
+ })
14
+
2
15
  let schema = {
3
16
  "@type": "Product",
4
17
  "@context": "https://schema.org",
@@ -10,19 +23,10 @@ let schema = {
10
23
  "brand": {
11
24
  "@type": "Brand",
12
25
  "name": Astro.props.brand,
13
- "description": null
14
26
  },
15
- "offers": {
16
- "@type": "Offer",
17
- "price": Astro.props.price,
18
- "priceCurrency": Astro.props.currency,
19
- "url": Astro.props.url,
20
- "itemCondition": "http://schema.org/NewCondition",
21
- "sku": Astro.props.sku,
22
- "availability": Astro.props.inStock ? "https://schema.org/InStock" : "https://schema.org/OutOfStock"
23
- }
27
+ "offers": offersArray
24
28
  };
25
- ---
26
29
 
30
+ ---
27
31
 
28
32
  <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>
@@ -0,0 +1,34 @@
1
+ ---
2
+ let itemListElement = []
3
+ Astro.props.list.forEach((product,index) => {
4
+ itemListElement.push({
5
+ "type": "ListItem",
6
+ "position": index + 1,
7
+ "item" : {
8
+ "@type" : "Product",
9
+ "name" : product?.title,
10
+ "url": product.url,
11
+ "sku": product.sku,
12
+ "image":product.image[0].largeProduct,
13
+ "offers":{
14
+ "@type":"Offer",
15
+ "availability": "https://schema.org/InStock",
16
+ "price":product.defaultVariant ? product.defaultVariant.price.price.amount : product.cheapestVariant.price.price.amount,
17
+ "priceCurrency": Astro.props.currency
18
+ }
19
+ }
20
+ })
21
+ });
22
+
23
+ let schema = {
24
+ "@type":"ProductCollection",
25
+ "@context": "https://schema.org",
26
+ "mainEntity":{
27
+ "@type":"ItemList",
28
+ "itemListElement": itemListElement,
29
+ }
30
+ };
31
+
32
+ ---
33
+
34
+ <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>
@@ -0,0 +1,10 @@
1
+ ---
2
+ let schema = {
3
+ "@type":"WebSite",
4
+ "@context": "https://schema.org",
5
+ "url": Astro.props.domain
6
+ };
7
+
8
+ ---
9
+
10
+ <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>