-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
56 lines (41 loc) · 1.4 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
48
49
50
51
52
53
54
55
56
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img";
import fs from "node:fs/promises";
import path from "node:path";
import CleanCSS from "clean-css";
import pluginRss from "@11ty/eleventy-plugin-rss";
const __dirname = import.meta.dirname;
export default async function(eleventyConfig) {
eleventyConfig.setInputDirectory("src");
eleventyConfig.addLayoutAlias("post", "layouts/post.njk");
eleventyConfig.addPassthroughCopy("static");
eleventyConfig.addShortcode("minifiedcss", async function (code) {
return `<style>
${await fs
.readFile(path.resolve(__dirname, "./static/index.css"))
.then((data) => new CleanCSS().minify(data).styles)}
</style>`;
});
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
// which file extensions to process
extensions: "html",
// Add any other Image utility options here:
// optional, output image formats
formats: ["webp", "jpeg"],
// formats: ["auto"],
// optional, output image widths
widths: ["auto", 400, 800, 1600, 2200],
useCache: true,
// optional, attributes assigned on <img> override these values.
defaultAttributes: {
loading: "lazy",
decoding: "async",
},
});
eleventyConfig.addFilter("prettyJson", (value = '') => {
// Remove the altText from the JSON
delete value.altText;
const json = JSON.stringify(value, null, 2);
return json;
});
eleventyConfig.addPlugin(pluginRss);
};