Skip to content

Commit

Permalink
Updates Dawn to use the new structured_data filter (Shopify#3380)
Browse files Browse the repository at this point in the history
* Updates Dawn to use the new filter

* Add support for article structured data
  • Loading branch information
lhoffbeck committed May 30, 2024
1 parent 99d9188 commit abbf0dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 77 deletions.
40 changes: 5 additions & 35 deletions sections/main-article.liquid
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ 'section-blog-post.css' | asset_url | stylesheet_tag }}

<article class="article-template" itemscope itemtype="http://schema.org/BlogPosting">
<article class="article-template">
{%- for block in section.blocks -%}
{%- case block.type -%}
{%- when '@app' -%}
Expand All @@ -15,7 +15,6 @@
>
<div
class="article-template__hero-{{ block.settings.image_height }} media"
itemprop="image"
{% if block.settings.image_height == 'adapt' and article.image %}
style="padding-bottom: {{ 1 | divided_by: article.image.aspect_ratio | times: 100 }}%;"
{% endif %}
Expand Down Expand Up @@ -49,26 +48,24 @@
>
<h1
class="article-template__title"
itemprop="headline"
>
{{ article.title | escape }}
</h1>
{%- if block.settings.blog_show_date -%}
<span class="circle-divider caption-with-letter-spacing" itemprop="dateCreated pubdate datePublished">
<span class="circle-divider caption-with-letter-spacing">
{{- article.published_at | time_tag: format: 'date' -}}
</span>
{%- endif -%}
{%- if block.settings.blog_show_author -%}
<span class="caption-with-letter-spacing" itemprop="author" itemscope itemtype="http://schema.org/Person">
<span itemprop="name">{{ article.author }}</span>
<span class="caption-with-letter-spacing">
<span>{{ article.author }}</span>
</span>
{%- endif -%}
</header>

{%- when 'content' -%}
<div
class="article-template__content page-width page-width--narrow rte{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
itemprop="articleBody"
{{ block.shopify_attributes }}
>
{{ article.content }}
Expand Down Expand Up @@ -278,34 +275,7 @@
</article>

<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"articleBody": {{ article.content | strip_html | json }},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": {{ request.origin | append: page.url | json }}
},
"headline": {{ article.title | json }},
{% if article.excerpt != blank %}
"description": {{ article.excerpt | strip_html | json }},
{% endif %}
{% if article.image %}
"image": [
{{ article | image_url: width: 1920 | prepend: "https:" | json }}
],
{% endif %}
"datePublished": {{ article.published_at | date: '%Y-%m-%dT%H:%M:%SZ' | json }},
"dateCreated": {{ article.created_at | date: '%Y-%m-%dT%H:%M:%SZ' | json }},
"author": {
"@type": "Person",
"name": {{ article.author | json }}
},
"publisher": {
"@type": "Organization",
"name": {{ shop.name | json }}
}
}
{{ article | structured_data }}
</script>

{% schema %}
Expand Down
43 changes: 1 addition & 42 deletions sections/main-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -709,48 +709,7 @@
-%}

<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"url": {{ request.origin | append: product.url | json }},
{% if seo_media -%}
"image": [
{{ seo_media | image_url: width: 1920 | prepend: "https:" | json }}
],
{%- endif %}
"description": {{ product.description | strip_html | json }},
{% if product.selected_or_first_available_variant.sku != blank -%}
"sku": {{ product.selected_or_first_available_variant.sku | json }},
{%- endif %}
"brand": {
"@type": "Brand",
"name": {{ product.vendor | json }}
},
"offers": [
{%- for variant in product.variants -%}
{
"@type" : "Offer",
{%- if variant.sku != blank -%}
"sku": {{ variant.sku | json }},
{%- endif -%}
{%- if variant.barcode.size == 12 -%}
"gtin12": {{ variant.barcode }},
{%- endif -%}
{%- if variant.barcode.size == 13 -%}
"gtin13": {{ variant.barcode }},
{%- endif -%}
{%- if variant.barcode.size == 14 -%}
"gtin14": {{ variant.barcode }},
{%- endif -%}
"availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
"price" : {{ variant.price | divided_by: 100.00 | json }},
"priceCurrency" : {{ cart.currency.iso_code | json }},
"url" : {{ request.origin | append: variant.url | json }}
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
]
}
{{ product | structured_data }}
</script>
</div>
</product-info>
Expand Down

0 comments on commit abbf0dd

Please sign in to comment.