aboutsummaryrefslogtreecommitdiff
path: root/_includes/paginator.html
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@gmail.com>2019-10-27 09:57:37 -0400
committerAndrew Lee <alee14498@gmail.com>2019-10-27 09:57:37 -0400
commite62e7bb6b14555c9bbe5d40d217103984f4f80e6 (patch)
tree21887d847dccacb47644eb6f74ce31326172303c /_includes/paginator.html
parent716ea6ed2b64c921a799d872a07bfbd53b2a3e58 (diff)
downloadpokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.tar.gz
pokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.tar.bz2
pokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.zip
Rewrite progress
Diffstat (limited to '_includes/paginator.html')
-rw-r--r--_includes/paginator.html69
1 files changed, 69 insertions, 0 deletions
diff --git a/_includes/paginator.html b/_includes/paginator.html
new file mode 100644
index 0000000..592a2cf
--- /dev/null
+++ b/_includes/paginator.html
@@ -0,0 +1,69 @@
+{% if paginator.total_pages > 1 %}
+<nav class="pagination">
+ {% assign first_page_path = site.paginate_path | replace: 'page:num', '' | replace: '//', '/' | relative_url %}
+ <ul>
+ {% comment %} Link for previous page {% endcomment %}
+ {% if paginator.previous_page %}
+ {% if paginator.previous_page == 1 %}
+ <li><a href="{{ first_page_path }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a></li>
+ {% else %}
+ <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>
+ {% endif %}
+ {% else %}
+ <li><a href="#" class="disabled"><span aria-hidden="true">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</span></a></li>
+ {% endif %}
+
+ {% comment %} First page {% endcomment %}
+ {% if paginator.page == 1 %}
+ <li><a href="#" class="disabled current">1</a></li>
+ {% else %}
+ <li><a href="{{ first_page_path }}">1</a></li>
+ {% 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 %}
+ <li><a href="{{ site.paginate_path | replace: ':num', index | replace: '//', '/' | relative_url }}" class="disabled current">{{ index }}</a></li>
+ {% 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 %}
+ <li><a href="{{ site.paginate_path | replace: ':num', index | relative_url }}">{{ index }}</a></li>
+ {% 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 %}
+ <li><a href="{{ site.paginate_path | replace: ':num', paginator.total_pages | replace: '//', '/' | relative_url }}">{{ paginator.total_pages }}</a></li>
+ {% endif %}
+
+ {% comment %} Link next page {% endcomment %}
+ {% if paginator.next_page %}
+ <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>
+ {% 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>
+{% endif %}