-
Notifications
You must be signed in to change notification settings - Fork 2
/
.eleventy.js
45 lines (38 loc) · 1.06 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
const beautify = require("simply-beautiful");
module.exports = function (eleventyConfig) {
// Filters
eleventyConfig.addNunjucksFilter("absoluteUrl", (href, base) => {
let { URL } = require("url");
return new URL(href, base).toString();
});
eleventyConfig.addNunjucksFilter("dateFormatISO", (value) => {
const date = new Date(value);
return date.toISOString().slice(0, 10);
});
// Layouts
eleventyConfig.addLayoutAlias("base", "_base.njk");
// Transforms
eleventyConfig.addTransform("beautify", function (content, outputPath) {
if (outputPath.endsWith(".html")) {
let beautifyHTML = beautify.html(content, {
indent_size: 2,
indent_scripts: "keep",
});
return beautifyHTML;
}
return content;
});
return {
dir: {
input: "src",
data: "data",
includes: "views/includes",
layouts: "views/layouts",
output: "public",
},
templateFormats: ["njk", "md"],
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk",
passthroughFileCopy: false,
};
};