-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
42 lines (36 loc) · 1.16 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
const markdownIt = require('markdown-it');
const markdownItAnchor = require('markdown-it-anchor');
const markdownItFootnote = require('markdown-it-footnote');
module.exports = function(eleventyConfig) {
// Copy the `imges` and `css` folders to the output
eleventyConfig.addPassthroughCopy('assets');
// Copy PDF files with the articles
eleventyConfig.addPassthroughCopy('!(_site)**/*.pdf');
// Markdown
let markdownLibrary = markdownIt({
html: true,
breaks: true,
linkify: true,
typographer: true
})
.use(markdownItAnchor, {
permalink: true,
permalinkClass: 'direct-link',
permalinkSymbol: '#'
})
.use(markdownItFootnote);
markdownLibrary.renderer.rules.footnote_caption = (tokens, idx) => {
let n = Number(tokens[idx].meta.id + 1).toString();
if (tokens[idx].meta.subId > 0) {
n += ":" + tokens[idx].meta.subId;
}
return n;
};
eleventyConfig.setLibrary('md', markdownLibrary);
// Create and add the sort filter
function sortByIndex(values) {
let vals = [...values]
return vals.sort((a, b) => Math.sign(a.data.index - b.data.index))
}
eleventyConfig.addFilter('sortByIndex', sortByIndex);
};