generated from fephil/jamstack-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
55 lines (43 loc) · 1.17 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
52
53
54
55
const htmlmin = require('html-minifier');
const isProduction = process.env.ELEVENTY_ENV === 'production';
module.exports = function(config) {
// Layout Aliases
config.addLayoutAlias('base', 'layouts/base.njk');
// Transforms
config.addTransform('htmlmin', function(content, outputPath) {
if ( outputPath.endsWith('.html') && isProduction ) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
return minified;
}
return content;
});
// Assets
config.addPassthroughCopy('src/fonts');
config.addPassthroughCopy('src/images');
config.addPassthroughCopy({ 'public': '/' });
// Shortcodes
config.addNunjucksShortcode('test', function(item) {
return `<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium">${item}</span>`;
});
// Filters
// TBA
// Collections
// TBA
// Plugins
// TBA
return {
dir: {
input: 'src',
output: '_site',
data: '_data',
includes: '_includes'
},
templateFormats: ['html', 'njk'],
htmlTemplateEngine: 'njk',
passthroughFileCopy: true
};
};