-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
51 lines (41 loc) · 1.36 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
const typeset = require('typeset')
const markdownIt = require('markdown-it')
const svgSprite = require('eleventy-plugin-svg-sprite')
module.exports = (config) => {
config.setServerOptions({
watch: ['dist/css/main.css'],
showAllHosts: true,
})
config.addPassthroughCopy('src/assets')
config.addPassthroughCopy('src/index.js')
config.addWatchTarget('src/index.js')
// Put all projects in a collection
config.addCollection('projects', (collection) => {
return collection.getFilteredByGlob('src/projects/*.md')
})
// Use curly quotes, ellipses, em dash, etc. to improve typography
config.addTransform('typeset', (content) => {
return typeset(content, { disable: ['hangingPunctuation', 'hyphenate'] })
})
// Add filter to transform markdown to HTML
config.addFilter('md', (content) => {
const md = new markdownIt({ html: true })
let inline = !content.includes('\n')
return inline ? md.renderInline(content) : md.render(content)
})
// Inline SVGs as a sprite
config.addPlugin(svgSprite, {
path: 'src/assets/svg',
globalClasses: 'icon',
})
config.addShortcode('icon', (name, customClass) => {
return `<svg aria-hidden="true" class="icon ${customClass}"><use href="#svg-${name}"></use></svg>`
})
return {
markdownTemplateEngine: 'njk',
dir: {
input: 'src',
output: 'dist',
},
}
}