On my 11ty site (skeleventy-starter) I want to parse hundreds of reviews. These reviews are stored in my data folder in a folder called reviews as individual yaml-files (named like this: "entry-7128372832.yml"). Each yaml file looks like this:
_id: 84494a00-b086-11ea-94d5-7f955bef1b4e
rating: 5
name: Name
review: "review body"
date: "2019-05-12T12:12:31.116Z"
I added the custom data file format to the 11ty config as stated in the documentation:
const yaml = require("js-yaml");
module.exports = (eleventyConfig) => {
// Yaml
eleventyConfig.addDataExtension("yaml", (contents) =>
yaml.safeLoad(contents)
);
};
However, when I try to loop over the review-data in my .njk-files:
{% for review in reviews %}
<p>{{ review.name }}</p>
<p>{{ review.rating }}</p>
<p>{{ review.review }}</p>
{% endfor %}
I neither seem to have access to the data nor get an error in the console. What am I missing here? Any help is appreciated. Thanks!
{% for key, val in subdata %} {{ key }} {% endfor %}
github.com/11ty/eleventy/issues/304#issuecomment-440678396 – Wilden