-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.eleventy.js
More file actions
37 lines (31 loc) · 981 Bytes
/
.eleventy.js
File metadata and controls
37 lines (31 loc) · 981 Bytes
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
const markdownIt = require('markdown-it')
const markdownItAnchor = require('markdown-it-anchor')
const markdownItTOC = require('markdown-it-table-of-contents')
const headerSlugify = (text) => {
const cleaned = text.replace(/<\/?code>/g, '').replace(/(<|>|[<>])/g, '')
return markdownItAnchor.defaults.slugify(cleaned)
}
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy('favicon')
eleventyConfig.addPassthroughCopy('images')
eleventyConfig.addPassthroughCopy('styles')
const markdownEngine = markdownIt({ html: true })
markdownEngine.use(markdownItAnchor, {
permalink: true,
permalinkBefore: true,
permalinkSymbol: '#',
slugify: headerSlugify
})
markdownEngine.use(markdownItTOC, {
includeLevel: [2],
containerHeaderHtml: '<h2>Contents</h2>',
slugify: headerSlugify
})
eleventyConfig.setLibrary('md', markdownEngine)
return {
dir: {
input: '.',
output: '_site'
}
}
}