-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.eleventy.js
98 lines (82 loc) · 2.93 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
const util = require('util')
const { DateTime } = require('luxon')
const typogr = require('typogr')
const pluginTOC = require('eleventy-plugin-toc')
const markdownIt = require("markdown-it");
const markdownItAnchor = require("markdown-it-anchor")
const pluginRss = require("@11ty/eleventy-plugin-rss")
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight")
module.exports = function(eleventyConfig) {
// Pass Through Copy
eleventyConfig.addPassthroughCopy('src/images')
eleventyConfig.addPassthroughCopy('src/fonts')
eleventyConfig.addPassthroughCopy('src/data')
eleventyConfig.addPassthroughCopy('src/scripts/service-worker.js')
eleventyConfig.addPassthroughCopy('src/admin')
eleventyConfig.addPassthroughCopy('src/_redirects')
// Filters
eleventyConfig.addFilter('dumpCircular', function(val) {
return util.inspect(val, {showHidden: true, depth: 2, colors: false})
})
eleventyConfig.addFilter('dateReadable', function(val) {
return DateTime.fromJSDate(val, {zone: 'utc'}).toFormat('MMM dd, yyyy')
})
eleventyConfig.addFilter('dateIso', function(val) {
return DateTime.fromJSDate(val, {zone: 'utc'}).toISO()
})
eleventyConfig.addFilter('dateRSS', function(val) {
return DateTime.fromJSDate(val, {zone: 'utc'}).toHTTP()
})
eleventyConfig.addFilter('dateHtmlString', function(val) {
return DateTime.fromJSDate(val, {zone: 'utc'}).toFormat('yyyy-LL-dd')
})
eleventyConfig.addFilter('typogr', function(val) {
return typogr.typogrify(val)
})
eleventyConfig.addFilter('smartypants', function(val) {
return typogr(val).chain().smartypants().value()
})
// Collections
eleventyConfig.addCollection("postsReverse", function(collection) {
return collection.getAllSorted().reverse();
})
eleventyConfig.addCollection("curated", function(collection) {
const curated = {}
curated.work = collection.getFilteredByGlob(['src/work/*.md'])
curated.articles = collection.getFilteredByGlob(['src/articles/*.md'])
return curated
})
// Plugins
eleventyConfig.addPlugin(pluginTOC)
eleventyConfig.addPlugin(pluginRss)
eleventyConfig.addPlugin(syntaxHighlight)
// Libaries
eleventyConfig.setLibrary('md', markdownIt({
html: true,
breaks: true,
linkify: true,
typographer: true
})
.use(markdownItAnchor, {
permalink: true,
permalinkClass: 'direct-link',
permalinkSymbol: ''
})
)
// Layout Alias
eleventyConfig.addLayoutAlias('list', 'layouts/list.njk')
eleventyConfig.addLayoutAlias('post.njk', 'layouts/post.njk')
// Shortcodes
eleventyConfig.addShortcode('figure', function(url, alt, caption, classes) {
return `<figure class="${classes}">
<img src="${url}" alt="${alt}"/>
<figcaption>${caption}</figcaption>
</figure>`
})
return {
dir: { input: 'src', output: 'dist', data: '_data' },
passthroughFileCopy: true,
templateFormats: ['njk', 'md', 'css', 'html', 'yml'],
htmlTemplateEngine: 'njk'
}
}