custom/plugins/SasBlogModule/src/Resources/views/storefront/layout/meta.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/layout/meta.html.twig' %}
  2. {% if activeRoute == 'sas.frontend.blog.detail' and entry.media.url %}
  3.     {% set metaImage = entry.media.url|striptags|trim %}
  4. {% endif %}
  5. {% block layout_head_canonical %}
  6.     {% if activeRoute == 'sas.frontend.blog.detail' %}
  7.         {% set blogCanonicalPath = app.request.attributes.get('sw-original-request-uri')|default(app.request.requestUri)|split('?')|first %}
  8.         {% set blogCanonicalUrl = app.request.schemeAndHttpHost ~ blogCanonicalPath %}
  9.         <link rel="canonical" href="{{ blogCanonicalUrl }}"/>
  10.     {% else %}
  11.         {{ parent() }}
  12.     {% endif %}
  13. {% endblock %}
  14. {% block layout_head_meta_tags_image_og %}{{ metaImage ?? parent() }}{% endblock %}
  15. {% block layout_head_meta_tags_image_twitter %}{{ metaImage ?? parent() }}{% endblock %}
  16. {% block layout_head_meta_tags_image_meta %}{{ metaImage ?? parent() }}{% endblock %}
  17. {% block layout_head_meta_tags_schema_webpage %}
  18.     {{ parent() }}
  19.     {% if activeRoute == 'sas.frontend.blog.detail' %}
  20.         {% set blogPath = app.request.attributes.get('sw-original-request-uri')|default(app.request.requestUri)|split('?')|first %}
  21.         {% set blogUrl = app.request.schemeAndHttpHost ~ blogPath %}
  22.         {% set authorName = '' %}
  23.         {% set logoUrl = theme_config('sw-logo-desktop') %}
  24.         {% set publisherData = {
  25.             '@type': 'Organization',
  26.             '@id': app.request.schemeAndHttpHost ~ '/#organization',
  27.             'name': config('core.basicInformation.shopName')|default('')|trim
  28.         } %}
  29.         {% set imageUrls = [] %}
  30.         {% set blogPostingData = {
  31.             '@context': 'https://schema.org',
  32.             '@type': 'BlogPosting',
  33.             'headline': entry.translated.title,
  34.             'datePublished': entry.publishedAt|date('c'),
  35.             'description': entry.translated.teaser|striptags|trim,
  36.             'mainEntityOfPage': {
  37.                 '@type': 'WebPage',
  38.                 '@id': blogUrl
  39.             },
  40.             'publisher': publisherData
  41.         } %}
  42.         {% if entry.blogAuthor %}
  43.             {% set authorName = entry.blogAuthor.displayName ?: entry.blogAuthor.translated.name %}
  44.         {% endif %}
  45.         {% if entry.updatedAt %}
  46.             {% set blogPostingData = blogPostingData|merge({
  47.                 'dateModified': entry.updatedAt|date('c')
  48.             }) %}
  49.         {% endif %}
  50.         {% if authorName %}
  51.             {% set blogPostingData = blogPostingData|merge({
  52.                 'author': {
  53.                     '@type': 'Person',
  54.                     'name': authorName
  55.                 }
  56.             }) %}
  57.         {% endif %}
  58.         {% if entry.media %}
  59.             {% if entry.media.thumbnails.elements|length %}
  60.                 {% for thumbnail in entry.media.thumbnails.elements %}
  61.                     {% set imageUrls = imageUrls|merge([thumbnail.url]) %}
  62.                 {% endfor %}
  63.             {% elseif entry.media.url %}
  64.                 {% set imageUrls = [entry.media.url] %}
  65.             {% endif %}
  66.         {% endif %}
  67.         {% if imageUrls %}
  68.                 {% set blogPostingData = blogPostingData|merge({
  69.                     'image': imageUrls
  70.                 }) %}
  71.         {% endif %}
  72.         {% if logoUrl %}
  73.             {% set blogPostingData = blogPostingData|merge({
  74.                 'publisher': publisherData|merge({
  75.                     'logo': {
  76.                         '@type': 'ImageObject',
  77.                         'url': logoUrl
  78.                     }
  79.                 })
  80.             }) %}
  81.         {% endif %}
  82.         <script type="application/ld+json">{{ blogPostingData|json_encode|raw }}</script>
  83.     {% endif %}
  84. {% endblock %}