-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
.eleventy.js
48 lines (41 loc) · 1.39 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
module.exports = function(eleventyConfig) {
const markdownIt = require('markdown-it');
const markdownItOptions = {
html: true,
linkify: true
};
const md = markdownIt(markdownItOptions)
.use(require('markdown-it-footnote'))
.use(require('markdown-it-attrs'))
.use(function(md) {
// Recognize Mediawiki links ([[text]])
md.linkify.add("[[", {
validate: /^\s?([^\[\]\|\n\r]+)(\|[^\[\]\|\n\r]+)?\s?\]\]/,
normalize: match => {
const parts = match.raw.slice(2,-2).split("|");
parts[0] = parts[0].replace(/.(md|markdown)\s?$/i, "");
match.text = (parts[1] || parts[0]).trim();
match.url = `/notes/${parts[0].trim()}/`;
}
})
})
eleventyConfig.addFilter("markdownify", string => {
return md.render(string)
})
eleventyConfig.setLibrary('md', md);
eleventyConfig.addCollection("notes", function (collection) {
return collection.getFilteredByGlob(["notes/**/*.md", "index.md"]);
});
eleventyConfig.addPassthroughCopy('assets');
eleventyConfig.setUseGitIgnore(false);
return {
dir: {
input: "./",
output: "_site",
layouts: "layouts",
includes: "includes",
data: "_data"
},
passthroughFileCopy: true
}
}