Skip to content

Commit

Permalink
Merge pull request #8 from 1peter10/fix-pagination
Browse files Browse the repository at this point in the history
partials/home_posts.html: Make pagination links work
  • Loading branch information
cydave authored Jul 18, 2024
2 parents 6f7376f + 79bc55e commit 28d9fa9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions content/posts/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ sort_by = "date"
paginate_by = 5
insert_anchor_links = "right"
generate_feed = true
transparent = true
+++
12 changes: 8 additions & 4 deletions templates/partials/home_posts.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% set posts = get_section(path="posts/_index.md") %}
{% for page in posts.pages | slice(end=10) %}
{% for page in paginator.pages %}
<article class="post-entry">
<header class="entry-header">
<h2>{{ page.title }}</h2>
Expand All @@ -16,10 +15,15 @@ <h2>{{ page.title }}</h2>
</article>
{% endfor %}

{% if posts.pages | length > 5 %}
{% if paginator %}
<footer class="page-footer">
<nav class="pagination">
<a class="next" href="#todo">Next »</a>
{% if paginator.previous %}
<a class="previous" href="{{ paginator.previous | safe }}">« Previous</a>
{% endif %}
{% if paginator.next %}
<a class="next" href="{{ paginator.next | safe }}">Next »</a>
{% endif %}
</nav>
</footer>
{% endif %}
2 changes: 1 addition & 1 deletion templates/partials/post_nav_links.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set posts_section = get_section(path="posts/_index.md") %}
{% set posts_section = get_section(path="_index.md") %}
{% set num_posts = posts_section | length %}
{% if num_posts > 1 %}
<nav class="paginav">
Expand Down

0 comments on commit 28d9fa9

Please sign in to comment.