In the documentation (https://www.11ty.dev/docs/data-global-custom/) for Eleventy it states that you can use the following as one option for adding custom global data:
// .eleventy.js
module.exports = function(eleventyConfig) {
eleventyConfig.addGlobalData("myFunctionPromise", () => {
return new Promise((resolve) => {
setTimeout(resolve, 100, "foo");
})
});
};
When attempting to use this within the .eleventy.js
project configuration file it fails with:
> eleventyConfig.addGlobalData is not a function
However, custom collections can be defined on eleventyConfig
using eleventyConfig.addCollection
without any issues.
What is the issue here?
The addGlobalData
configuration is coming soon in Eleventy v1.0.0 (written in the header next to the title of the page). This version has not been released yet.
If you want to use the canary version of Eleventy v1.0.0, you can install it with:
npm install @11ty/eleventy@canary
Keep in mind that this is a canary version that may have bugs or other issues. You can track progress towards 1.0 via the GitHub milestone. In the meantime, you can use global data files to add global data to your site.