This repository has been archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
58 lines (47 loc) · 1.66 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
const fs = require('fs')
const { DateTime } = require('luxon')
const pluginRss = require('@11ty/eleventy-plugin-rss')
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
const markdownIt = require('markdown-it')
const markdownItImageLazyLoading = require('markdown-it-image-lazy-loading')
const input = 'src'
const output = 'dist'
module.exports = function(eleventyConfig) {
eleventyConfig.addLayoutAlias('post', '_layouts/post')
eleventyConfig.addPassthroughCopy({ [`${input}/_static`]: '.' })
eleventyConfig.addFilter('readableDate', dateObj =>
DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('LLL dd, yyyy'))
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
eleventyConfig.addFilter('htmlDateString', (dateObj) =>
DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd'))
eleventyConfig.addPairedShortcode('ifContentWithCode', function(innerTemplate, content) {
return content.includes('</code>') ? innerTemplate : ''
})
eleventyConfig.setBrowserSyncConfig({
callbacks: {
ready: function(_err, browserSync) {
const content_404 = fs.readFileSync(`${output}/404.html`)
browserSync.addMiddleware('*', (_req, res) => {
res.write(content_404)
res.end()
})
},
},
ui: false,
ghostMode: false
})
eleventyConfig.addPlugin(pluginRss)
eleventyConfig.addPlugin(syntaxHighlight)
const markdownLibrary = markdownIt({
html: true,
breaks: true,
linkify: true,
}).use(markdownItImageLazyLoading)
eleventyConfig.setLibrary('md', markdownLibrary)
return {
dir: {
input,
output
}
}
}