-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
46 lines (39 loc) · 1.38 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
const fs = require('fs')
const md = require('markdown-it')
const componentsDir = './src/_includes/components'
const layoutsDir = './src/_includes/layouts'
const toPascalCase = s => s.replace(/(^\w|-\w)/g, t => t.replace(/-/, '').toUpperCase())
module.exports = function (config) {
// Markdown plugins
const markdownLib = md({ html: true })
.use(require('markdown-it-external-links'), {
externalClassName: 'external',
externalTarget: '_blank',
externalRel: 'noopener noreferrer',
internalDomains: ['csi.lk', 'callumsilcock.com'],
})
.use(require('markdown-it-highlightjs'), {
code: false,
})
.use(require('markdown-it-attrs'))
config.setLibrary('md', markdownLib)
// Use custom ignore
config.setUseGitIgnore(false)
// Add all layouts
fs.readdirSync(layoutsDir).forEach(folder => {
config.addLayoutAlias(folder, `layouts/${folder}/${folder}.11ty.js`)
})
// Add all components as {% shortcodes %}
fs.readdirSync(componentsDir).forEach(folder => {
config.addPairedShortcode(toPascalCase(folder), children =>
require(`${componentsDir}/${folder}/${folder}.js`).default(null, children),
)
})
// Config
return {
dir: { input: 'src', output: 'dist', data: '_data' },
passthroughFileCopy: true,
templateFormats: ['njk', 'md', 'css', 'html', 'yml', 'txt', 'svg', 'ico'],
htmlTemplateEngine: 'njk',
}
}