Guide_Wii/_includes/paginator.html

70 lines
3.2 KiB
HTML
Raw Normal View History

2016-10-30 01:02:14 +02:00
{% if paginator.total_pages > 1 %}
<nav class="pagination">
2017-10-28 21:58:34 +02:00
{% assign first_page_path = site.paginate_path | replace: 'page:num', '' | replace: '//', '/' | absolute_url %}
2016-10-30 01:02:14 +02:00
<ul>
{% comment %} Link for previous page {% endcomment %}
{% if paginator.previous_page %}
{% if paginator.previous_page == 1 %}
2017-10-28 21:58:34 +02:00
<li><a href="{{ first_page_path }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a></li>
2016-10-30 01:02:14 +02:00
{% else %}
2017-10-28 21:58:34 +02:00
<li><a href="{{ site.paginate_path | replace: ':num', paginator.previous_page | replace: '//', '/' | absolute_url }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a></li>
2016-10-30 01:02:14 +02:00
{% endif %}
{% else %}
2017-10-28 21:58:34 +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-10-30 01:02:14 +02:00
{% endif %}
{% comment %} First page {% endcomment %}
{% if paginator.page == 1 %}
<li><a href="#" class="disabled current">1</a></li>
{% else %}
2017-10-28 21:58:34 +02:00
<li><a href="{{ first_page_path }}">1</a></li>
2016-10-30 01:02:14 +02:00
{% endif %}
{% assign page_start = 2 %}
{% if paginator.page > 4 %}
{% assign page_start = paginator.page | minus: 2 %}
{% comment %} Ellipsis for truncated links {% endcomment %}
<li><a href="#" class="disabled">&hellip;</a></li>
{% 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 %}
2017-10-28 21:58:34 +02:00
<li><a href="{{ site.paginate_path | replace: ':num', index | replace: '//', '/' | absolute_url }}" class="disabled current">{{ index }}</a></li>
2016-10-30 01:02:14 +02:00
{% else %}
{% comment %} Distance from current page and this link {% endcomment %}
{% assign dist = paginator.page | minus: index %}
{% if dist < 0 %}
{% comment %} Distance must be a positive value {% endcomment %}
{% assign dist = 0 | minus: dist %}
{% endif %}
2017-10-28 21:58:34 +02:00
<li><a href="{{ site.paginate_path | replace: ':num', index | absolute_url }}">{{ index }}</a></li>
2016-10-30 01:02:14 +02:00
{% endif %}
{% endfor %}
{% comment %} Ellipsis for truncated links {% endcomment %}
{% if pages_to_end > 3 %}
<li><a href="#" class="disabled">&hellip;</a></li>
{% endif %}
{% if paginator.page == paginator.total_pages %}
<li><a href="#" class="disabled current">{{ paginator.page }}</a></li>
{% else %}
2017-10-28 21:58:34 +02:00
<li><a href="{{ site.paginate_path | replace: ':num', paginator.total_pages | replace: '//', '/' | absolute_url }}">{{ paginator.total_pages }}</a></li>
2016-10-30 01:02:14 +02:00
{% endif %}
{% comment %} Link next page {% endcomment %}
{% if paginator.next_page %}
2017-10-28 21:58:34 +02:00
<li><a href="{{ site.paginate_path | replace: ':num', paginator.next_page | replace: '//', '/' | absolute_url }}">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</a></li>
2016-10-30 01:02:14 +02:00
{% else %}
<li><a href="#" class="disabled"><span aria-hidden="true">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</span></a></li>
{% endif %}
</ul>
</nav>
2016-11-23 02:29:35 +01:00
{% endif %}