jamestagal / plenti-educenter

0 stars 1 forks source link

Pagination #5

Closed jamestagal closed 2 years ago

jamestagal commented 2 years ago

Hi @jimafisk I've just finished putting the pagination together for this theme and followed along with your tutorial but I am seeing a couple of problems. All the code seems to be fine and I am not getting any errors. However here are the issues:

  1. When I refresh the page, blog you can see the pagination ui appear quickly at the top of the page then it disappears. So it does not remain visible on the page.
  2. I set the postsPerPage to 4 but I still see 6 on the blog page.

Could you please take a look for me when you can. 😄

Best regards, Ben

jimafisk commented 2 years ago

Hi @jamestagal,

By default pagers are set to null instead of 1 now: https://github.com/plentico/plenti/issues/191#issuecomment-1186242647

So you need to change this line: https://github.com/jamestagal/plenti-educenter/blob/main/layouts/content/blog.svelte#L7

To something like:

$: currentPage = content.pager ? content.pager : 1;

Let me know if that works! Thanks!

jamestagal commented 2 years ago

Hi @jimafisk Thanks for pointing that change out. However that causes it to append blog to the end of the current blog url when clicking page 2 or 1 buttons. see screenshot.

Screen Shot 2022-10-08 at 10 01 49 am

Also the other forward and back buttons are disabled.

Ben

jimafisk commented 2 years ago

Hi @jamestagal,

I just pushed a change that should fix this: https://github.com/jamestagal/plenti-educenter/commit/331f2dc459e778ee704ec8b537f2f50aca9ce7c2

The problem was the pagination links are all using relative links:

https://github.com/jamestagal/plenti-educenter/blob/331f2dc459e778ee704ec8b537f2f50aca9ce7c2/layouts/components/pagination.svelte

You could have changed all the relative links (e.g. blog/2) to absolute links (e.g. /blog/2) and that would have fixed it as well. However, adding a baseurl (like I did in my commit) allows you to serve your site off a subfolder (like https://mysite.com/mysite) if you'd like :).

jamestagal commented 2 years ago

Hi @jimafisk Thank you. Yes that fixed it! and having a baseurl is a nice to have feature. 😃

thanks again Jim. Ben