-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheleventy.config.cjs
50 lines (42 loc) · 1.39 KB
/
eleventy.config.cjs
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
const fs = require("fs");
const pluginWebC = require("@11ty/eleventy-plugin-webc");
const bundlerPlugin = require("@11ty/eleventy-plugin-bundle");
const NOT_FOUND_PATH = "_site/404.html";
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(pluginWebC, {
components: "website/_includes/components/*.webc",
});
eleventyConfig.addPlugin(bundlerPlugin);
eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
eleventyConfig.addPassthroughCopy({ public: "." });
eleventyConfig.setServerOptions({
module: "@11ty/eleventy-server-browsersync",
// Default Browsersync options shown:
port: 8080,
open: false,
notify: false,
ui: false,
ghostMode: false,
callbacks: {
ready: function(err, bs) {
bs.addMiddleware("*", (req, res) => {
if (!fs.existsSync(NOT_FOUND_PATH)) {
throw new Error(`Expected a \`${NOT_FOUND_PATH}\` file but could not find one. Did you create a 404.html template?`);
}
const content_404 = fs.readFileSync(NOT_FOUND_PATH);
// Add 404 http status code in request header.
res.writeHead(404, { "Content-Type": "text/html; charset=UTF-8" });
// Provides the 404 content without redirect.
res.write(content_404);
res.end();
});
}
}
});
return {
dir: {
input: "website",
},
markdownTemplateEngine: "njk"
};
};