-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
61 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const path = require("path"); | ||
|
||
function getGlobalOptions(eleventyDirectories, options) { | ||
let globalOptions = Object.assign({ | ||
packages: { | ||
image: require("../"), | ||
}, | ||
outputDir: path.join(eleventyDirectories.output, options.urlPath || ""), | ||
}, options); | ||
|
||
globalOptions.eleventyDirectories = eleventyDirectories; | ||
|
||
return globalOptions; | ||
} | ||
|
||
module.exports = { | ||
getGlobalOptions, | ||
}; |
2 changes: 1 addition & 1 deletion
2
src/imageAttributesToPosthtmlNode.js → src/image-attrs-to-posthtml-node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const eleventyImage = require("../"); | ||
const eleventyImage = require("../img"); | ||
|
||
const ATTR_PREFIX = "eleventy:"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { getGlobalOptions } = require("./global-options.js"); | ||
|
||
function eleventyWebcOptionsPlugin(eleventyConfig, options = {}) { | ||
let eleventyDirectories; | ||
eleventyConfig.on("eleventy.directories", (dirs) => { | ||
eleventyDirectories = dirs; | ||
}); | ||
|
||
// Notably, global options are not shared automatically with the `eleventyImageTransformPlugin` below. | ||
// Devs can pass in the same object to both if they want! | ||
eleventyConfig.addJavaScriptFunction("__private_eleventyImageConfigurationOptions", () => { | ||
return getGlobalOptions(eleventyDirectories, options); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
eleventyWebcOptionsPlugin, | ||
}; |