-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
107 lines (90 loc) · 3.06 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const cleancss = require('clean-css')
const moment = require('moment')
const markdownIt = require("markdown-it")
const markdownItAnchor = require("markdown-it-anchor")
const slugify = require("slugify")
moment.locale('en')
module.exports = function(eleventyConfig) {
// minify css filter
eleventyConfig.addFilter('cssmin', function(code) {
return new cleancss({}).minify(code).styles;
})
// date format filters
eleventyConfig.addFilter('dateFormatMonth', date => {
return moment(date).utc().format('MMMM YYYY');
})
eleventyConfig.addFilter('dateFormatYear', date => {
return moment(date).utc().format('YYYY');
})
eleventyConfig.addFilter('dateFormat', date => {
return moment(date).utc().format('LL');
})
// limit filter
eleventyConfig.addFilter('limit', function (arr, limit) {
return arr.slice(0, limit);
})
// inspect objects as JSON
eleventyConfig.addFilter('jsonify', (data) => {
return JSON.stringify(data, null, "\t")
})
// where hash array includes substring
eleventyConfig.addFilter("where_includes", function(arr, key, value) {
return arr.filter(function(x){
return (x[key].join(' ').includes(value))
})
});
// URI encoding
eleventyConfig.addFilter('uri_encode', function(str) {
return encodeURIComponent(str);
});
const markdownItOptions = {
html: true,
}
// Options for the `markdown-it-anchor` library
const markdownItAnchorOptions = {
slugify: (str) => slugify(str, {
lower: true,
strict: true,
remove: /["]/g,
}),
permalink: markdownItAnchor.permalink.linkInsideHeader({
symbol: `#`,
class: 'not-prose header-anchor',
placement: 'after'
})
}
const markdownLib = markdownIt(markdownItOptions).use(
markdownItAnchor,
markdownItAnchorOptions
)
eleventyConfig.setLibrary("md", markdownLib)
// layout aliases
eleventyConfig.addLayoutAlias('base', 'layouts/base.html')
eleventyConfig.addLayoutAlias('exhibit', 'layouts/exhibit.html')
eleventyConfig.addLayoutAlias('history', 'layouts/history.html')
eleventyConfig.addLayoutAlias('item', 'layouts/item.html')
eleventyConfig.addLayoutAlias('page', 'layouts/page.html')
// passthrough copy
eleventyConfig.addPassthroughCopy('site/assets/')
.addPassthroughCopy('site/media/')
.addPassthroughCopy('site/js/')
.addPassthroughCopy({
'site/_data/items.json': 'items.json'
})
.addPassthroughCopy({
'./node_modules/siema/dist/siema.min.js': '/assets/vendor/siema.min.js'
})
.addPassthroughCopy({
'./node_modules/flickity/dist/flickity.pkgd.min.js': '/assets/vendor/flickity.min.js'
})
.addPassthroughCopy({
'./node_modules/flickity/dist/flickity.min.css': '/assets/vendor/flickity.min.css'
})
return {
markdownTemplateEngine: 'liquid',
dir: {
input: 'site',
output: 'dist',
},
}
}