Closed ak4zh closed 2 years ago
Looks like the limit is set to 2 here:
Hm, strange. I've been holding off updating this template until 1.0 comes out as it seems to be around the corner. This didn't happen prior to updating kit? If you can create a reproduction so I can take a look that would be very helpful.
The recentPosts snippet is only used for the index page and shouldn't affect /posts (maybe there's some weird caching going on?)
@mattjennings The issue only arise after you update kit version to 1.0.0-next.357 (I did not tested with lower versions)
Downgrading the kit to current locked version removes the issue immediately with no other change in the codebase (except some tiny stuffs like changing %svelte.head%
to %sveltekit.head%
etc.
Also notice you will not face the issue when you run it in dev mode npm run dev
It only appears on production build npm run build && npm run preview
The issue has no relevance with the limit set in recentPosts.
I tried to open the endpoint /posts.json
without any query params and it still returns only 2 posts always even when you paginate it will always return same latest 2 post for every page and it also allows you to paginate as much as you want, you can go up on page count without any limit, even if you have just 20 posts, you can go to page 100 and still see same 2 post always.
@Ak4zh I've updated this template the latest version of kit and made a few changes. Please look over these changes or make a new copy of this repo and move your content over (probably the easiest way).
Here's a summary of the changes:
/posts.json.js
in favour of page endpoints for the routes that used it. I'm not entirely sure what was causing it to only show 2 posts, but I much prefer the page endpoints approach anyway and it solved the issue.@mattjennings Thanks for the update. I am planning to make a pull request to probably add a search feature and post category. I am also wondering if there is a specific reason you chose to run pagination via a static url instead of query params?
I wanted to keep it working with the static adapter. Using query params would have meant SSR or client-side data fetching, and as a result breaking the static export. Now that it's using auto maybe I'll change that, I dunno. I don't want SSR to be a requirement (and therefore requiring vercel/netlify/a node server to deploy).
re: search & post category functionality, I'm probably just going to leave this template as it is features-wise. But I appreciate the idea!
The static pagination makes sense now. Thank you for the answers.
I tried to update with the latest version @sveltejs/kit ^1.0.0-next.357 Everything works fine, I only stumble across one issue after the update.
The issue is the /posts only returns 2 latest posts, even when you paginate you will always get the latest 2 blog post only until you do a browser based hard refresh. The /posts.json endpoint also returns only 2 posts no matter how many blog posts you have. The above issue does not seem to occur in dev mode
npm run dev
, it only occurs after you build the appnpm run build && npm run preview
I want to update the kit because I find the param matcher feature really helpful to split my post to different category like /posts, /projects, /ideas