-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.eleventy.js
133 lines (111 loc) · 3.85 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const yaml = require("js-yaml");
const { DateTime } = require("luxon");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const htmlmin = require("html-minifier");
module.exports = function (eleventyConfig) {
// Disable automatic use of your .gitignore
eleventyConfig.setUseGitIgnore(false);
// Merge data instead of overriding
eleventyConfig.setDataDeepMerge(true);
// human readable date
eleventyConfig.addFilter("readableDate", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
"DD"
);
});
// Wed Aug 6, 2014 (13:07)
eleventyConfig.addFilter("readableDateTime", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
"EEE DD (T)"
);
});
// 06 Aug 2014
eleventyConfig.addFilter("dateOnly", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
"dd LLL yyyy"
);
});
eleventyConfig.addFilter("timeOnly", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
"HH:mm"
);
});
eleventyConfig.addFilter("monthOnly", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
"M"
);
});
eleventyConfig.addFilter("yearOnly", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
"yyyy"
);
});
// 06 Aug
eleventyConfig.addFilter("dayMonthOnly", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
"dd LLL"
);
});
// Filtered events excluding a given type
eleventyConfig.addFilter("newItemList", (items, item_type) => {
return items.filter(item => item.type != item_type
);
});
// Filtered events including a given type
eleventyConfig.addFilter("inclItemTypeList", (items, item_type) => {
return items.filter(item => item.type == item_type
);
});
// Was returning list of items excluding the current day
// Fix 1 day off, minus the day of local datetime before it gets compared
eleventyConfig.addFilter("laterItemList", (items) => {
return items.filter(item => DateTime.local().minus({days: 0.5}) <= DateTime.fromJSDate(item.start_datetime)
);
});
eleventyConfig.addFilter("laterItemListConf", (items) => {
return items.filter(item => DateTime.local().minus({days: 0.5}) <= DateTime.fromJSDate(item.end_datetime)
);
});
// Syntax Highlighting for Code blocks
eleventyConfig.addPlugin(syntaxHighlight);
// To Support .yaml Extension in _data
// You may remove this if you can use JSON
eleventyConfig.addDataExtension("yaml", (contents) =>
yaml.safeLoad(contents)
);
// Add Tailwind Output CSS as Watch Target
eleventyConfig.addWatchTarget("./_tmp/static/css/style.css");
// Copy Static Files to /_Site
eleventyConfig.addPassthroughCopy({
"./_tmp/static/css/style.css": "./static/css/style.css",
"./src/admin/config.yml": "./admin/config.yml",
"./node_modules/alpinejs/dist/alpine.js": "./static/js/alpine.js",
"./node_modules/prismjs/themes/prism-tomorrow.css":
"./static/css/prism-tomorrow.css",
});
// Copy Image Folder to /_site
eleventyConfig.addPassthroughCopy("./src/static/img");
// Copy favicon to route of /_site
eleventyConfig.addPassthroughCopy("./src/favicon.ico");
// Minify HTML
eleventyConfig.addTransform("htmlmin", function (content, outputPath) {
// Eleventy 1.0+: use this.inputPath and this.outputPath instead
if (outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
return minified;
}
return content;
});
// Let Eleventy transform HTML files as nunjucks
// So that we can use .html instead of .njk
return {
dir: {
input: "src",
},
htmlTemplateEngine: "njk",
};
};