You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Eleventy's built-in Render plugin breaks a function I defined in a webc:setup block, but only on the first build of the site. The error message doesn't even make sense. What could be the cause of this?
I have a component with a function to show a number of posts based on a dynamic attribute: _components/collections-post.webc:
<scriptwebc:setup>// Return the last n posts in reverse orderconstrecent_posts=(n)=>{constposts=collections.postconstsorted=posts.sort((a,b)=>a.page.date-b.page.date)consttop=sorted.slice(0-n)returntop.reverse()}</script><divclass="h-feed"><articleclass="collections-post h-entry" webc:for="post of recent_posts(numposts)"><template@html="post.content" webc:nokeep></template></article></div>
I use this on WebC pages like home.webc and blog.webc...
This worked when I first added renderTemplate and the <rsvp> component but, when I remove the output directory to rebuilt the entire site I get an error that doesn't make any sense...
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble rendering webc template ./_input/blog.webc (via TemplateContentRenderError)
[11ty] 2. Check the dynamic attribute: `webc:for="recent_posts(numposts)"`.
[11ty] Original error message: Cannot read properties of undefined (reading 'post') (via Error)
[11ty]
[11ty] Original error stack trace: Error: Check the dynamic attribute: `webc:for="recent_posts(numposts)"`.
[11ty] Original error message: Cannot read properties of undefined (reading 'post')
It's saying that post is undefined, but that's in a webc:for block and it shouldn't even get to that line if post is undefined.
I checked the dynamic attribute (numposts) and it's set in any case. If I comment out the for loop and just show the number it'll build the site and show the number:
<divclass="h-feed"><div@text="numposts"></div><divwebc:ignore><articleclass="collections-post h-entry" webc:for="post of recent_posts(numposts)"><template@html="post.content" webc:nokeep></template></article></div></div>
Reproduction steps
Define a function in a webc:setup block that does something with a collection
Use {% renderTemplate "webc" %} in any Liquid / Markdown page.
Remove the output directory.
Rebuild the site: npx @11ty/eleventy
See an error
Expected behavior
It builds the site
Reproduction URL
No response
Screenshots
No response
The text was updated successfully, but these errors were encountered:
Operating system
Ubuntu 22.04
Eleventy
2.0.1
Describe the bug
Using Eleventy's built-in Render plugin breaks a function I defined in a
webc:setup
block, but only on the first build of the site. The error message doesn't even make sense. What could be the cause of this?I have a component with a function to show a number of posts based on a dynamic attribute:
_components/collections-post.webc
:I use this on WebC pages like
home.webc
andblog.webc
...I started using
renderTemplate
so that I could use a WebC component in my Markdown posts.This worked when I first added
renderTemplate
and the<rsvp>
component but, when I remove the output directory to rebuilt the entire site I get an error that doesn't make any sense...It's saying that
post
is undefined, but that's in awebc:for
block and it shouldn't even get to that line ifpost
is undefined.I checked the dynamic attribute (
numposts
) and it's set in any case. If I comment out the for loop and just show the number it'll build the site and show the number:Reproduction steps
webc:setup
block that does something with a collection{% renderTemplate "webc" %}
in any Liquid / Markdown page.npx @11ty/eleventy
Expected behavior
It builds the site
Reproduction URL
No response
Screenshots
No response
The text was updated successfully, but these errors were encountered: