-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.js
54 lines (44 loc) · 1.38 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
const fs = require("fs");
const { DateTime } = require('luxon');
module.exports = eleventyConfig => {
// Display 404 page in BrowserSnyc
eleventyConfig.setBrowserSyncConfig({
callbacks: {
ready: (err, bs) => {
const content_404 = fs.readFileSync("dist/en/404/index.html");
bs.addMiddleware("*", (req, res) => {
// Provides the 404 content without redirect.
res.write(content_404);
res.end();
});
}
}
});
// or, use a Universal filter (an alias for all of the above)
eleventyConfig.addFilter("frDate", (date) => {
return DateTime.fromJSDate(date).toFormat('dd.MM.yyyy')
});
eleventyConfig.addFilter("engDate", (date) => {
return DateTime.fromJSDate(date).toFormat('yyyy.MM.dd')
});
// Return the smallest number argument
eleventyConfig.addFilter("min", (...numbers) => {
return Math.min.apply(null, numbers);
});
// Get the first `n` elements of a collection.
eleventyConfig.addFilter("head", (array, n) => {
if( n < 0 ) return array.slice(n);
return array.slice(0, n);
});
// Returning something from the configuration function is optional
return {
dir: {
input: "src",
output: "dist",
},
templateFormats: ["njk", "md"],
// htmlTemplateEngine: "njk",
// markdownTemplateEngine: "njk",
passthroughFileCopy: false
};
};