-
Notifications
You must be signed in to change notification settings - Fork 2
/
.eleventy.js
58 lines (48 loc) · 1.92 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 { nunjucks } = require("nunjucks");
module.exports = function(eleventyConfig) {
// Configure markdown-it plugins
const markdownIt = require('markdown-it')
const markdownItAnchor = require('markdown-it-anchor')
const markdownItAttrs = require('markdown-it-attrs')
const markdownItOptions = {
html: true,
breaks: true,
linkify: true
}
const mdLib = markdownIt(markdownItOptions).use(markdownItAttrs).use(markdownItAnchor)
eleventyConfig.setLibrary('md', mdLib);
// Enable SVG templating
eleventyConfig.addTemplateFormats('svg');
eleventyConfig.addExtension('svg', {
outputFileExtension: 'svg',
key: 'html'
});
// Export css and js artifacts
eleventyConfig.addPassthroughCopy('halfmoonui');
eleventyConfig.addPassthroughCopy('jsonpath-0.8.0.js');
eleventyConfig.addPassthroughCopy('custom-variables.css');
eleventyConfig.addPassthroughCopy({'mechdb/mechdb.js': 'mechdb.js'});
// Export character sheets
eleventyConfig.addPassthroughCopy('character-sheets/*.pdf');
// Export MechDB artifacts
eleventyConfig.addPassthroughCopy({'_data/parts.json': 'mechdb/parts.json'});
eleventyConfig.addPassthroughCopy({'_data/planets.json': 'lore/planets.json'});
// Export images
eleventyConfig.addPassthroughCopy('images/*.svg');
eleventyConfig.addPassthroughCopy('images/planets/*.svg');
// ???
eleventyConfig.setNunjucksEnvironmentOptions({
throwOnUndefined: true
});
// Custom shortcodes
eleventyConfig.addShortcode('keyword', function(word, glossary) {
return '<b class="keyword" onclick="halfmoon.initStickyAlert({content: \'' + glossary[word] + '\', title: \'' + word + '\', hasDismissButton: true, timeShown: 5000});">' + word + '</b>'
});
// Custom filters
eleventyConfig.addFilter('getObjectsByAttribute', function(objects, attribute, value) {
return objects.filter((obj) => obj[attribute] == value);
});
return {
htmlTemplateEngine: 'njk'
}
};