Last active
May 23, 2020 18:32
-
-
Save mauricedb/902a03293f636f04c99073c473a81328 to your computer and use it in GitHub Desktop.
Pagination with Eleventy and Nunjucks
This file contains hidden or 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
<span>Page {{ pagination.pageNumber + 1 }} of {{ pagination.pages.length }}:</span> | |
{% if page.url !== pagination.href.first %}<a href="{{ pagination.href.first }}"><i class="ion-ios-skipbackward"></i></a>{% endif %} | |
{% if pagination.href.previous %}<a href="{{ pagination.href.previous }}"><i class="ion-arrow-left-b"></i></a>{% endif %} | |
{%- for pageEntry in pagination.pages %} | |
{%- if (loop.index0 - pagination.pageNumber) | abs <= 3 %} | |
<a href="{{ pagination.hrefs[ loop.index0 ] -}}" | |
{%- if page.url === pagination.hrefs[ loop.index0 ] %} class="active"{% endif %}> | |
{{- loop.index -}} | |
</a> | |
{%- endif %} | |
{%- endfor %} | |
{% if pagination.href.next %}<a href="{{ pagination.href.next }}"><i class="ion-arrow-right-b"></i></a>{% endif %} | |
{% if page.url !== pagination.href.last %}<a href="{{ pagination.href.last }}"><i class="ion-ios-skipforward"></i></a>{% endif %} |
Author
mauricedb
commented
May 23, 2020
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment