forked from fluid-project/floeproject.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
67 lines (55 loc) · 1.96 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 fs = require("fs");
const rssPlugin = require('@11ty/eleventy-plugin-rss');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
// Import filters
const dateFilter = require('./src/filters/date-filter.js');
const markdownFilter = require('./src/filters/markdown-filter.js');
// Import transforms
const htmlMinTransform = require('./src/transforms/html-min-transform.js');
const parseTransform = require('./src/transforms/parse-transform.js');
// Import data files
const site = require('./src/_data/site.json');
module.exports = function(config) {
// Filters
config.addFilter('dateFilter', dateFilter);
config.addFilter('markdownFilter', markdownFilter);
// Transforms
config.addTransform('htmlmin', htmlMinTransform);
config.addTransform('parse', parseTransform);
// Passthrough copy
config.addPassthroughCopy({"src/assets/images": "assets/images"});
config.addPassthroughCopy({"src/assets/js": "assets/js"});
config.addPassthroughCopy({"src/lib": "lib"});
config.addPassthroughCopy({"src/assets/stylesheets": "assets/stylesheets"});
config.addPassthroughCopy({"src/news/images": "news/images"})
// Plugins
config.addPlugin(rssPlugin);
config.addPlugin(syntaxHighlight);
// 404
config.setBrowserSyncConfig({
callbacks: {
ready: function(err, bs) {
bs.addMiddleware("*", (req, res) => {
const content_404 = fs.readFileSync('dist/404.html');
// Provides the 404 content without redirect.
res.write(content_404);
// Add 404 http status code in request header.
// res.writeHead(404, { "Content-Type": "text/html" });
res.writeHead(404);
res.end();
});
}
}
});
return {
dir: {
input: 'src',
output: 'dist',
includes: "_includes"
},
templateFormats: ["html", "md"],
htmlTemplateEngine: "liquid",
// 1.1 Enable elventy to pass dirs specified above
passthroughFileCopy: true
};
};