-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eleventy.js
84 lines (71 loc) · 2.25 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
let Nunjucks = require('nunjucks');
let slugify = require('slugify');
let markdownIt = require('markdown-it');
let markdownItAnchor = require('markdown-it-anchor');
let markdownItToc = require('markdown-it-table-of-contents');
let markdownItFootnote = require('markdown-it-footnote');
let TOC = require('eleventy-plugin-toc');
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/assets/css");
eleventyConfig.addPassthroughCopy("src/assets/img");
eleventyConfig.addPlugin(TOC);
function removeExtraText(s) {
let newStr = String(s).replace(/New\ in\ v\d+\.\d+\.\d+/, "");
newStr = newStr.replace(/Coming\ soon\ in\ v\d+\.\d+\.\d+/, "");
newStr = newStr.replace(/⚠️/g, "");
newStr = newStr.replace(/[?!]/g, "");
newStr = newStr.replace(/<[^>]*>/g, "");
return newStr;
}
function markdownItSlugify(s) {
return slugify(removeExtraText(s), { lower: true, remove: /[:’'`,]/g });
}
function removeExtraText(s) {
let newStr = String(s).replace(/New\ in\ v\d+\.\d+\.\d+/, "");
newStr = newStr.replace(/Coming\ soon\ in\ v\d+\.\d+\.\d+/, "");
newStr = newStr.replace(/⚠️/g, "");
newStr = newStr.replace(/[?!]/g, "");
newStr = newStr.replace(/<[^>]*>/g, "");
return newStr;
}
function markdownItSlugify(s) {
return slugify(removeExtraText(s), { lower: true, remove: /[:’'`,]/g });
}
let md = markdownIt({
html: true,
breaks: false,
linkify: true
}).use(markdownItAnchor, {
slugify: markdownItSlugify,
permalinkClass: "direct-link",
permalinkSymbol: "#",
level: [1,2,3,4]
}).use(markdownItToc, {
includeLevel: [2, 3],
slugify: markdownItSlugify,
format: function(heading) {
return removeExtraText(heading);
},
transformLink: function(link) {
return link.replace(/\%60/g, "");
}
}).use(markdownItFootnote, {
});
md.linkify.tlds('.io', false);
eleventyConfig.setLibrary('md', md);
eleventyConfig.addFilter('ucfirst', (str) => {
return str[0].toUpperCase() + str.substring(1);
});
eleventyConfig.addFilter('lower', (str) => {
let theString = str+"";
return theString.toLowerCase();
});
return {
htmlTemplateEngine: "njk",
dir: {
includes: "includes",
input: "src",
output: "site"
}
};
};