-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
If folder named _data/content exists 11ty 2 fails to build #2824
Comments
I can verify that renaming the directory to something other than "content" works fine. Leads me to assume that "content" is a reserved word of some sort in eleventy. |
Yeah, // index.11tydata.js
const { inspect } = require("node:util");
module.exports = {
eleventyComputed: {
debug(data) {
const p = data.collections.all.at(0);
if (p) console.log(inspect(p, {sorted: true, depth: 0}));
return "";
}
}
}; OUTPUT{
content: [Getter],
data: [Object],
date: 2022-06-14T00:00:00.000Z,
filePathStem: '/news/2022-06-14/index',
fileSlug: '2022-06-14',
inputPath: './src/news/2022-06-14/index.md',
outputPath: 'www/news/2022-06-14/index.html',
page: [Object],
template: [Template],
templateContent: [Getter/Setter],
url: '/news/2022-06-14/'
} |
It would be nice to have Eleventy detect situations like that and give a clear error message. |
This is filed at #1173! Please subscribe over there! |
Fixed by #3251 Shipping with 3.0.0-alpha.7 |
Operating system
macOS Ventura 13.2.1
Eleventy
2.0.0
Describe the bug
If any data file exists under the directory name content e.g.
_data/content/my-file.json
11ty fails to build, full error below. A minimum reproduction to show the error can be found at: https://github.com/Pezmc/11ty-data-content-issueMy understanding from debugging so far is that the TemplateLayout parsing tries to set
data.content
but that is declared with only a getter (i.e. read only). It seems likely that the_data
dir having a directory namedcontent
, which is exposed on the page object, is overlapping with the setting of the page content.This was not an issue with 11ty <2.0
Error stack trace:
Reproduction steps
_data/content/any-name.json
npx @11ty/eleventy
Expected behavior
Short term fix: Rename the
content
folder to side-step the issue e.g._data/my-content
Expected behaviour from 11ty: Either throw a clear error if a folder named content (and perhaps other protected internal names) is present; or guard against this happening and allow the _data tags to overlap with the internal props on the page object.
Reproduction URL
https://github.com/Pezmc/11ty-data-content-issue
Screenshots
No response
The text was updated successfully, but these errors were encountered: