-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.config.js
84 lines (75 loc) · 2.24 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import markdownIt from 'markdown-it';
import pluginRss from '@11ty/eleventy-plugin-rss';
import lightningCSS from '@11tyrocks/eleventy-plugin-lightningcss';
import embeds from 'eleventy-plugin-embed-everything';
import { eleventyImageTransformPlugin } from '@11ty/eleventy-img';
import { InputPathToUrlTransformPlugin } from "@11ty/eleventy";
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
import { minify } from "terser";
export default async function (eleventyConfig) {
eleventyConfig.addPassthroughCopy('src/_headers');
eleventyConfig.addPassthroughCopy('src/localcopy.xslt');
eleventyConfig.addPassthroughCopy({ 'src/favicon/': '/', });
eleventyConfig.addPassthroughCopy('src/images');
eleventyConfig.addPassthroughCopy('src/.well-known/');
const mdOptions = {
html: true,
linkify: true,
typographer: true,
};
eleventyConfig.setLibrary('md', markdownIt(mdOptions));
eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(InputPathToUrlTransformPlugin);
eleventyConfig.addPlugin(lightningCSS);
eleventyConfig.addPlugin(embeds, {
use: ['youtube', 'soundcloud'],
youtube: {
options: {
lite: {
responsive: true
}
},
},
});
eleventyConfig.addNunjucksAsyncFilter(
'jsmin',
async function (code, callback) {
if (process.env.ELEVENTY_ENV === 'production') {
try {
const minified = await minify(code);
callback(null, minified.code);
} catch (err) {
console.error('Terser error: ', err);
// Fail gracefully.
callback(null, code);
}
}
callback(null, code);
}
);
eleventyConfig.addPlugin(
eleventyImageTransformPlugin,
{
extensions: 'html',
formats: ['webp'],
widths: [600, 1200, 1800, 2400, 'auto'],
defaultAttributes: {
sizes: '(min-width: 64em) 50vw, 100vw',
loading: 'lazy',
decoding: 'async',
},
},
);
eleventyConfig.addFilter('daysPassed', (value) => {
return Math.ceil(
(new Date(value) - new Date((new Date(value)).getFullYear(), 0, 1)) /
(86400000),
);
});
return {
dir: {
input: 'src',
},
};
}