Skip to content

Commit

Permalink
Make templateConfig available to plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
MadeByMike committed Oct 6, 2020
1 parent 5918bab commit e84d7f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/TemplateConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class TemplateConfig {
} else {
debug("Eleventy local project config file not found, skipping.");
}
await eleventyConfig.applyPlugins();

await eleventyConfig.applyPlugins(localConfig);

let eleventyConfigApiMergingObject = eleventyConfig.getMergingConfigObject();

Expand Down
8 changes: 4 additions & 4 deletions src/UserConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class UserConfig {
this.plugins.push({ plugin, options });
}

async applyPlugins() {
async applyPlugins(rootConfig) {
for (let index = 0; index < this.plugins.length; index++) {
const { plugin, options } = this.plugins[index];
// TODO support function.name in plugin config functions
Expand All @@ -287,15 +287,15 @@ class UserConfig {
if (typeof plugin === "function") {
pluginBench.before();
let configFunction = plugin;
await configFunction(this, options);
await configFunction(this, options, rootConfig);
pluginBench.after();
} else if (plugin && plugin.configFunction) {
pluginBench.before();
if (options && typeof options.init === "function") {
options.init.call(this, plugin.initArguments || {});
options.init.call(this, plugin.initArguments || {}, rootConfig);
}

await plugin.configFunction(this, options);
await plugin.configFunction(this, options, rootConfig);
pluginBench.after();
} else {
throw new UserConfigError(
Expand Down

0 comments on commit e84d7f1

Please sign in to comment.