-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
67 lines (61 loc) · 2.09 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
const { minify } = require('terser');
const CleanCSS = require("clean-css");
const JSON5 = require('json5');
const pluginRss = require("@11ty/eleventy-plugin-rss");
const configUtils = require('./src/plugins/utils');
const typeUtils = require('./src/plugins/type');
const timeUtils = require('./src/plugins/time');
const imageUtils = require('./src/plugins/image');
module.exports = function(eleventyConfig) { // Set custom directories for input, output, includes, and data
eleventyConfig.addNunjucksAsyncFilter("jsmin", async function (
code,
callback
) {
try {
const minified = await minify(code);
callback(null, minified.code);
} catch (err) {
console.err('Terser error', err);
// Fail gracefully
callback(null, code);
}
});
eleventyConfig.addFilter("cssmin", function(code) {
return new CleanCSS({}).minify(code).styles;
});
// plugins
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(configUtils);
eleventyConfig.addPlugin(typeUtils);
eleventyConfig.addPlugin(timeUtils);
eleventyConfig.addPlugin(imageUtils);
// configure json5 support for data files
eleventyConfig.addDataExtension('json5', JSON5.parse);
// separate projects included fully
eleventyConfig.addPassthroughCopy("content/darken/index.html");
eleventyConfig.addPassthroughCopy("content/offset-cipher");
eleventyConfig.addPassthroughCopy("src/pq");
eleventyConfig.addPassthroughCopy("src/twine");
// assets
eleventyConfig.addPassthroughCopy("content/css");
eleventyConfig.addPassthroughCopy("content/fonts");
// the ./content/img folder is "legacy" images
eleventyConfig.addPassthroughCopy("content/img");
eleventyConfig.addPassthroughCopy("content/vid");
eleventyConfig.addPassthroughCopy("content/**/*.txt");
eleventyConfig.addPassthroughCopy("content/favicon.ico");
eleventyConfig.addPassthroughCopy("content/CNAME");
return {
markdownTemplateEngine: 'njk',
templateFormats: [
"njk",
"md"
],
dir: {
input: "content",
includes: "_includes",
data: "_data",
output: "docs"
}
};
};