Closed puzant closed 6 years ago
Did you look at https://github.com/blakeembrey/metalsmith-pagination#template-usage? It's just a matter of doing whatever you want with those properties.
yes I did, but I can't figure out how to make the pagination with handlebars template
this is my code in blog,html
{{#each collections.blog-post}}
{{this.slug}}{{this.content.author.name}}
{{/each}}
I don't see anything that uses pagination, can you share how you're using it so someone can help?
<h2>Paginated Blog Posts</h2>
<ul>
{{#each pagination.files}}
<li>
<a href="/{{this.full_slug}}">{{this.content.title}}</a> \ {{this.content.author.name}} <img src="{{this.content.author.content.image }}"> \ {{ dateFormat content.date 'MMM DD, YYYY'}} \\
{{#each (arrayfromstring content.tags)}}
<a href="/blog/topics/{{slug this}}" >{{this}}.</a>
{{/each}}
</li>
{{/each}}
</ul>
I don't know how to make the collections appear paginated !
And can you share the issue you are facing here? Are you using a template plugin or something else to render?
the issue is I have a blog page where I am rendering the collection, but I don't know how make the collection paginated, to have each page show 10 blog posts I am using handlebars templates
I don't understand, if you're accessing pagination.files
it's already the paginated files. Is the issue you are having is that more than 10 files appear?
{{#each pagination.files}}
{{/each}}
here is my final code however I can't paginate the collection of the blogs
@puzant If you read through that code, you can see where it's incorrect. First you loop over pagination.files
which give you each "file" in a single page (as shown on the README). Second, you loop over the existing collection of every blog-post
again - which is not paginated. Can you see how it's broken now? You'd be outputting pageSize * collectionSize
number of files and should be pretty obvious to see the problem if you have more than one page.
I'm going to close this issue now, since https://github.com/blakeembrey/metalsmith-pagination/issues/38#issuecomment-390491795 looked correct but you didn't respond to what the issue was.
{{{ contents }}} {{#each collections.blog-post}} {{#eah pagination.files}} {{this.slug}} {{/each}} {{/each}}
this is the best I could do , but still it's not working !!!
I've searched everywhere in the documentations and I couldn't find a single example about using pagination with handlebars any help with this issue ?