Description
I am new to 11ty and using the Programmatic API version of 11ty, it is working for me when using the defaults, but I want to set some configuration overrides (not in a configuration file, but programmatically).
When I view this documentation...
https://www.11ty.dev/docs/programmatic/
...it mentions that you can set configuration options using a "config" function. However, it gives no clear examples.
I want the ability to configure the includes
and data
directories using this method (as well as some other overrides), but I cannot figure out how to do it. I have tried a number of things.
Here is the example code from the documentation:
const Eleventy = require("@11ty/eleventy");
(async function() {
let elev = new Eleventy( ".", "_site", {
// --quiet
quietMode: true,
// --config
configPath: ".eleventy.js",
config: function(eleventyConfig) {
// Do some custom Configuration API stuff
// Works great with eleventyConfig.addGlobalData
},
});
// Use `write` or `toJSON` or `toNDJSON`
})();
After that example, the documentation states...
(More to come)
Looking in the Eleventy.js
source code, I am wondering if this feature is possibly incomplete?
/* Programmatic API config */
if (options.config && typeof options.config === "function") {
// TODO use return object here?
options.config(this.eleventyConfig.userConfig);
}
In other documentation for the eleventy.config.js
files, there are examples like the following for setting overrides:
module.exports = function(eleventyConfig) {
return {
dir: {
includes: "includes",
data: "data"
},
templateFormats: ["gif", "html", "jpg", "liquid", "md"],
htmlTemplateEngine: "liquid",
markdownTemplateEngine: "liquid"
}
};
I was hoping to be able to just use a simple configuration object with the Programmatic API configuration like the following:
dir: {
includes: "includes",
data: "data"
},
templateFormats: ["gif", "html", "jpg", "liquid", "md"],
htmlTemplateEngine: "liquid",
markdownTemplateEngine: "liquid"
At this point I am wondering if the code is incomplete which is why the documentation is incomplete?
So far I really like this product and I thank you for creating it. I am not currently blocked by this, but really would like to be able to set overrides as the documentation implies as that may be needed for me in the near future.