Closed jamestagal closed 2 years ago
hi @jamestagal ... your URL contains undefinedposts/
in your route before the page number 2
. It looks like you have a problem with your content values or your plenti.json
.
The paginate.svelte
component, has a calculation for pagepath as follows:
pagePath = (baseurl + content.path.replace(/[0-9]/g, "")).replace("//", "") + "/";
The goal of pagePath
is to generate the correct URL path as set in the plenti.json
. In other words, the plenti.json
sets the specified locations for plenti to creates files in, and pagePath
generates html that points to those locations. In your case, the content.path
seems to be undefined. The page content for project
pages look as follows. Notice what "path" looks like for both pages:
{
"pager": 1,
"path": "projs/1",
"type": "projs",
"filename": "projs.json",
"fields": { "title": "Projects", "enabled": true, "menu": true }
},{
"pager": 2,
"path": "projs/2",
"type": "projs",
"filename": "projs.json",
"fields": { "title": "Projects", "enabled": true, "menu": true }
}
We can redefine pagePath
using "type" instead, as follows:
pagePath = baseurl + (content.type === "index" ? "" : content.type + "/");
Does this change fix your issue? If not, then you likely need to tweak it to point to the paths where your plenti.json
is configured.
Cheers, Roberto
btw @jamestagal, if you want something more static, we could try something like:
switch (content.type) {
case "projs":
pagePath = baseurl + "projects/";
break;
case "catgs":
pagePath = baseurl + "categories/";
break;
case "tags":
pagePath = baseurl + "tags/";
break;
default:
pagePath = baseurl;
}
In this approach, we need to account for each page type where we want pagination. So notice, when we get the pagination sorted, we can use it for categories and tags, and we could spell out the name "categories" when the "catgs" content is being compiled. In the plenti.json, we could then have:
"catgs": "categories/:filename/:paginate(totalCatgsPages)"
You could use this approach for the projs
content.type and set the pagePath to pagePath = baseurl + "posts/";
Hi @roobyz
Ok I can try this approach. Where would i put the switch statement? in the script tag of the paginate.svelte
file?
Ben
I've been working on the tag and category naming request and as part of that effort, I believe that I have a more ideal solution. That said, this requires a pretty broad refactor. ;-)
Hi @roobyz I ran into this issue recently when navigating to the second Posts page I get the following error:
https://vigorous-einstein-b90548.netlify.app/undefinedposts/2
I think this happened after I reconfigured the Post grouping of a couple of existing post and as a result it reduced all posts to be listed on one page...but there aren't any post of page 2....any longer hence the error.
Could you please have a look into this issue.
Best regards, Ben