Last active
April 30, 2021 17:47
-
-
Save Narottam04/91b283de6bc2aea3a8b34553c941f0a7 to your computer and use it in GitHub Desktop.
Pagination not working. No errors when compiling.
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
--- | |
layout: layouts/allposts.njk | |
permalink: '/posts{% if pagination.pageNumber > 0 %}/page/{{ pagination.pageNumber }}{% endif %}/index.html' | |
title: My Posts | |
pagination: | |
data: collections.posts | |
size: 3 | |
reverse: true | |
--- | |
{% set postslist = collections.posts %} | |
{% include "postslist.njk" %} |
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
<!-- blog post content --> | |
<section class="blog-content"> | |
<div class="main-heading"> | |
<h1 class="font-mont h1-style">BLOGS</h1> | |
</div> | |
<ol class="blogs"> | |
{% for post in postslist %} | |
<!-- blog posts --> | |
<li class="blog-container"> | |
<div> | |
<a href="{{ post.url | url}}"> | |
<img src="{{post.data.featuredImage}}" alt="blogs" /> | |
</a> | |
<div class="blog-heading"> | |
<div> | |
<a href="{{post.url | url}}"> | |
<p class="p-style">{{post.data.title}}</p> | |
</a> | |
<p>{{post.data.tag}}</p> | |
</div> | |
<div> | |
<img src="/images/link pointer.svg" alt="link" class="link" /> | |
</div> | |
</div> | |
</div> | |
</li> | |
{% endfor %} | |
</ol> | |
<ol> | |
<li>{% if pagination.href.previous %}<a href="{{ pagination.href.previous }}">Previous</a>{% else %}Previous{% endif %}</li> | |
{%- 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 %} | |
<li>{% if pagination.href.next %}<a href="{{ pagination.href.next }}">Next</a>{% else %}Next{% endif %}</li> | |
</ol> | |
</section> | |
After changing the permalink, I am not getting any error but pagination is not working.
file structure after permalink was added:
posts/page/1
all the blog posts are added to 1 and there is no new file where other posts after pagination is added.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
when I changed the value of size to 4 i got the following error
Problem writing Eleventy templates: (more in DEBUG output)
DuplicatePermalinkOutputError
was thrown:(Repeated output has been truncated…)