Closed ryanwiemer closed 6 years ago
Oooh, super interesting use case. Hadn't thought at all about that. I'm open to adding such an option. It will add a little complexity I think, I'll contemplate on it a few days and see what comes up.
@chmac Sounds good!
In case it's helpful I was able to achieve the desired functionality albeit I had to do the pagination logic manually without the plugin. It's a little messy but it works:
@ryanwiemer Thanks. That’s definitely helpful. I was thinking of calculating the number of pages with slightly different logic, and then doing something like limit = page === 0 ? postsPerFirstPage : postsPerPage
. Will contemplate further and get back next week.
Cool. Yeah, I'm sure there are better ways to simplify the logic. Like I said it's a little messy right now. 😉
@ryanwiemer Had a quick crack at this. It looks like the changeset is quite small. I haven't tested this yet, but will try to do that this week / next, and if it all looks good, release it. Any feedback on the commit above would be greatly appreciated. :-)
@ryanwiemer Wow, it's more complicated than I first though. I forgot to update the $skip
parameter. I think I've covered that now and I've done some light testing. But will let this sit for a few days and look at it again before releasing.
@chmac,
Awesome! I think this will be a very useful feature. Let me know once you are ready to officially release it. I would love to use your plugin on my gatsby-starter rather than do all the logic manually in the gatsby-node.js
file. Your approach to pagination definitely resonates with me more than the other plugins out there today. 👍
It's out as v 0.3.0. I forgot to look at your bug in #7 before releasing. Will do that now.
@chmac ,
Do you have any thoughts on how to achieve a different number of posts on the first page vs other paginated pages? In a perfect world it would be an additional option such as
itemsPerFirstPage
.It's pretty common to see something like the home page with a smaller number of posts while the paginated pages show more. So for example 3 posts on the homepage but then 9 posts per subsequent paginated page.