-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
99 lines (85 loc) · 2.75 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
89
90
91
92
93
94
95
96
97
98
99
const pluginLazyImages = require('eleventy-plugin-lazyimages');
const filterNbsp = require('eleventy-nbsp-filter');
const filters = require('./src/utils/filters.js');
const shortcodes = require('./src/utils/shortcodes.js');
const collections = require('./src/utils/collections.js');
module.exports = function (config) {
// Plugins
if (process.env.ELEVENTY_ENV == 'production') {
config.addPlugin(pluginLazyImages);
}
// Markdown It
let markdownIt = require('markdown-it');
let markdownItGitHubHeadings = require('markdown-it-github-headings');
let markdownItExternalAnchor = require('markdown-it-external-anchor');
let options = {
html: true,
};
let markdownLib = markdownIt(options)
.use(markdownItGitHubHeadings)
.use(markdownItExternalAnchor, {
domain: 'www.kogakure.de',
class: 'external',
});
config.setLibrary('md', markdownLib);
// Compress and combine JS files
config.addFilter('jsmin', require('./src/utils/minify-js.js'));
// Minify the HTML in production
if (process.env.ELEVENTY_ENV == 'production') {
config.addTransform('htmlmin', require('./src/utils/minify-html.js'));
}
// Shortcodes
config.addShortcode('download', shortcodes.download);
config.addShortcode('duoColorImage', shortcodes.duoColorImage);
config.addShortcode('email', shortcodes.email);
config.addShortcode('more', shortcodes.more);
config.addShortcode('product', shortcodes.product);
config.addShortcode('youtube', shortcodes.youtube);
config.addPairedShortcode('banner', shortcodes.banner);
config.addPairedShortcode('figure', shortcodes.figure);
config.addPairedShortcode('productshelf', shortcodes.productshelf);
// Filters
Object.keys(filters).forEach((filterName) => {
config.addFilter(filterName, filters[filterName]);
});
config.addFilter('nbsp', filterNbsp(2, 10));
// Watch for changes and reload
config.addWatchTarget('src/assets');
// Copy static files to dist
config.addPassthroughCopy({
'src/static/**/*.{xml,html,ico}': '.',
});
config.addPassthroughCopy({
'src/static/.well-known/*': '.well-known',
});
config.addPassthroughCopy({
'src/downloads': 'downloads',
});
config.addPassthroughCopy({
'src/assets/fonts': 'assets/fonts',
});
config.addPassthroughCopy({
'src/assets/images': 'assets/images',
});
// Deep-Merge
config.setDataDeepMerge(true);
// Custom Collections
Object.keys(collections).forEach((collectionName) => {
config.addCollection(collectionName, collections[collectionName]);
});
// Set input and output folders
return {
dir: {
input: 'src',
data: 'data',
includes: 'includes',
layouts: 'layouts',
output: 'dist',
},
templateFormats: ['njk', 'md', '11ty.js'],
htmlTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
markdownTemplateEngine: 'njk',
passthroughFileCopy: true,
};
};