Code Monkey home page Code Monkey logo

Comments (7)

CaptainCodeman avatar CaptainCodeman commented on July 17, 2024

Looks like the limit is set to 2 here:

recentPosts: await fetch('/posts.json?limit=2').then((res) => res.json())

from sveltekit-blog-template.

mattjennings avatar mattjennings commented on July 17, 2024

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?)

from sveltekit-blog-template.

ak4zh avatar ak4zh commented on July 17, 2024

@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.

from sveltekit-blog-template.

mattjennings avatar mattjennings commented on July 17, 2024

@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:

  • updated kit to next.357
  • removed /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.
  • changed adapter from static to auto as vercel was having issues with routing on the static adapter
  • updated svelte.config.js, jsconfig.json

from sveltekit-blog-template.

ak4zh avatar ak4zh commented on July 17, 2024

@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?

from sveltekit-blog-template.

mattjennings avatar mattjennings commented on July 17, 2024

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!

from sveltekit-blog-template.

ak4zh avatar ak4zh commented on July 17, 2024

The static pagination makes sense now.
Thank you for the answers.

from sveltekit-blog-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.