A few more features and cleanup

This commit is contained in:
Zach Leatherman
2023-01-24 08:41:50 -06:00
parent 91c45f84b9
commit 1f49621084
2 changed files with 14 additions and 5 deletions

View File

@@ -11,14 +11,18 @@ module.exports = eleventyConfig => {
// Eleventy Image shortcode
// https://www.11ty.dev/docs/plugins/image/
eleventyConfig.addAsyncShortcode("image", async function imageShortcode(src, alt, sizes) {
eleventyConfig.addAsyncShortcode("image", async function imageShortcode(src, alt, widths, sizes) {
// Full list of formats here: https://www.11ty.dev/docs/plugins/image/#output-formats
// Warning: Avif can be resource-intensive so take care!
let formats = ["avif", "webp", "auto"];
let file = relativeToInputPath(this.page.inputPath, src);
let metadata = await eleventyImage(file, {
widths: ["auto"],
// You can add "avif" or "jpeg" here if youd like!
formats: ["webp", "png"],
widths: widths || ["auto"],
formats,
outputDir: path.join(eleventyConfig.dir.output, "img"), // Advanced usage note: `eleventyConfig.dir` works here because were using addPlugin.
});
// TODO loading=eager and fetchpriority=high
let imageAttributes = {
alt,
sizes,