generated from maxboeck/resume
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
88 lines (73 loc) · 2.17 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const pluginRss = require('@11ty/eleventy-plugin-rss')
const markdownIt = require('markdown-it')
const filters = require('./utils/filters.js')
const transforms = require('./utils/transforms.js')
const shortcodes = require('./utils/shortcodes.js')
const iconsprite = require('./utils/iconsprite.js')
module.exports = function (config) {
// Plugins
config.addPlugin(pluginRss)
// Filters
Object.keys(filters).forEach(filterName => {
config.addFilter(filterName, filters[filterName])
})
// Transforms
Object.keys(transforms).forEach(transformName => {
config.addTransform(transformName, transforms[transformName])
})
// Shortcodes
Object.keys(shortcodes).forEach(shortcodeName => {
config.addShortcode(shortcodeName, shortcodes[shortcodeName])
})
// Icon Sprite
config.addNunjucksAsyncShortcode('iconsprite', iconsprite)
// Asset Watch Targets
config.addWatchTarget('./src/assets')
// Markdown
config.setLibrary(
'md',
markdownIt({
html: true,
breaks: true,
linkify: true,
typographer: true,
}),
)
// Layouts
config.addLayoutAlias('base', 'base.njk')
config.addLayoutAlias('resume', 'resume.njk')
// Collections
const collections = ['work', 'education']
collections.forEach(name => {
config.addCollection(name, function (collection) {
const folderRegex = new RegExp(`\/${name}\/`)
const inEntryFolder = item => item.inputPath.match(folderRegex) !== null
const byStartDate = (a, b) => {
if (a.data.start && b.data.start) {
return a.data.start - b.data.start
}
return 0
}
return collection.getAllSorted().filter(inEntryFolder).sort(byStartDate)
})
})
// Pass-through files
config.addPassthroughCopy('src/robots.txt')
config.addPassthroughCopy('src/assets/images')
config.addPassthroughCopy('src/assets/fonts')
// Deep-Merge
config.setDataDeepMerge(true)
// Base Config
return {
dir: {
input: 'src',
output: 'dist',
includes: 'includes',
layouts: 'layouts',
data: 'data',
},
templateFormats: ['njk', 'md', '11ty.js'],
htmlTemplateEngine: 'njk',
markdownTemplateEngine: 'njk',
}
}