forked from aishakhan0925/womenofjamstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
42 lines (34 loc) · 1.04 KB
/
.eleventy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const Image = require("@11ty/eleventy-img");
async function imageShortcode(src, alt, loading) {
const sizes = "(min-width: 704px) 47vw, (min-width: 1055px) 30vw, 100vw";
let metadata = await Image(src, {
widths: [300, 600, 900],
formats: ["avif", "webp"],
outputDir: "_site/img",
urlPath: "/img",
});
let imageAttributes = {
alt,
sizes,
loading,
decoding: "async",
};
return Image.generateHTML(metadata, imageAttributes);
}
module.exports = function (eleventyConfig) {
eleventyConfig.addNunjucksAsyncShortcode("image", imageShortcode);
eleventyConfig.ignores.add("./src/_sass");
eleventyConfig.ignores.add("./src/_css/main.css.map");
eleventyConfig.addWatchTarget("./src/css");
eleventyConfig.addPassthroughCopy({ "./src/_css": "/css" });
eleventyConfig.addPassthroughCopy({ "./src/_fonts": "/fonts" });
eleventyConfig.addPassthroughCopy({ "./src/_public": "/" });
return {
dir: {
data: "_data",
input: "src",
includes: "_includes",
layouts: "_layouts",
},
};
};