-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.config.js
52 lines (47 loc) · 1.46 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
const { groupBy } = require('lodash')
const markdownIt = require('markdown-it')
const markdownItLinkAttributes = require('markdown-it-link-attributes')
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy('./content/assets')
eleventyConfig.addPassthroughCopy('./content/ads.txt')
eleventyConfig.addPassthroughCopy('./content/favicon.ico')
eleventyConfig.addPassthroughCopy('./content/about-zhiyuan/CV-Zhiyuan_Zheng.pdf')
eleventyConfig.addPlugin(require('./eleventy.config.avatar.js'))
eleventyConfig.addPlugin(require('./eleventy.config.images.js'))
eleventyConfig.addPlugin(require('./eleventy.config.videos.js'))
eleventyConfig.addFilter('group_by_year', array => {
if (!Array.isArray(array) || array.length === 0) {
return []
}
const groups = groupBy(
array.filter(d => d.data.year),
'data.year'
)
return Object.keys(groups)
.map(group => ({
year: group,
data: groups[group].sort((a, b) => a.data.priority - b.data.priority)
}))
.reverse()
})
eleventyConfig.setLibrary(
'md',
markdownIt({ html: true }).use(markdownItLinkAttributes, {
matcher: href => {
return !href.startsWith('/')
},
attrs: {
target: '_blank',
rel: 'noopener noreferrer'
}
})
)
return {
templateFormats: ['md', 'liquid'],
dir: {
input: 'content',
includes: '../_includes',
layouts: '../_layouts'
}
}
}