{% extends "base.html" %}

{% load static dsfr_tags wagtailcore_tags wagtailimages_tags wagtail_dsfr_tags i18n %}

{% block title %}
  <title>
    {% if object_list.count %}
      {{ object_list.count }} {% translate "result" %}{{ object_list.count|pluralize }}
    {% else %}
      {% translate "No results" %}
    {% endif %}
    {% blocktranslate %}for query "{{ query }}"{% endblocktranslate %} — {{ settings.sites_conformes_content_manager.CmsDsfrConfig.site_title }}
  </title>
{% endblock title %}

{% if page.search_description %}
  {% block description %}
    <meta name="description"
          content="{% if object_list.count %} {{ object_list.count }} résultat{{ object_list.count|pluralize }} {% else %} Aucun résultat {% endif %} pour la recherche « {{ query }} »" />
  {% endblock description %}
{% endif %}

{% block content %}
  <div class="fr-container fr-my-4w">
    <h1>
      {% if object_list.count %}
        {{ object_list.count }} {% translate "result" %}{{ object_list.count|pluralize }}
      {% else %}
        {% translate "No results" %}
      {% endif %}
      {% blocktranslate %}for query "{{ query }}"{% endblocktranslate %}
    </h1>
    {% if object_list.count %}
      <ol>
        {% for result in object_list %}
          <li>
            <h2 class="fr-h4">
              <a href="{% pageurl result %}">{{ result }}</a>
            </h2>
            {% if result.search_description %}<p>{{ result.search_description|safe }}</p>{% endif %}

          </li>
        {% endfor %}
      </ol>
    {% else %}
      <div class="fr-my-7w fr-mt-md-12w fr-mb-md-10w fr-grid-row fr-grid-row--gutters fr-grid-row--middle fr-grid-row--center">
        <div class="fr-py-0 fr-col-12 fr-col-md-6">
          <h2 class="fr-mb-3w">{% translate "We did not find any content matching your search." %}</h2>
          <p>{% translate "To continue your visit, you can consult our home page." %}</p>
          <div class="fr-btns-group fr-btns-group--inline-md">
            <a class="fr-btn" href="{% root_url %}">{% translate "Back to home page" %}</a>
          </div>
        </div>
        <div class="fr-col-12 fr-col-md-3 fr-col-offset-md-1 fr-px-6w fr-px-md-0 fr-py-0">
          <img src="{% static 'dsfr/dist/artwork/pictograms/digital/search.svg' %}"
               class="fr-responsive-img"
               alt=""
               width="300"
               height="300" />
        </div>
      </div>
    {% endif %}
  </div>

{% endblock content %}
