-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
35 lines (27 loc) · 1.04 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
const CleanCSS = require("clean-css");
var UglifyJS = require("uglify-js");
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("img");
eleventyConfig.addFilter("cssmin", function(code) {
return new CleanCSS({}).minify(code).styles;
});
eleventyConfig.addFilter("jsmin", function(code) {
return UglifyJS.minify(code, {mangle: {
toplevel: true,
}}).code;
});
const toMonth = new Intl.DateTimeFormat('en', { month: 'long' });
eleventyConfig.addFilter("dateymd", function(date) {
return date instanceof Date ?
date.getUTCDate() + ' ' + toMonth.format(date) + ', ' + date.getUTCFullYear() : ''
});
eleventyConfig.addFilter("lowercase", str => str ? str.toLowerCase() : '')
eleventyConfig.addFilter("parsehtmlentities", function( str ){
str = str.replace(/&/g, '&');
console.log( str )
return str.replace(/&#([0-9]{1,3});/gi, function(match, numStr) {
var num = parseInt(numStr, 10); // read num as normal number
return String.fromCharCode(num);
});
})
};