{% load village_tags i18n %}
{% translate "Pagination" as pagination_label %}
<nav role="navigation"
     class="village-pagination"
     aria-label="{{ pagination_label }}"
     id="village-pagination"
     data-village-js-pagination="true">
  <ul class="village-pagination__list">
    <li>
      <a class="village-pagination__link village-pagination__link--first"
         {% if page_obj.has_previous %} href="?{% url_remplace_params page=1 %}" {% endif %}>{% translate "First page" %}</a>
    </li>
    <li>
      <a class="village-pagination__link village-pagination__link--prev village-pagination__link--lg-label"
         {% if page_obj.has_previous %} href="?{% url_remplace_params page=page_obj.previous_page_number %}" {% endif %}>
        {% translate "Previous page" %}
      </a>
    </li>
    {% if page_obj.pages_list %}
      {% for item in page_obj.pages_list %}
        {% if item == "…" %}
          <li>
            <a class="village-pagination__link village-unhidden-lg">…</a>
          </li>
        {% else %}
          <li>
            {% translate "Page" as page_label %}
            <a class="village-pagination__link"
               {% if item == page_obj.number %}aria-current="page"{% endif %}
               title="{{ page_label }} {{ item }}"
               href="?{% url_remplace_params page=item %}">{{ item }}</a>
          </li>
        {% endif %}
      {% endfor %}
    {% else %}
      <li>
        <a class="village-pagination__link"
           aria-current="page"
           title="{{ page_label }} {{ page_obj.number }} / {{ page_obj.paginator.num_pages }}"
           href="?{% url_remplace_params page=page_obj.number %}">
          {{ page_obj.number }} / {{ page_obj.paginator.num_pages }}
        </a>
      </li>
    {% endif %}
    <li>
      <a class="village-pagination__link village-pagination__link--next village-pagination__link--lg-label"
         {% if page_obj.has_next %} href="?{% url_remplace_params page=page_obj.next_page_number %}" {% endif %}>
        {% translate "Next page" %}
      </a>
    </li>
    <li>
      <a class="village-pagination__link village-pagination__link--last"
         {% if page_obj.has_next %} href="?{% url_remplace_params page=page_obj.paginator.num_pages %}" {% endif %}>
        {% translate "Last page" %}
      </a>
    </li>
  </ul>
</nav>
