2016-03-09 21:11:34 +01:00
|
|
|
{% if paginator.total_pages > 1 %}
|
|
|
|
<nav class="pagination">
|
2020-03-17 02:17:53 +01:00
|
|
|
{% assign first_page_path = paginator.first_page_path | default: site.paginate_path | replace: 'page:num', '' | replace: '//', '/' | relative_url %}
|
2016-03-09 21:11:34 +01:00
|
|
|
<ul>
|
|
|
|
{% comment %} Link for previous page {% endcomment %}
|
|
|
|
{% if paginator.previous_page %}
|
|
|
|
{% if paginator.previous_page == 1 %}
|
2017-01-24 16:42:02 +01:00
|
|
|
<li><a href="{{ first_page_path }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% else %}
|
2018-03-20 16:35:36 +01:00
|
|
|
<li><a href="{{ site.paginate_path | replace: ':num', paginator.previous_page | replace: '//', '/' | relative_url }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% endif %}
|
2016-03-30 21:26:25 +02:00
|
|
|
{% else %}
|
2017-01-24 16:42:02 +01:00
|
|
|
<li><a href="#" class="disabled"><span aria-hidden="true">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</span></a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% endif %}
|
|
|
|
|
2016-03-30 21:26:25 +02:00
|
|
|
{% comment %} First page {% endcomment %}
|
2016-03-09 21:11:34 +01:00
|
|
|
{% if paginator.page == 1 %}
|
2016-03-30 21:26:25 +02:00
|
|
|
<li><a href="#" class="disabled current">1</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% else %}
|
2017-01-24 16:42:02 +01:00
|
|
|
<li><a href="{{ first_page_path }}">1</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% assign page_start = 2 %}
|
|
|
|
{% if paginator.page > 4 %}
|
|
|
|
{% assign page_start = paginator.page | minus: 2 %}
|
|
|
|
{% comment %} Ellipsis for truncated links {% endcomment %}
|
2016-03-30 21:26:25 +02:00
|
|
|
<li><a href="#" class="disabled">…</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% assign page_end = paginator.total_pages | minus: 1 %}
|
|
|
|
{% assign pages_to_end = paginator.total_pages | minus: paginator.page %}
|
|
|
|
{% if pages_to_end > 4 %}
|
|
|
|
{% assign page_end = paginator.page | plus: 2 %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% for index in (page_start..page_end) %}
|
|
|
|
{% if index == paginator.page %}
|
2018-03-20 16:35:36 +01:00
|
|
|
<li><a href="{{ site.paginate_path | replace: ':num', index | replace: '//', '/' | relative_url }}" class="disabled current">{{ index }}</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% else %}
|
2016-03-30 21:26:25 +02:00
|
|
|
{% comment %} Distance from current page and this link {% endcomment %}
|
2016-03-09 21:11:34 +01:00
|
|
|
{% assign dist = paginator.page | minus: index %}
|
|
|
|
{% if dist < 0 %}
|
2016-03-30 21:26:25 +02:00
|
|
|
{% comment %} Distance must be a positive value {% endcomment %}
|
2016-03-09 21:11:34 +01:00
|
|
|
{% assign dist = 0 | minus: dist %}
|
|
|
|
{% endif %}
|
2018-03-20 16:35:36 +01:00
|
|
|
<li><a href="{{ site.paginate_path | replace: ':num', index | relative_url }}">{{ index }}</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
|
2016-03-30 21:26:25 +02:00
|
|
|
{% comment %} Ellipsis for truncated links {% endcomment %}
|
2016-03-09 21:11:34 +01:00
|
|
|
{% if pages_to_end > 3 %}
|
2016-03-30 21:26:25 +02:00
|
|
|
<li><a href="#" class="disabled">…</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if paginator.page == paginator.total_pages %}
|
2016-03-30 21:26:25 +02:00
|
|
|
<li><a href="#" class="disabled current">{{ paginator.page }}</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% else %}
|
2018-03-20 16:35:36 +01:00
|
|
|
<li><a href="{{ site.paginate_path | replace: ':num', paginator.total_pages | replace: '//', '/' | relative_url }}">{{ paginator.total_pages }}</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% endif %}
|
|
|
|
|
2016-03-30 21:26:25 +02:00
|
|
|
{% comment %} Link next page {% endcomment %}
|
2016-03-09 21:11:34 +01:00
|
|
|
{% if paginator.next_page %}
|
2018-03-20 16:35:36 +01:00
|
|
|
<li><a href="{{ site.paginate_path | replace: ':num', paginator.next_page | replace: '//', '/' | relative_url }}">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</a></li>
|
2016-03-30 21:26:25 +02:00
|
|
|
{% else %}
|
2016-07-29 18:16:53 +02:00
|
|
|
<li><a href="#" class="disabled"><span aria-hidden="true">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</span></a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% endif %}
|
|
|
|
</ul>
|
|
|
|
</nav>
|
2017-01-24 16:42:02 +01:00
|
|
|
{% endif %}
|