@thg-altitude/schemaorg 1.0.29 → 1.0.31

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/README.md CHANGED
@@ -1,2 +1,11 @@
1
1
  # Schema.org
2
- Reusable Schema.org for Astro
2
+
3
+ Reusable Schema.org for Astro applications
4
+
5
+ ## Publishing
6
+
7
+ - Increment package version in `package.json` and reinstall with `npm i`
8
+ - Open PR
9
+ - Merge into main branch
10
+
11
+ This will trigger the release workflow
package/index.js CHANGED
@@ -5,6 +5,7 @@ import CollectionPage from './src/components/CollectionPage.astro'
5
5
  import Organization from './src/components/Organization.astro'
6
6
  import ProductCollection from './src/components/ProductCollection.astro'
7
7
  import WebSite from './src/components/WebSite.astro'
8
+ import EnhancedProductList from './src/components/EnhancedProductList.astro'
8
9
 
9
10
  export {
10
11
  Product,
@@ -13,5 +14,6 @@ export {
13
14
  CollectionPage,
14
15
  Organization,
15
16
  ProductCollection,
16
- WebSite
17
+ WebSite,
18
+ EnhancedProductList
17
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thg-altitude/schemaorg",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,59 @@
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')?.split(', ')[0]}`
7
+ let breadcrumbsList = []
8
+ let productList = []
9
+
10
+ const {breadcrumbs=[], products=[],currentUrl='/',name='',description=''} = Astro.props
11
+
12
+ breadcrumbs?.length > 0 && breadcrumbs.forEach((crumb,index)=>{breadcrumbsList.push( {
13
+ "@type": "ListItem",
14
+ "position": index+1,
15
+ "name": crumb?.displayName,
16
+ "item": url+ (crumb?.pagePath !== '/' ? "/c":'')+ crumb?.pagePath
17
+ } )})
18
+
19
+ products?.length >0 && products?.forEach((product)=>{
20
+ productList.push( {
21
+ "@type": "Product",
22
+ "@id":product?.url,
23
+ "name": product?.title,
24
+ "image": product?.images?.[0]?.original ,
25
+ "url": product?.url,
26
+ "sku":product?.sku,
27
+ "offers": {
28
+ "@type": "Offer",
29
+ "priceCurrency": product.defaultVariant?.price?.price.currency ,
30
+ "price": product.defaultVariant?.price?.price.amount
31
+ },
32
+ "aggregateRating":{
33
+ "@type":"AggregateRating",
34
+ "ratingValue":product?.reviews?.averageScore,
35
+ "reviewCount":product?.reviews?.total
36
+ },
37
+
38
+ },)
39
+
40
+ })
41
+
42
+ let schema = {
43
+ "@context": "https://schema.org",
44
+ "@graph":[
45
+ {
46
+ "@type": "BreadcrumbList",
47
+ "itemListElement": breadcrumbsList
48
+ },
49
+ {
50
+ "@type": "ItemList",
51
+ "url":currentUrl,
52
+ "numberOfItems": productList?.length,
53
+ "itemListOrder":"https://schema.org/ItemListUnordered",
54
+ "itemListElement":productList
55
+ }
56
+ ]
57
+ };
58
+ ---
59
+ <script type="application/ld+json" set:html={JSON.stringify(schema)}></script>