-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.config.js
77 lines (68 loc) · 1.65 KB
/
eleventy.config.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
67
68
69
70
71
72
73
74
75
76
77
"use strict";
const rss = require("@11ty/eleventy-plugin-rss");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const less = require("less");
const htmlmin = require("html-minifier");
const staticAssets = ["htdocs/*.ico", "htdocs/*.txt", "htdocs/media"];
module.exports = function (config) {
// Plugins
config.addPlugin(rss);
config.addPlugin(syntaxHighlight);
// Static assets
for (const asset of staticAssets) {
config.addPassthroughCopy(asset);
}
// Quick and dirty date formatting
config.addNunjucksFilter("format_date", function (value) {
const monthNames = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
];
const date = new Date(value);
const month = monthNames[date.getMonth()];
return `${month} ${date.getDate()}, ${date.getFullYear()}`;
});
// Less templates: https://lesscss.org
config.addExtension("less", {
outputFileExtension: "css",
compile: async (input) => {
return async () => {
const output = await less.render(input, {
paths: ["htdocs/_stylesheets"],
});
return output.css;
};
},
});
// TODO: Minify CSS output
// Minify HTML output
// TODO: Target html specifically (without the path comparison)
config.addTransform("htmlmin", function (content) {
if (this.outputPath && this.outputPath.endsWith(".html")) {
const minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
return minified;
}
return content;
});
return {
dir: {
input: "htdocs",
output: "dist",
},
templateFormats: ["md", "less", "njk"],
};
};