Is your feature request related to a problem? Please describe.
Global data files are very usefull to store the common data that can be used in all pages. But currently only accept json and js formats. This is not convenient for people with no technical skills that only want to edit the content of a website (menu, footer text, cookies banner, etc).
Describe the solution you'd like
I'd like to be able to place yaml files in _data folder in the same way that I can put js and json.
Describe alternatives you've considered
An alternative is a js file that parse other yaml file and export the data, but it's a nuisance :)
@oscarotero You can use yaml, it's just not turned on by default 馃槉
npm i -D js-yaml
.eleventy.js require the module and inside your eleventyConfig tell eleventy to support yaml: const yaml = require("js-yaml");
module.exports = eleventyConfig => {
eleventyConfig.addDataExtension("yaml", contents => yaml.safeLoad(contents));
};
Hope this helps 馃槉
Official docs: https://www.11ty.dev/docs/data-custom/#yaml
@scottishstoater OMG, I don't know why I didn't see this. Thanks for your help!
Maybe, yaml format could be enabled by default because js-yaml is installed anyway (is a dependency of gray-matter, used by eleventy to parse the front-matter of the files), so it does not requires any additional dependency.
Most helpful comment
@scottishstoater OMG, I don't know why I didn't see this. Thanks for your help!
Maybe, yaml format could be enabled by default because js-yaml is installed anyway (is a dependency of gray-matter, used by eleventy to parse the front-matter of the files), so it does not requires any additional dependency.