-
Notifications
You must be signed in to change notification settings - Fork 2
/
.eleventy.js
53 lines (38 loc) · 1.42 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
const path = require('path')
const del = require('del')
const STATIC_FOLDERS = require('./_helper/paths')
const IS_PROD = process.env.ELEVENTY_ENV === 'production'
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(require('./_plugins'))
eleventyConfig.addPlugin(require('./_shortcodes'))
eleventyConfig.addPlugin(require('./_functions'))
eleventyConfig.addPlugin(require('./_libraries'))
eleventyConfig.addPlugin(require('./_transforms'))
eleventyConfig.addPlugin(require('./_templates'))
eleventyConfig.on('eleventy.before', async function () {
const dist = path.join(process.cwd(), 'dist')
const deletedDirectoryPaths = await del([`${dist}/**`, `!${dist}/img`])
if (deletedDirectoryPaths.length) {
console.log('eleventy.before: 🗑 Deleted `dist`.')
}
})
eleventyConfig.addLayoutAlias('base', 'layouts/base.njk')
eleventyConfig.addWatchTarget(`./${STATIC_FOLDERS.static}**/*`)
eleventyConfig.addWatchTarget('./_helper/**/*')
// copy static assets to dist folder
eleventyConfig.addPassthroughCopy({ [`./${STATIC_FOLDERS.img}`]: '/img/' })
eleventyConfig.addPassthroughCopy({
[`./${STATIC_FOLDERS.files}`]: '/files/',
})
return {
templateFormats: ['md', '11ty.js', 'njk'],
htmlTemplateEngine: 'njk',
markdownTemplateEngine: 'njk',
dir: {
input: '_src',
output: 'dist',
data: '_data',
includes: '_includes',
},
}
}