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