-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
58 lines (51 loc) · 1.62 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
const markdownIt = require('markdown-it')
const markdownItAnchor = require('markdown-it-anchor')
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const matter = require('gray-matter');
module.exports = (config) => {
// Set Markdown config
const markdownLibrary = markdownIt({
html: true,
breaks: true,
linkify: true
}).use(markdownItAnchor, {
permalink: true,
permalinkBefore: true,
permalinkSymbol: "",
});
// Watch CSS
config.addWatchTarget('dist/css/*.css')
config.setBrowserSyncConfig({
files: ['dist/css/*.css']
})
// Syntax highlighting plugin
config.addPlugin(syntaxHighlight);
// Build a reportedSections computed data object for table of contents and tidier templates
config.addCollection("reportSections", (collection) => {
const sections = collection.getFilteredByGlob('./src/report/*.md').map(section => {
const separatedMetadataAndContent = matter(section.template.inputContent)
return {
ID: section.fileSlug,
title: separatedMetadataAndContent.data.title,
order: separatedMetadataAndContent.data.order,
url: `../..${section.filePathStem}.md`,
content: separatedMetadataAndContent.content,
isEmpty: separatedMetadataAndContent.isEmpty
}
})
return sections.sort((a, b) => a.order - b.order);
})
config.addPairedShortcode("markdown", content => {
return markdownLibrary.render(content)
})
// Pass through vendor script for prism.js
config.addPassthroughCopy('vendor')
return {
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dir: {
input: "src",
output: "dist",
},
};
};