-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eleventy.js
54 lines (41 loc) · 1.48 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
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
module.exports = function(config) {
// A useful way to reference the context we are runing eleventy in
let env = process.env.ELEVENTY_ENV;
// Layout aliases can make templates more portable
config.addLayoutAlias('default', 'layouts/base.njk');
// Add some utility filters
config.addFilter("squash", require("./src/utils/filters/squash.js") );
config.addFilter("dateDisplay", require("./src/utils/filters/date.js") );
// add support for syntax highlighting
config.addPlugin(syntaxHighlight);
// minify the html output
config.addTransform("htmlmin", require("./src/utils/minify-html.js"));
// compress and combine js files
config.addFilter("jsmin", function(code) {
const UglifyJS = require("uglify-js");
let minified = UglifyJS.minify(code);
if( minified.error ) {
console.log("UglifyJS error: ", minified.error);
return code;
}
return minified.code;
});
// pass some assets right through
config.addPassthroughCopy("./src/site/images");
config.addPassthroughCopy("./src/site/photos");
// make the seed target act like prod
env = (env=="seed") ? "prod" : env;
return {
dir: {
input: "src/site",
output: "docs",
data: `_data/${env}`
},
dataTemplateEngine: "njk",
templateFormats : ["njk", "md", "11ty.js"],
htmlTemplateEngine : "njk",
markdownTemplateEngine : "njk",
passthroughFileCopy: true
};
};