Created
October 31, 2013 12:35
-
-
Save kylekeesling/7248951 to your computer and use it in GitHub Desktop.
Simple Jekyll Paginator Logic I didn't like the pagination logic provided in the Jekyll Docs (http://jekyllrb.com/docs/pagination/) since it repeated the HTML for displaying the button, so I came up w/ this. It stores the proper previous page path into a liquid variable then plops it into the HREF so you only have to code your button once
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.previous_page %} | |
{% if paginator.previous_page == 1 %} | |
{% capture previous_page %}/{% endcapture %} | |
{% else %} | |
{% capture previous_page %}/page{{ paginator.previous_page }}{% endcapture %} | |
{% endif %} | |
<a href="{{ previous_page }}" class="previous">← Newer Posts</a> | |
{% endif %} | |
{% if paginator.next_page %} | |
<a href="/page{{ paginator.next_page }}" class="next">Older Posts →</a> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SO much better.