make pagination a "real" component

This commit is contained in:
madrilene 2024-02-13 15:39:02 +01:00
parent 3bfc787fdf
commit fff583fe8d
2 changed files with 9 additions and 7 deletions

View file

@ -1,14 +1,14 @@
<section class="region">
<nav role="navigation" aria-labelledby="pagination_label">
<span id="pagination_label" hidden>{{ meta.blog.paginationLabel }}</span>
<span id="prefix" hidden>{{ meta.blog.paginationPage }}</span>
<span id="pagination_label" hidden>{{ meta[metaKey].paginationLabel }}</span>
<span id="prefix" hidden>{{ meta[metaKey].paginationPage }}</span>
<ol class="pagination | cluster" role="list">
<li>
{% if pagination.href.previous %}
<a href="{{ pagination.href.previous }}"> {{ meta.blog.paginationPrevious }} </a>
{% else %} {{ meta.blog.paginationPrevious }} {% endif %}
<a href="{{ pagination.href.previous }}"> {{ meta[metaKey].paginationPrevious }} </a>
{% else %} {{ meta[metaKey].paginationPrevious }} {% endif %}
</li>
{% if meta.blog.paginationNumbers %}
{% if meta[metaKey].paginationNumbers %}
{%- for pageEntry in pagination.pages %}
<li>
<a href="{{ pagination.hrefs[ loop.index0 ] }}" id="link_{{ loop.index }}" aria-labelledby="prefix link_{{ loop.index }}" {% if page.url == pagination.hrefs[ loop.index0 ] %} aria-current="page" {% endif %}>
@ -18,8 +18,8 @@
{% endif %}
<li>
{% if pagination.href.next %}
<a href="{{ pagination.href.next }}">{{ meta.blog.paginationNext }}</a>
{% else %} {{ meta.blog.paginationNext }} {% endif %}
<a href="{{ pagination.href.next }}">{{ meta[metaKey].paginationNext }}</a>
{% else %} {{ meta[metaKey].paginationNext }} {% endif %}
</li>
</ol>
</nav>

View file

@ -33,6 +33,8 @@ masonry: true
<!-- set collection to paginate -->
{% set collectionToPaginate = collections.posts %}
<!-- set target pagination settings in meta.js -->
{% set metaKey = "blog" %}
<!-- if the number of items in the collection is greater than the number of items shown on one page -->
{% if collectionToPaginate.length > pagination.size %}
<!-- include pagination -->