{% sw_extends '@Storefront/storefront/layout/meta.html.twig' %}
{% if activeRoute == 'sas.frontend.blog.detail' and entry.media.url %}
{% set metaImage = entry.media.url|striptags|trim %}
{% endif %}
{% block layout_head_canonical %}
{% if activeRoute == 'sas.frontend.blog.detail' %}
{% set blogCanonicalPath = app.request.attributes.get('sw-original-request-uri')|default(app.request.requestUri)|split('?')|first %}
{% set blogCanonicalUrl = app.request.schemeAndHttpHost ~ blogCanonicalPath %}
<link rel="canonical" href="{{ blogCanonicalUrl }}"/>
{% else %}
{{ parent() }}
{% endif %}
{% endblock %}
{% block layout_head_meta_tags_image_og %}{{ metaImage ?? parent() }}{% endblock %}
{% block layout_head_meta_tags_image_twitter %}{{ metaImage ?? parent() }}{% endblock %}
{% block layout_head_meta_tags_image_meta %}{{ metaImage ?? parent() }}{% endblock %}
{% block layout_head_meta_tags_schema_webpage %}
{{ parent() }}
{% if activeRoute == 'sas.frontend.blog.detail' %}
{% set blogPath = app.request.attributes.get('sw-original-request-uri')|default(app.request.requestUri)|split('?')|first %}
{% set blogUrl = app.request.schemeAndHttpHost ~ blogPath %}
{% set authorName = '' %}
{% set logoUrl = theme_config('sw-logo-desktop') %}
{% set publisherData = {
'@type': 'Organization',
'@id': app.request.schemeAndHttpHost ~ '/#organization',
'name': config('core.basicInformation.shopName')|default('')|trim
} %}
{% set imageUrls = [] %}
{% set blogPostingData = {
'@context': 'https://schema.org',
'@type': 'BlogPosting',
'headline': entry.translated.title,
'datePublished': entry.publishedAt|date('c'),
'description': entry.translated.teaser|striptags|trim,
'mainEntityOfPage': {
'@type': 'WebPage',
'@id': blogUrl
},
'publisher': publisherData
} %}
{% if entry.blogAuthor %}
{% set authorName = entry.blogAuthor.displayName ?: entry.blogAuthor.translated.name %}
{% endif %}
{% if entry.updatedAt %}
{% set blogPostingData = blogPostingData|merge({
'dateModified': entry.updatedAt|date('c')
}) %}
{% endif %}
{% if authorName %}
{% set blogPostingData = blogPostingData|merge({
'author': {
'@type': 'Person',
'name': authorName
}
}) %}
{% endif %}
{% if entry.media %}
{% if entry.media.thumbnails.elements|length %}
{% for thumbnail in entry.media.thumbnails.elements %}
{% set imageUrls = imageUrls|merge([thumbnail.url]) %}
{% endfor %}
{% elseif entry.media.url %}
{% set imageUrls = [entry.media.url] %}
{% endif %}
{% endif %}
{% if imageUrls %}
{% set blogPostingData = blogPostingData|merge({
'image': imageUrls
}) %}
{% endif %}
{% if logoUrl %}
{% set blogPostingData = blogPostingData|merge({
'publisher': publisherData|merge({
'logo': {
'@type': 'ImageObject',
'url': logoUrl
}
})
}) %}
{% endif %}
<script type="application/ld+json">{{ blogPostingData|json_encode|raw }}</script>
{% endif %}
{% endblock %}