forked from jeremenichelli/personal-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
66 lines (53 loc) · 1.72 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
55
56
57
58
59
60
61
62
63
64
65
66
const pluginSyntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
const htmlmin = require('html-minifier')
module.exports = function(eleventyConfig) {
// liquid config
eleventyConfig.setLiquidOptions({
dynamicPartials: true
})
// preprocess collections
eleventyConfig.addCollection('blogposts', (collection) => {
return collection
.getFilteredByTag('post')
.reverse()
.slice(0, 8)
})
eleventyConfig.addCollection('archive', (collection) => {
return collection.getFilteredByTag('post').reverse()
})
eleventyConfig.addCollection('all', function(collection) {
return collection.getAll()
})
// shortcodes
eleventyConfig.addShortcode('actionLink', (link) => {
return `<em>Check out this example <a aria-label="launch this code snippet" href=${link} rel="noopener noreferrer">in action</a>.</em>`
})
// add highlighting
eleventyConfig.addPlugin(pluginSyntaxHighlight)
// set layout alias
eleventyConfig.addLayoutAlias('home', 'layouts/home.liquid')
eleventyConfig.addLayoutAlias('default', 'layouts/default.liquid')
// copy assets folder and public files
eleventyConfig.addPassthroughCopy('assets')
eleventyConfig.addPassthroughCopy('robots.txt')
// minify html
eleventyConfig.addTransform('htmlmin', (content, outputPath) => {
if (outputPath.endsWith('.html')) {
const minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
})
return minified
}
return content
})
// do not ignore generated assets
eleventyConfig.setUseGitIgnore(false)
// return base config
return {
input: './',
output: './_site',
passthroughFileCopy: true
}
}