-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
56 lines (45 loc) · 1.29 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
const sass = require("sass")
const htmlmin = require("html-minifier")
const { execSync } = require("child_process")
/** @param {import('@11ty/eleventy').UserConfig} config */
module.exports = function (config) {
config.addPassthroughCopy({ "src/public": "." })
config.addTemplateFormats("scss")
config.addExtension("scss", {
outputFileExtension: "css",
compile: async function (inputContent) {
let result = sass.compileString(inputContent)
return async (data) => {
return result.css
}
},
})
config.addTransform("htmlmin", function (content) {
if (this.page.outputPath && this.page.outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
})
return minified
}
return content
})
config.addFilter("scss", (data) => {
return sass.compileString(data).css
})
config.addShortcode("ghlink", (repo) => {
return `[${repo}](https://github.com/cf12/${repo})`
})
config.addShortcode("gitHash", () => {
return execSync("git rev-parse --short HEAD").toString().trim()
})
return {
dir: {
input: "src",
},
markdownTemplateEngine: "njk",
}
}