-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheleventy.config.js
More file actions
62 lines (52 loc) · 1.8 KB
/
eleventy.config.js
File metadata and controls
62 lines (52 loc) · 1.8 KB
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
const htmlmin = require('html-minifier')
const fg = require('fast-glob')
// Run search for images in /gallery and /sponsors
const galleryImages = fg.sync(['**/promo-photos/*', '!**/dist'])
const allImages = fg.sync(['**/photos/*', '!**/dist'])
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
})
// Create collection of gallery images
eleventyConfig.addCollection('photos', function(collection) {
return galleryImages
})
// Create collection of allimages
eleventyConfig.addCollection('allphotos', function(collection) {
return allImages
})
// Layout aliases
eleventyConfig.addLayoutAlias('default', 'layouts/default.njk')
eleventyConfig.addLayoutAlias('video', 'layouts/video.njk')
eleventyConfig.addLayoutAlias('archive', 'layouts/archive.njk')
// Include our static assets
eleventyConfig.addPassthroughCopy('css')
eleventyConfig.addPassthroughCopy('javascript')
eleventyConfig.addPassthroughCopy('images')
eleventyConfig.addPassthroughCopy('webfonts')
return {
templateFormats: ['md', 'njk'],
markdownTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
passthroughFileCopy: true,
dir: {
input: 'site',
output: 'dist',
includes: 'includes',
data: 'globals'
}
}
}