-
Notifications
You must be signed in to change notification settings - Fork 5
/
.eleventy.js
39 lines (33 loc) 路 1.11 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
const markdownIt = require('markdown-it')
const markdownItAnchor = require('markdown-it-anchor')
const markdownItTOC = require('markdown-it-table-of-contents')
const syntaxHighlightPlugin = require('@11ty/eleventy-plugin-syntaxhighlight')
const headerSlugify = (text) => {
const cleaned = text.replace(/<\/?code>/g, '').replace(/(<|>|[<>])/g, '')
return markdownItAnchor.defaults.slugify(cleaned)
}
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(syntaxHighlightPlugin)
eleventyConfig.addPassthroughCopy('site/favicon')
eleventyConfig.addPassthroughCopy('site/images')
eleventyConfig.addPassthroughCopy('site/styles')
const markdownEngine = markdownIt({ html: true })
markdownEngine.use(markdownItAnchor, {
permalink: true,
permalinkBefore: true,
permalinkSymbol: '#',
slugify: headerSlugify
})
markdownEngine.use(markdownItTOC, {
includeLevel: [2],
containerHeaderHtml: '<h2>Table of Contents</h2>',
slugify: headerSlugify
})
eleventyConfig.setLibrary('md', markdownEngine)
return {
dir: {
input: 'site',
output: 'dist'
}
}
}