-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
66 lines (49 loc) · 2.14 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
const markdownShortcode = require("eleventy-plugin-markdown-shortcode");
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const markdownIt = require("markdown-it");
const uslug = require('uslug');
const markdownItAnchor = require('markdown-it-anchor');
const uslugify = s => uslug(s);
module.exports = function(eleventyConfig){
eleventyConfig.addLayoutAlias('default', 'layouts/default.njk');
eleventyConfig.addPassthroughCopy("public");
//adding plugins
eleventyConfig.addPlugin(markdownShortcode);
eleventyConfig.addPlugin(eleventyNavigationPlugin);
//adds plugins and configures markdownIt
let options = {
html: true,
breaks: true,
linkify: true
};
// sets markdownIt as default markdown library for parsing .md files
let markdownLib = markdownIt(options).use(markdownItAnchor, {slugify: uslugify});
eleventyConfig.setLibrary("md", markdownLib);
// configures a filter to allow inserting .md snippets into any nunjucks layout. From here: https://github.com/11ty/eleventy/issues/658
eleventyConfig.addFilter('markdown', function(value) {
let markdown = require('markdown-it')({
html: true
});
return markdown.render(value);
});
// adds filter to order the skills list with the skill categories with more items first
eleventyConfig.addFilter("orderSkillsMoreFirst", function(objectArray){
return objectArray.sort((a,b) => b.skills.length - a.skills.length)
});
// adds shortcut to translate break-lines into separate <p> elements
eleventyConfig.addPairedShortcode("richText", function(content) {
return content.split("\n").reduce((acc, line, i) => acc+`<p id="${i}" class="mb-0">${line}</p>`);
});
return {
templateFormats: ["md", "njk", "css"],
markdownTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
passthroughFileCopy: true,
dir: {
input: 'site',
includes: '_includes',
data: '_data',
output: 'docs'
}
}
}