forked from redbrick/atlas
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.js
70 lines (59 loc) · 2.02 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
const path = require('path')
const yaml = require('js-yaml')
const { DateTime } = require('luxon')
const readingTime = require('reading-time')
const tocPlugin = require('eleventy-plugin-toc')
const postcssPlugin = require('eleventy-plugin-postcss')
const eleventyNavigationPlugin = require('@11ty/eleventy-navigation')
const gitBuildPlugin = require('./eleventy/plugins/git-build')
const pagefindPlugin = require('./eleventy/plugins/pagefind')
const navigationRenderPlugin = require('./eleventy/plugins/navigation-render')
const markdown = require('./eleventy/parsers/markdown')
const slugify = require('./eleventy/filters/slugify')
const pkg = require('./package.json')
module.exports = function (eleventyConfig) {
eleventyConfig.setUseGitIgnore(false)
eleventyConfig.addDataExtension('yml, yaml', (contents) =>
yaml.load(contents)
)
eleventyConfig.addPassthroughCopy('import-map.json')
eleventyConfig.addPassthroughCopy(
path.join(
pkg.eleventy.dir.input,
'assets',
'/**/[!_]*.{png,jpg,jpeg,webp,svg,gif,bmp,ico}'
)
)
eleventyConfig.addPlugin(gitBuildPlugin, {
repos: [
{ name: 'blog' },
],
clean: false,
})
eleventyConfig.addPlugin(pagefindPlugin)
eleventyConfig.addPlugin(postcssPlugin)
eleventyConfig.addPlugin(eleventyNavigationPlugin)
eleventyConfig.addPlugin(navigationRenderPlugin)
eleventyConfig.addPlugin(tocPlugin, {
tags: ['h2', 'h3', 'h4'],
wrapperClass: 'menu',
ul: true,
})
eleventyConfig.addFilter('slugify', slugify)
eleventyConfig.addFilter('readable', (date) => {
return DateTime.fromJSDate(date).toLocaleString(
DateTime.DATE_FULL
)
})
eleventyConfig.addFilter('readingTime', (str) => {
return readingTime(str, { wordsPerMinute: 250 }).text
})
eleventyConfig.addWatchTarget('postcss.config.js')
eleventyConfig.addWatchTarget('tailwind.config.js')
eleventyConfig.setLibrary('md', markdown)
eleventyConfig.setNunjucksEnvironmentOptions({
throwOnUndefined: true,
autoescape: false,
})
return pkg.eleventy
}