Last active
October 27, 2015 18:57
-
-
Save rnkn/8d4ba45ef26b643f9705 to your computer and use it in GitHub Desktop.
A better Jekyll paginator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if paginator.total_pages > 1 %} | |
<p> | |
{% if paginator.previous_page == 1 %} | |
<a href="{{ '/blog/' | prepend: site.baseurl }}">previous</a> | |
{% elsif paginator.previous_page %} | |
<a href="{{ paginator.previous_page_path | prepend: site.baseurl }}">previous</a> | |
{% else %} | |
previous | |
{% endif %} | |
{% for page in (1..paginator.total_pages) %} | |
{% if page == paginator.page %} | |
{{ page }} | |
{% elsif page == 1 %} | |
<a href="{{ '/blog/' | prepend: site.baseurl }}">{{ page }}</a> | |
{% else %} | |
<a href="{{ site.paginate_path | replace: ':num', page | prepend: site.baseurl }}">{{ page }}</a> | |
{% endif %} | |
{% endfor %} | |
{% if paginator.next_page %} | |
<a href="{{ paginator.next_page_path | prepend: site.baseurl }}">next</a> | |
{% else %} | |
next | |
{% endif %} | |
</p> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment