-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
54 lines (44 loc) · 1.49 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
require('dotenv').config();
const { parse, stringify } = require('himalaya');
const dateFilter = require('./src/filters/date-filter.js');
const htmlMinTransform = require('./src/transforms/html-min-transform.js');
const Image = require('@11ty/eleventy-img');
const isProduction = process.env.NODE_ENV === 'production';
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const w3DateFilter = require('./src/filters/w3-date-filter.js');
module.exports = config => {
config.addFilter('dateFilter', dateFilter);
config.addFilter('w3DateFilter', w3DateFilter);
config.addPlugin(syntaxHighlight);
config.addPassthroughCopy('./src/img/**');
config.addPassthroughCopy('./src/css/**');
config.addPassthroughCopy('./src/js/**');
config.addPassthroughCopy('./src/font/**');
config.addCollection('blog', collection => {
return [...collection.getFilteredByGlob('./src/posts/*.md')];
});
config.addNunjucksAsyncShortcode('svgIcon', async (src, cls) => {
const metadata = await Image(src, {
formats: ['svg'],
dryRun: true,
});
const svg = parse(metadata.svg[0].buffer.toString());
svg[0].attributes.push({
key: 'class',
value: cls ? cls : 'icon'
});
return stringify(svg);
});
if (isProduction) {
config.addTransform('htmlmin', htmlMinTransform);
}
return {
markdownTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
dir: {
input: 'src',
output: 'dist'
}
};
};