Created
August 23, 2021 09:12
-
-
Save SaraSoueidan/1b1ee2a2779500b065cabc8a8191ba91 to your computer and use it in GitHub Desktop.
11ty pagination
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
<nav class="c-collection-pagination" aria-labelledby="pagination-label"> | |
<h2 id="pagination-label" class="visually-hidden">Pagination</h2> | |
<ul> | |
<li> | |
{% if page.url != pagination.href.first %}<a href="{{ pagination.href.first }}">First</a> | |
{% else %}First{% endif %} | |
</li> | |
<li> | |
{% if page.url != pagination.href.last %}<a href="{{ pagination.href.last }}">Last</a> | |
{% else %}Last{% endif %} | |
</li> | |
<li> | |
{% if pagination.href.previous %}<a href="{{ pagination.href.previous }}">Previous</a> | |
{% else %}Previous{% endif %} | |
</li> | |
<li> | |
{% if pagination.href.next %}<a href="{{ pagination.href.next }}">Next</a> | |
{% else %}Next{% endif %} | |
</li> | |
<br> | |
{%- for pageEntry in pagination.pages %} | |
<li><a href="{{ pagination.hrefs[ loop.index0 ] }}" {% if page.url == pagination.hrefs[ loop.index0 ] %} aria-current="page"{% endif %}>Page {{ loop.index }}</a></li> | |
{%- endfor %} | |
</ul> | |
</nav> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment