-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
48 lines (41 loc) · 1.18 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
const htmlmin = require('html-minifier');
const dateFns = require('date-fns');
const lazyImagesPlugin = require('eleventy-plugin-lazyimages');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPlugin(lazyImagesPlugin, {
transformImgPath: (imgPath) => {
if (imgPath.startsWith('http://') || imgPath.startsWith('https://')) {
// Handle remote file
return imgPath;
} else {
return `./src/${imgPath}`;
}
},
});
eleventyConfig.setEjsOptions({
rmWhitespace: true,
context: {
dateFns,
},
});
eleventyConfig.setBrowserSyncConfig({
files: './_site/assets/styles/main.css',
});
eleventyConfig.addTransform('htmlmin', (content, outputPath) => {
if (outputPath.endsWith('.html')) {
const minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
minifyJS: true,
});
return minified;
}
return content;
});
return {
dir: { input: 'src', output: '_site', data: '_data' },
};
};