-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
43 lines (36 loc) · 1.32 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
module.exports = function (eleventyConfig) {
const rdmd = require('@readme/markdown');
const format = require('date-fns/format');
const htmlmin = require('html-minifier');
const embedYouTube = require('eleventy-plugin-youtube-embed');
eleventyConfig.setLibrary('md', { render: rdmd.html });
eleventyConfig.addFilter('squash', require('./_includes/squash.js'));
eleventyConfig.addFilter('date', (date, dateFormat) =>
format(date, dateFormat)
);
eleventyConfig.addPlugin(embedYouTube);
eleventyConfig.addPassthroughCopy({ _src: '/' });
eleventyConfig.addPassthroughCopy( {"_includes/samples": "samples"} );
// Allow us to put rendered markdown in HTML
eleventyConfig.addPairedShortcode('markdown', (content) => {
return rdmd.html(content);
});
// Only for prod environments
if (process.env.NODE_ENV !== 'development') {
// Minify our build to save the bits
eleventyConfig.addTransform('htmlmin', function (content, outputPath) {
if (outputPath?.endsWith('.html')) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
});
return minified;
}
return content;
});
}
eleventyConfig.setUseGitIgnore(false);
};