-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
55 lines (45 loc) · 1.64 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 CleanCSS = require("clean-css");
const { DateTime } = require("luxon");
const faviconsPlugin = require("eleventy-plugin-gen-favicons");
module.exports = function(eleventyConfig) {
eleventyConfig.addWatchTarget("./src/_includes/");
eleventyConfig.addPassthroughCopy('./src/_includes/');
// enable CORS
eleventyConfig.setBrowserSyncConfig({
middleware: function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
}
});
eleventyConfig.addFilter("cssmin", function(code) {
return new CleanCSS({}).minify(code).styles;
});
eleventyConfig.addFilter("asPostDate", (dateObj) => {
return DateTime.fromJSDate(dateObj).toLocaleString(DateTime.DATE_MED);
});
eleventyConfig.addFilter("limit", function(array, limit) {
return array.slice(0, limit);
});
eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(format || "LLLL dd, yyyy");
})
eleventyConfig.addFilter("htmlDateString", (dateObj) => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
})
eleventyConfig.addPlugin(faviconsPlugin, {
'outputDir': 'docs'
});
return {
templateFormats: ["html", "njk", "md", "js"],
dir: {
input: "src",
includes: "_includes",
data: "_data",
output: "docs"
},
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dataTemplateEngine: "njk",
passthroughFileCopy: true
}
};