-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheleventy.config.js
47 lines (39 loc) · 1.17 KB
/
eleventy.config.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
43
44
45
46
47
const svgContents = require("eleventy-plugin-svg-contents");
const Image = require("@11ty/eleventy-img");
const pluginBookshop = require("@bookshop/eleventy-bookshop");
const yaml = require("js-yaml");
module.exports = function(eleventyConfig) {
eleventyConfig.addWatchTarget("./src/assets/style.css");
eleventyConfig.addWatchTarget("component-library/");
eleventyConfig.addPassthroughCopy("./src/assets/");
eleventyConfig.addPlugin(svgContents);
eleventyConfig.addShortcode("image", async function (src, alt, widths, sizes) {
if (src === undefined || src === null) {
return "";
}
let metadata = await Image(`src/${src}`, {
widths: [widths],
formats: ["avif", "webp", "svg", "jpeg"],
outputDir: "./_site/optimized/",
urlPath: "/optimized/",
});
let imageAttributes = {
alt,
sizes,
loading: "lazy",
decoding: "async",
};
return Image.generateHTML(metadata, imageAttributes);
});
eleventyConfig.addDataExtension("yml", (contents) => yaml.load(contents));
eleventyConfig.addPlugin(pluginBookshop({
bookshopLocations: ["component-library"],
pathPrefix: '',
}));
return {
dir: {
input: "src",
output: "_site"
}
}
};