-
-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array pagination fails on serverless #2853
Comments
Cross posting our social discussion! https://fediverse.zachleat.com/@zachleat/109994443453826167 I am looking at this today! |
Alright I did uncover a temporary workaround for you that works in current versions! ---js
{
title: "Posts",
pagination: {
data: "collections.post",
reverse: true,
alias: "posts",
size: 2,
serverless: "eleventy.serverless.path.page",
serverlessFilter: function(data, key) {
let chunks = [];
// this code assumes a page chunk size of 2 and adds them in reverse order
for(let j=0, k=data.length; j<k; j+=2) {
chunks.push([data[j+1], data[j]]);
}
return chunks[chunks.length - (key || 0)];
},
},
permalink: {
serverless: ["/serverless/", "/serverless/:page/"],
}
}
--- (Noting that |
Okay, cool! Is there likely to be a new version that fixes this without a workaround? If not, how would I be able to generate the dynamic previous and next and make them null if we're at the start/end? |
This will ship with v2.0.1 |
Just pushed a small fix here that unlocks the use of multiple serverless URLs in array pagination (including one without a path param)
Navigating to |
…emplate (including one without a serverless path param)
Yessss! Wonderful stuff. Thank you ever so much. |
Does this also solve: And remove the need for this documentation change? |
@dwkns let me look! |
@dwkns I added support for Array-based serverless pagination with |
Operating system
macOS 13.0 (22A380)
Eleventy
2.0.0
Describe the bug
The pagination works expected in build:
/build/
/build/2/
The pagination works here in serverless:
/serverless/
But it doesn't work when you go to page 2:
/serverless/2/
Reproduction steps
No response
Expected behavior
No response
Reproduction URL
https://github.com/ryangittings/11ty-serverless-pagination-issue
Screenshots
No response
The text was updated successfully, but these errors were encountered: