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
Serverless templates not rendering correct data and associated build issues #2544
Comments
I am seeing the same issue with Eleventy serverless. The data from the first item in the pagination array is returned regardless of the route. Using 2.0.0-canary.15. |
Same issue exists on 2.0.0-canaray.16 |
OK finally worked it out. Your data has to be an If you use this as your data pagination data structure it will work as expected. {
"post1": {
"name": "post1",
"content": "Content for Post 1"
},
"post2": {
"name": "post2",
"content": "Content for Post 2"
},
"post3": {
"name": "post3",
"content": "Content for Post 3"
}
} |
Improve description of how Dynamic Slugs to Subset Your Pagination works. See: 11ty/eleventy#2544 It wasn't clear (to me) that you have to use an `Object` for your pagination data. Typically a CMS will return an array rather than an object and that produces weird results.
Closing this as it's a documentation issue, not a Eleventy one. |
I'm trying to create a live preview system for a CMS
Consider this data:
And this template:
It builds
/posts/post1/
,/posts/post2/
,/posts/post3/
as expected.The serverless routes on
/preview/posts/post1/
,/preview/posts/post2/
,/preview/posts/post3/
all work, however they all show the data frompost1
. I think this is expected?As I understand it from the documentation I should uncomment
serverless: eleventy.serverless.path.id
which should matchid
to the slug and therefore render the correct content.However when I do that, two things happen:
post1
gets builtpost2
andpost3
do not, no error is given, which was unexpected.Make sure you do
rm -rf _site netlify netlify.toml .netlify && netlify dev
otherwise you can get caught out testing this./preview/posts/
routes render. I get an"error": "json.filter is not a function"
error in the browser andCould not find pagination data, went looking for: post2 (via Error)
type errors in the console when I try to visit those pages.If I add in
addAllPagesToCollections: true
(thanks to @chriskirknielsen in Discord) it solves the first issue. But I can't get the/preview/posts/...
routes to render with the correct data.It happens in
1.0.2
&2.0.0-canary.15
Is this a bug, a couple of bugs? Or am I doing something wrong?
Environment:
1.0.2
&2.0.0-canary.15
Additional context
Repo to reproduce
I looked at the this code (from the 11ty website) the only differences I can see are :
I don't know if either of these are relevant.
The text was updated successfully, but these errors were encountered: