-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eleventy.js
executable file
·48 lines (41 loc) · 1.34 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 CleanCSS = require("clean-css");
module.exports = function(eleventyConfig) {
// Folders to copy to build dir (See. 1.1)
eleventyConfig.addPassthroughCopy("src/assets/images");
// eleventyConfig.addPassthroughCopy("src/assets/static");
// Minify HTML output
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;
});
// Clean CSS Filter
eleventyConfig.addFilter("cssmin", function(code) {
return new CleanCSS({}).minify(code).styles;
});
// Ordinal date
eleventyConfig.addFilter("ordinal", function(date) {
return date + (date > 0 ? ['th', 'st', 'nd', 'rd'][(date > 3 && date < 21) || date % 10 > 3 ? 0 : date % 10] : '');
});
eleventyConfig.addCollection("sortedEntries", function(collection) {
return collection.getFilteredByTag("entries").reverse();;
});
return {
dir: {
input: "src/",
output: "dist",
includes: "_includes"
},
templateFormats: ["html", "md"],
htmlTemplateEngine: "liquid",
// 1.1 Enable elventy to pass dirs specified above
passthroughFileCopy: true
};
};