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
Following the technique in this comment, I've created a shortcode that loads a partial within a post, and injects it with the rendering context. Simplified example:
post.md
---title: Post---
Text ...
{% promo "newsletter" %}
More text ...
.eleventy.js
importaddPromofrom'./lib/promo.js';exportdefaultfunction(eleventyConfig){/* Some collection */eleventyConfig.addCollection('stuff',function(collection){returncollection.getFilteredByTag('stuff');});/* Add helper */addPromo(eleventyConfig);return{markdownTemplateEngine: "njk",};};
This works perfectly in Eleventy 2.0.0, but in Eleventy 3.0.0-alpha.17, it fails with an unhelpful error:
Problem writing Eleventy templates: (more in DEBUG output)
1. Having trouble rendering njk template ./post.md (via TemplateContentRenderError)
2. (./post.md)
EleventyShortcodeError: Error with Nunjucks shortcode `promo` (via Template render error)
3. Error in your Eleventy config file '.eleventy.js'. (via Template render error)
Original error stack trace: EleventyConfigError: Error in your Eleventy config file '.eleventy.js'.
at TemplateConfig.requireLocalConfigFile (/node_modules/@11ty/eleventy/src/TemplateConfig.js:376:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TemplateConfig.mergeConfig (/node_modules/@11ty/eleventy/src/TemplateConfig.js:404:41)
at async TemplateConfig.init (/node_modules/@11ty/eleventy/src/TemplateConfig.js:199:17)
at async RenderManager.init (/node_modules/@11ty/eleventy/src/Plugins/RenderPlugin.js:394:3)
at async RenderManager.compile (/node_modules/@11ty/eleventy/src/Plugins/RenderPlugin.js:424:3)
at async Object.<anonymous> (/lib/promo.js:14:14)
Changing ...this.ctx.getAll() to just ...this.ctx seems to result in the object I want; but via a try catch I can surface this additional error that seems to happen as many times as the shortcode is used in the project:
EleventyConfigError: Error in your Eleventy config file '.eleventy.js'.
at TemplateConfig.requireLocalConfigFile (/node_modules/@11ty/eleventy/src/TemplateConfig.js:376:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TemplateConfig.mergeConfig (/node_modules/@11ty/eleventy/src/TemplateConfig.js:404:41)
at async TemplateConfig.init (/node_modules/@11ty/eleventy/src/TemplateConfig.js:199:17)
at async RenderManager.init (/node_modules/@11ty/eleventy/src/Plugins/RenderPlugin.js:394:3)
at async RenderManager.compile (/node_modules/@11ty/eleventy/src/Plugins/RenderPlugin.js:424:3)
at async Object.<anonymous> (/lib/promo.js:15:15) {
originalError: UserConfigError: config.addCollection(stuff) already exists. Try a different name for your collection.
at UserConfig.addCollection (/node_modules/@11ty/eleventy/src/UserConfig.js:1051:10)
at default (/.eleventy.js:110:17)
at TemplateConfig.requireLocalConfigFile (/node_modules/@11ty/eleventy/src/TemplateConfig.js:368:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TemplateConfig.mergeConfig (/node_modules/@11ty/eleventy/src/TemplateConfig.js:404:41)
at async TemplateConfig.init (/node_modules/@11ty/eleventy/src/TemplateConfig.js:199:17)
at async RenderManager.init (/node_modules/@11ty/eleventy/src/Plugins/RenderPlugin.js:394:3)
at async RenderManager.compile (/node_modules/@11ty/eleventy/src/Plugins/RenderPlugin.js:424:3)
at async Object.<anonymous> (/lib/promo.js:15:15)
}
It appears to (somehow) try to re-register the first collection listed in .eleventy.js, but I'm not entirely sure how or why it's doing that.
Reproduction steps
Create a project as per the above example files
Build it with Eleventy 3.0.0-alpha.17
Build will fail
Expected behavior
Build should not fail; or at least a more useful error should be returned.
Reproduction URL
No response
Screenshots
No response
The text was updated successfully, but these errors were encountered:
Operating system
macOS Sonoma 14.4.1
Eleventy
3.0.0-alpha.17
Describe the bug
Following the technique in this comment, I've created a shortcode that loads a partial within a post, and injects it with the rendering context. Simplified example:
post.md
.eleventy.js
lib/promo.js
_includes/promo.njk
This works perfectly in Eleventy 2.0.0, but in Eleventy 3.0.0-alpha.17, it fails with an unhelpful error:
Changing
...this.ctx.getAll()
to just...this.ctx
seems to result in the object I want; but via atry catch
I can surface this additional error that seems to happen as many times as the shortcode is used in the project:It appears to (somehow) try to re-register the first collection listed in
.eleventy.js
, but I'm not entirely sure how or why it's doing that.Reproduction steps
Expected behavior
Build should not fail; or at least a more useful error should be returned.
Reproduction URL
No response
Screenshots
No response
The text was updated successfully, but these errors were encountered: