-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eleventy.js
51 lines (45 loc) · 1.71 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
43
44
45
46
47
48
49
50
51
import { eleventyImageTransformPlugin } from '@11ty/eleventy-img';
import { toISOString, toAbsoluteUrl } from "./lib/filters.js";
import { dir } from './lib/constants.js';
import faviconShortcode from './lib/shortcodes/favicon.js';
// Template language for the site: https://www.11ty.dev/docs/languages/liquid/
const TEMPLATE_ENGINE = 'liquid';
/**
* @type {(eleventyConfig: import('@11ty/eleventy/src/UserConfig')) => ReturnType<import('@11ty/eleventy/src/defaultConfig')>}
*/
export default (eleventyConfig) => {
// Watch targets
eleventyConfig.addWatchTarget(`${dir.input}/assets/styles`);
// Plugins
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
// which file extensions to process
extensions: 'html',
// optional, output image formats
formats: ['jpg', 'webp'],
// optional, output image widths
widths: ['auto', 400, 800],
// optional, attributes assigned on <img> override these values.
defaultAttributes: {
loading: 'lazy',
sizes: '100vw',
decoding: 'async',
},
});
// Custom shortcodes
eleventyConfig.addShortcode('favicon', faviconShortcode);
// Custom filters
eleventyConfig.addFilter('toAbsoluteUrl', toAbsoluteUrl);
eleventyConfig.addFilter('toIsoString', toISOString);
eleventyConfig.addFilter('toJson', JSON.stringify);
eleventyConfig.addFilter('fromJson', JSON.parse);
eleventyConfig.addFilter('keys', Object.keys);
eleventyConfig.addFilter('values', Object.values);
eleventyConfig.addFilter('entries', Object.entries);
return {
dir,
dataTemplateEngine: TEMPLATE_ENGINE,
markdownTemplateEngine: TEMPLATE_ENGINE,
htmlTemplateEngine: TEMPLATE_ENGINE,
templateFormats: ['html', 'md', TEMPLATE_ENGINE],
};
};