Open paulrobertlloyd opened 1 year ago
Yeah, I believe this was an intentional defensive design decision. I wonder if there is some middle ground we can get to here, I’d be most worried about .js
data files but it seems like .json
is risky too.
Commit: https://github.com/11ty/eleventy/commit/d0ab03811e87735ac3d79f03bdbff493358f13df
Specifically from the original request (#1699) was targeted towards index.*
data files and my worry was that index.js
and index.json
would match files that were not supposed to be data files.
(Consider what I said me to be thinking out loud)
That said, it does seem like this should work (but does not):
eleventyConfig.setDataFileBaseName("_data");
eleventyConfig.setDataFileSuffixes([""]);
I would like to configure this so that _data.json
, _data.js
, etc. work as directory data files but, at the same time, template data files still require the .data
file extension. For example, lorem-ipsum.data.js
would work as a data file for the lorem-ipsum.md
template but lorem-ipsum.js
wouldn’t be a data file but a template.
Operating system
macOS Ventura 13.2.1
Eleventy
2.0.0
Describe the bug
I’m trying to use a custom base file name so that I can use the following directory data files[^1]:
However, the custom base file name only appears to work if the
.11tydata
suffix is provided:Using default config (data files share same name as directory):
[directory_name].11tydata.json
[directory_name].json
Using
eleventyConfig.setDataFileBaseName("_data")
:_data.11tydata.json
_data.json
Setting
eleventyConfig.setDataFileSuffixes([""])
has no effect, either.[^1]: I actually want to use a custom data format, YAML, so that I can use
_data.yaml
files, but given the natively supported JSON format doesn’t work as expected either, using this as my example.