Closed Pezmc closed 1 year ago
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, content
is a special name in the bowels of Eleventy. And just because I always forget all the properties on items in a collection, here's my handy cheat-sheet from a sample project I had locally:
// 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 "";
}
}
};
{
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 https://github.com/11ty/eleventy/issues/1173! Please subscribe over there!
Fixed by https://github.com/11ty/eleventy/pull/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