-
Notifications
You must be signed in to change notification settings - Fork 9
/
.eleventy.js
55 lines (48 loc) · 1.78 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
const fs = require("fs");
const pluginRss = require("@11ty/eleventy-plugin-rss");
module.exports = function(eleventyConfig) {
// aliases for backwards support of jekyll layouts
eleventyConfig.addLayoutAlias('blank', 'layouts/blank.html');
eleventyConfig.addLayoutAlias('error', 'layouts/error.html');
eleventyConfig.addLayoutAlias('default', 'layouts/default.html');
eleventyConfig.addLayoutAlias('permalink', 'layouts/permalink.html');
eleventyConfig.addLayoutAlias('post', 'layouts/post.html');
eleventyConfig.addLayoutAlias('tag', 'layouts/tag.html');
// configure post collection
eleventyConfig.addCollection('post', collection => {
return collection.getFilteredByGlob('_posts/*.md');
});
// non-template files that we want to serve
eleventyConfig.addPassthroughCopy("images");
eleventyConfig.addPassthroughCopy("js");
eleventyConfig.addPassthroughCopy("main.css");
eleventyConfig.addPassthroughCopy("*.png");
eleventyConfig.addPassthroughCopy("favicon.ico");
eleventyConfig.addPassthroughCopy("manifest.json");
eleventyConfig.addPassthroughCopy("*.svg");
eleventyConfig.addPassthroughCopy("sw.js");
// 404 page for local server
eleventyConfig.setBrowserSyncConfig({
callbacks: {
ready: function(err, bs) {
bs.addMiddleware("*", (req, res) => {
const content_404 = fs.readFileSync('_site/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();
});
}
}
});
// register rss plugin
eleventyConfig.addPlugin(pluginRss);
return {
dir: {
input: "./",
output: "./_site"
}
}
}