{% extends "base.html" %}

{% load static dsfr_tags wagtailcore_tags wagtailimages_tags wagtail_dsfr_tags i18n %}

{% block title %}
  <title>{{ page.seo_title|default:page.title }} — {{ settings.sites_conformes_content_manager.CmsDsfrConfig.site_title }}</title>
{% endblock title %}

{% block description %}
  {% if page.search_description %}<meta name="description" content="{{ page.search_description }}" />{% endif %}
{% endblock description %}

{% block social_media %}
  <meta property="og:site_name" content="{{ request.get_host }}" />
  <meta property="og:title"
        content="{% if page.seo_title %}{{ page.seo_title }}{% else %}{{ page.title }}{% endif %}" />
  <meta property="og:type" content="article" />
  <meta property="og:url" content="{% canonical_url %}" />
  <meta property="og:description" content="{{ page.search_description }}" />
  <meta property="og:locale" content="{{ LANGUAGE_CODE }}" />

  {% if page.get_translations.live %}
    {% for translation in page.get_translations.live %}
      <meta property="og:locale:alternate"
            content="{{ translation.locale.language_code }}" />
    {% endfor %}
  {% endif %}

  <meta name="twitter:title"
        content="{% if page.seo_title %}{{ page.seo_title }}{% else %}{{ page.title }}{% endif %}" />
  <meta name="twitter:description" content="{{ page.search_description }}" />

  {% include "blocks/socialmedia_preview_image.html" %}
{% endblock social_media %}

{% block content %}
  {% include "sites_conformes_content_manager/blocks/heading.html" %}
  <div class="fr-container fr-pt-4w">
    {% include "sites_conformes_content_manager/blocks/breadcrumbs.html" %}
    
    {% if page.show_title %}
      <h1>
        {{ page.title }}
        {% include "sites_conformes_content_manager/blocks/page_visibility.html" %}
      </h1>
    {% endif %}
  </div>

  {% include "sites_conformes_content_manager/blocks/messages.html" %}

  {% include "sites_conformes_content_manager/blocks/blocks_stream.html" with stream=page.body %}

  <div class="fr-container fr-my-4w">
    {% for tag in page.tags.all|dictsort:"slug" %}
      <a class="fr-tag" target="_self" href="{% url 'global_tag' tag.slug %}">{{ tag }}</a>
    {% endfor %}
  </div>

  {% if settings.sites_conformes_content_manager.CmsDsfrConfig.show_share_links and settings.sites_conformes_content_manager.CmsDsfrConfig.share_links_content_pages %}
    {% include "blocks/share.html" %}
  {% endif %}

{% endblock content %}
