-
Notifications
You must be signed in to change notification settings - Fork 20
/
.eleventy.js
88 lines (81 loc) · 2.94 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const glob = require('fast-glob');
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const markdownIt = require("markdown-it");
const markdownItAnchor = require('markdown-it-anchor');
const markdownItToc = require('markdown-it-toc-done-right');
module.exports = function(eleventyConfig) {
/* --------------------------------------------------------------------------
11ty plugins
-------------------------------------------------------------------------- */
eleventyConfig.addPlugin(syntaxHighlight);
/* --------------------------------------------------------------------------
filters
-------------------------------------------------------------------------- */
glob.sync(['_source/_filters/*.js']).forEach(file => {
let filters = require('./' + file);
Object.keys(filters).forEach(name => eleventyConfig.addFilter(name, filters[name]));
});
/* --------------------------------------------------------------------------
BrowserSync settings
-------------------------------------------------------------------------- */
eleventyConfig.setBrowserSyncConfig({
ui: false,
logPrefix: false,
files: [ // watch the files generated elsewhere
'_public/assets/*.css',
'_public/assets/*.js',
'_public/assets',
'!_public/assets/**/**.map'
],
server: { // make URLs work without a .html extension
baseDir: "_public",
serveStaticOptions: {
extensions: ["html"]
}
},
snippetOptions: {
rule: { // put the snippet in the head for Turbo happiness
match: /<\/head>/i,
fn: function (snippet, match) {
return snippet + match;
}
}
},
});
/* --------------------------------------------------------------------------
MarkdownIt settings
-------------------------------------------------------------------------- */
const markdownItOptions = {
html: true, // allow HTML markup
typographer: true // fancy quotes
};
const markdownLib = markdownIt(markdownItOptions);
markdownLib.use(markdownItAnchor, { // add anchors to headings
level: '2',
permalink: 'true',
permalinkClass: 'anchor',
permalinkSymbol: '﹟',
permalinkBefore: 'true'
});
markdownLib.use(markdownItToc, { // make a TOC with ${toc}
level: '2',
listType: 'ul'
});
/* --------------------------------------------------------------------------
11ty settings
-------------------------------------------------------------------------- */
eleventyConfig.setLibrary('md', markdownLib);
eleventyConfig.setDataDeepMerge(true);
eleventyConfig.addPassthroughCopy({ '_source/_assets/fonts': 'assets/fonts' });
eleventyConfig.addPassthroughCopy({ '_source/_assets/images': 'assets' });
return {
dir: {
input: '_source',
output: '_public',
layouts: '_layouts',
includes: '_includes'
},
templateFormats: ['html', 'md', 'liquid', 'njk'],
htmlTemplateEngine: 'liquid'
};
};