-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.config.js
53 lines (43 loc) · 1.53 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
const htmlmin = require("html-minifier")
module.exports = eleventyConfig => {
// Add a readable date formatter filter to Nunjucks
eleventyConfig.addFilter("dateDisplay", require("./filters/dates.js"))
// Add a HTML timestamp formatter filter to Nunjucks
eleventyConfig.addFilter("htmlDateDisplay", require("./filters/timestamp.js"))
// Minify our HTML
eleventyConfig.addTransform("htmlmin", (content, outputPath) => {
if( outputPath.endsWith(".html") ) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
return minified;
}
return content;
})
// Collections
eleventyConfig.addCollection('blog', collection => {
return collection.getFilteredByTag('blog').reverse()
})
// Layout aliases
eleventyConfig.addLayoutAlias('default', 'layouts/default.njk')
eleventyConfig.addLayoutAlias('post', 'layouts/post.njk')
// Include our static assets
eleventyConfig.addPassthroughCopy("css")
eleventyConfig.addPassthroughCopy("javascript")
eleventyConfig.addPassthroughCopy("images")
return {
templateFormats: ["md", "njk"],
markdownTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
passthroughFileCopy: true,
dir: {
input: 'site',
output: 'dist',
includes: 'includes',
data: 'globals'
},
pathPrefix: '/'
}
}