generated from antaresphdev/eleventy-template
-
Notifications
You must be signed in to change notification settings - Fork 6
/
.eleventy.js
58 lines (49 loc) · 1.83 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 markdown = require('markdown-it')
const mdAnchor = require('markdown-it-anchor')
const slug = require('slug')
const config = require('./src/config/index');
const { passthrough, collections, filters, plugins, watchtargets, transforms } = config
module.exports = function (eleventy) {
Object.keys(passthrough).forEach(key => eleventy.addPassthroughCopy(passthrough[key]()))
Object.keys(collections).forEach(key => eleventy.addCollection(key, collections[key]))
Object.keys(filters).forEach(key => eleventy.addFilter(key, filters[key]))
Object.keys(watchtargets).forEach(key => eleventy.addWatchTarget(watchtargets[key]()))
Object.keys(transforms).forEach(key => eleventy.addTransform(key, transforms[key]))
let envIsProduction = process.env.ELEVENTY_ENV === 'production'
Object.keys(plugins).forEach(key => {
let { options, isProduction, plugin } = plugins[key]()
let shouldAddPlugin = false
if (isProduction) {
shouldAddPlugin = envIsProduction
} else {
shouldAddPlugin = true
}
if (shouldAddPlugin) {
if (options) {
eleventy.addPlugin(plugin, options)
} else {
eleventy.addPlugin(plugin)
}
}
})
eleventy.addGlobalData('generated', () => new Date().toISOString())
eleventy.setBrowserSyncConfig({ open: true })
const mdLib = markdown({ html: true, linkify: true, typographer: true })
mdLib.use(mdAnchor)
mdLib.use(require('markdown-it-deflist'))
mdLib.use(require('markdown-it-abbr'))
mdLib.use(require('markdown-it-footnote'))
mdLib.use(require('markdown-it-attrs'))
mdLib.disable('code')
eleventy.setLibrary('md', mdLib)
return {
dir: {
input: 'src',
output: 'public',
includes: 'templates/components',
layouts: 'templates/layouts',
data: 'data'
},
templateFormats: ['njk', 'md', '11ty.js', 'html']
}
}