-
Notifications
You must be signed in to change notification settings - Fork 453
/
.eleventy.js
44 lines (41 loc) · 1.13 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
const tocPlugin = require("eleventy-plugin-toc");
const markdownIt = require("markdown-it");
const CleanCSS = require("clean-css");
module.exports = (eleventyConfig) => {
eleventyConfig.addPassthroughCopy("docs/assets");
eleventyConfig.addFilter(
"cssmin",
(code) => new CleanCSS({}).minify(code).styles,
);
// This filter is used for deriving the chapter names
// from data in chapters.json
eleventyConfig.addFilter("heading", (str) =>
str.replace(/[_;\\/:*?\"<>|&']/g, " "),
);
// Filter for linking to section headers
// and displaying chapters in a page
const markdownItAnchor = require("markdown-it-anchor");
const mdIt = markdownIt({
html: true,
linkify: true,
}).use(markdownItAnchor, {
permalink: true,
permalinkBefore: false,
permalinkClass: "direct-link",
permalinkSymbol: "#",
level: [1, 2],
});
eleventyConfig.addFilter("markdown", (code) => {
if (code) {
return mdIt.render(code);
}
});
eleventyConfig.setLibrary("md", mdIt);
eleventyConfig.addPlugin(tocPlugin);
return {
dir: {
input: "docs",
output: "docs/_site",
},
};
};