-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.eleventy.js
66 lines (57 loc) · 1.61 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
56
57
58
59
60
61
62
63
64
65
66
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
const rss = require('@11ty/eleventy-plugin-rss');
const filters = require('./src/_11ty/filters.js');
const htmlmin = require('html-minifier');
module.exports = function (eleventyConfig) {
// Plugins
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPlugin(rss);
// Filters
Object.keys(filters).forEach((filterName) => {
eleventyConfig.addFilter(filterName, filters[filterName]);
});
// Transforms
eleventyConfig.addTransform('htmlmin', function (content, outputPath) {
if (outputPath.endsWith('.html')) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
return minified;
}
return content;
});
// Collections
eleventyConfig.addCollection('entriesSorted', function (collection) {
return collection.getFilteredByTag('entry').sort(function (a, b) {
if (a.data.title < b.data.title) {
return -1;
}
if (a.data.title > b.data.title) {
return 1;
}
return 0;
});
});
eleventyConfig.addPassthroughCopy({
'./src/assets/favicon': '/',
'./src/images': '/images',
'./src/assets': '/assets',
'./src/netlify.toml': '/netlify.toml',
});
return {
templateFormats: ['md', 'njk'],
pathPrefix: '/',
markdownTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
passthroughFileCopy: true,
dir: {
input: 'src',
includes: '_includes',
data: '_data',
output: '_site',
},
};
};