forked from josephdyer/skeleventy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
68 lines (51 loc) · 1.82 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
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 => {
const blogs = collection.getFilteredByTag('blog')
for( let i = 0; i < blogs.length; i++ ) {
const prevPost = blogs[i - 1]
const nextPost = blogs[i + 1]
blogs[i].data["prevPost"] = prevPost
blogs[i].data["nextPost"] = nextPost
}
return blogs.reverse()
})
// Layout aliases
eleventyConfig.addLayoutAlias('default', 'layouts/default.njk')
eleventyConfig.addLayoutAlias('post', 'layouts/post.njk')
// Include our static assets
eleventyConfig.addPassthroughCopy("css")
eleventyConfig.addPassthroughCopy("js")
eleventyConfig.addPassthroughCopy("images")
eleventyConfig.addPassthroughCopy("robots.txt")
return {
templateFormats: ["md", "njk"],
markdownTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
passthroughFileCopy: true,
dir: {
input: 'site',
output: 'dist',
includes: 'includes',
data: 'globals'
}
}
}