-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
62 lines (57 loc) · 1.61 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
const markdownIt = require('markdown-it');
const inspect = require('util').inspect;
const { EleventyHtmlBasePlugin } = require('@11ty/eleventy');
const yaml = require('js-yaml');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
const md = new markdownIt({
html: true,
});
module.exports = function(config) {
/* Add plugins */
config.addPlugin(syntaxHighlight);
config.addPlugin(EleventyHtmlBasePlugin);
/* Add YAML support */
config.addDataExtension('yml', contents => yaml.load(contents));
/* Filters */
config.addFilter('markdown', (content) => {
// Adds markdown support to any field
// e.g. {{ pattern.description | markdown | safe }}
return md.render(content);
});
config.addFilter('objToArray', data => {
// When using multiple files in the `data` directory
// 11ty appends them as key/value pairs to an object.
// This filter is useful for turning that object into an array,
// by ignoring the filename (key), and extracting the values.
return Object.values(data);
});
config.addFilter('debug', (content) => {
return inspect(content);
});
config.addFilter('getFileContents', (fileURI) => {
let filePath = `${__dirname}/${fileURI}`;
let file = readFileSync(filePath, (error, contents) => {
return contents;
});
return file.toString('utf8');
});
return {
templateFormats: [
'html',
'md',
'njk',
],
htmlTemplateEngine: [
'njk',
'md',
],
dir: {
// ⚠️ These values are both relative to your input directory.
input: 'src',
output: 'dist',
data: '_data',
includes: '_includes',
layouts: '_layouts',
}
}
}