sveltekit-blog-starter icon indicating copy to clipboard operation
sveltekit-blog-starter copied to clipboard

Category won't fully populate for blog posts

Open teonbrooks opened this issue 1 year ago • 1 comments

I noticed that under the category section of my blog that it is not fully populated. I believe this is caused by the line below

https://github.com/josh-collinsworth/sveltekit-blog-starter/blob/456314996b4ec4055108ed7c6ec67683e4570ae9/src/routes/blog/category/%2Bpage.server.js#L2

when the posts.json is being fetched, it's being limited with the parameter postsPerPages, which only retrieves the first page of blog posts. However, to properly populate the category page, it needs to retrieve the entirety of posts.

It doesn't currently have a way to accept an argument

teonbrooks avatar Mar 13 '24 18:03 teonbrooks

@teonbrooks Sorry, it looks like I messed up category pagination. I'll leave this open until I fix that.

Meanwhile, if you want all posts of a given category to show up on one page, you can just delete the limit: -1 option from the options object in src/routes/blog/category/[category]/+page.server.js. That'll cause the API call to return all posts.

josh-collinsworth avatar Apr 08 '24 16:04 josh-collinsworth