-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
44 lines (35 loc) · 1.24 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
const filters = require('./utils/filters.js')
const htmlMinTransform = require('./utils/transforms/html-min.js')
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
const site = require('./src/_data/site.json')
module.exports = function (config) {
// Passthrough copy
config.addPassthroughCopy('src/CNAME')
config.addPassthroughCopy('src/images')
config.addPassthroughCopy('src/js')
config.addPassthroughCopy('src/projects')
// Filters
Object.keys(filters).forEach((filterName) => {
config.addFilter(filterName, filters[filterName])
})
// Transforms
// config.addTransform('htmlmin', htmlMinTransform)
// Plugins
config.addPlugin(syntaxHighlight)
// Collections
const livePosts = (post) => post.date <= new Date() && !post.data.draft
config.addCollection('posts', (collection) => {
return [
...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts),
].reverse()
})
config.addCollection('postFeed', (collection) => {
return [...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts)]
.reverse()
.slice(0, site.maxPostsPerPage)
})
return {
pathPrefix: process.env.WEB_PATH_PREFIX || '',
dir: { input: 'src', output: '_site' },
}
}