forked from aelmosalamy/thesoc.club
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
42 lines (34 loc) · 918 Bytes
/
.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
const fs = require('fs')
const htmlmin = require('html-minifier')
module.exports = function (eleventyConfig) {
if (process.env.ELEVENTY_PRODUCTION) {
eleventyConfig.addTransform('htmlmin', htmlminTransform)
}
// Passthrough
eleventyConfig.addPassthroughCopy({ 'src/static': '.' })
// Watch targets
eleventyConfig.addWatchTarget('./src/styles/')
// Filters
// Same initials = same color
eleventyConfig.addFilter('pickone', (array, initials, order) => {
let hash = initials.split('').reduce((acc, val) => acc + val.charCodeAt(0) + order * 2, 0)
return array[hash % array.length]
})
// Shortcodes
return {
dir: {
input: 'src',
},
}
}
function htmlminTransform(content, outputPath) {
if (outputPath.endsWith('.html')) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
})
return minified
}
return content
}