2016-03-09 21:11:34 +01:00
|
|
|
{% if paginator.total_pages > 1 %}
|
|
|
|
<nav class="pagination">
|
|
|
|
<ul>
|
|
|
|
{% comment %} Link for previous page {% endcomment %}
|
|
|
|
{% if paginator.previous_page %}
|
|
|
|
{% if paginator.previous_page == 1 %}
|
2016-10-06 21:40:30 +02:00
|
|
|
<li><a href="{{ '/' | absolute_url }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a></li>
|
2016-03-09 21:11:34 +01:00
|
|
|
{% else %}
|
2016-10-06 21:40:30 +02:00
|
|
|
<li><a href="{{ '/page' | absolute_url }}{{ paginator.previous_page | append: '/' }}">{{ 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 %}
|
2016-07-29 18:16:53 +02: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 %}
|
2016-10-06 21:40:30 +02:00
|
|
|
<li><a href="{{ '/' | absolute_url }}">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 %}
|
2016-10-06 21:40:30 +02:00
|
|
|
<li><a href="{{ '/page' | absolute_url }}{{ index | append: '/' }}" 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 %}
|
2016-10-06 21:40:30 +02:00
|
|
|
<li><a href="{{ '/page' | absolute_url }}{{ index | append: '/' }}">{{ 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 %}
|
|
|
|
<li><a href="{{ base_path }}/page{{ paginator.total_pages }}/">{{ paginator.total_pages }}</a></li>
|
|
|
|
{% 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 %}
|
2016-07-29 18:16:53 +02:00
|
|
|
<li><a href="{{ base_path }}/page{{ paginator.next_page }}/">{{ 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>
|
|
|
|
{% endif %}
|