Add pagination to the blog page
This commit is contained in:
parent
9d9795b64c
commit
3067d35497
1 changed files with 12 additions and 1 deletions
|
@ -1,13 +1,24 @@
|
|||
---
|
||||
title: Blog
|
||||
generator: pagination
|
||||
pagination:
|
||||
max_per_page: 30
|
||||
provider: data.posts
|
||||
use: [posts]
|
||||
draft: true
|
||||
---
|
||||
|
||||
<ul>
|
||||
{% for post in data.posts|sort((a, b) => b.date <=> a.date) %}
|
||||
{% for post in page.pagination.items %}
|
||||
<li>
|
||||
<a href="{{ post.url|trim('/', 'right') }}">{{ post.title }}</a> - {{ post.date|date('jS F Y') }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
{% if page.pagination.previous_page or page.pagination.next_page %}
|
||||
<nav class="flex justify-center pt-10 space-x-6">
|
||||
{% if page.pagination.previous_page %}<a href="{{ site.url }}{{ page.pagination.previous_page.url }}">← Newer Posts{% endif %}<br />
|
||||
{% if page.pagination.next_page %}<a href="{{ site.url }}{{ page.pagination.next_page.url }}">Older Posts →</a>{% endif %}<br />
|
||||
</nav>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue