-
Notifications
You must be signed in to change notification settings - Fork 8
/
.eleventy.js
56 lines (47 loc) · 1.54 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
const markdownIt = require('markdown-it');
const markdownItToc = require('markdown-it-table-of-contents');
const markdownItAnchor = require('markdown-it-anchor');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy('src/assets');
const md = markdownIt({
html: true,
linkify: true,
typographer: true,
breaks: false,
})
.use(require('markdown-it-block-embed'))
.use(markdownItToc, { includeLevel: [1, 2, 3] })
.use(markdownItAnchor, {
permalink: markdownItAnchor.permalink.headerLink(),
});
eleventyConfig.setLibrary('md', md);
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPairedShortcode('aside', (content, label) => {
return `<aside class="aside"><p class="aside-label">${label}</p>${md.render(content)}</aside>`;
3;
});
eleventyConfig.addShortcode('current', (slug, currentSlug) => {
return slug === currentSlug ? 'aria-current="page"' : '';
});
// if NO_RELOAD node environment variable is found, disable live reloading
if (process.env.NO_RELOAD) {
eleventyConfig.setServerOptions({
liveReload: false,
});
}
// sort chapter collection by fileSlug
eleventyConfig.addCollection('sortedChapter', function (collection) {
return collection
.getFilteredByTag('chapter')
.sort(
(a, b) =>
parseInt(a.fileSlug.substr(0, 2)) - parseInt(b.fileSlug.substr(0, 2)),
);
});
return {
dir: {
input: 'src',
},
};
};