-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
27 lines (23 loc) · 905 Bytes
/
eleventy.config.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
const ics = require("ics");
const calendar = require("./calendar");
module.exports = (eleventyConfig, options = {}) => {
eleventyConfig.addFilter("slugifyEvent", (event) => {
return `${eleventyConfig.getFilter("slugify")(event.data.title)}-${calendar.toHtmlString(event.data.start)}`;
});
eleventyConfig.addFilter("toCalendar", (events) => {
const jsonEvents = (events || []).map(event => calendar.eventToJsonEvent(event, options));
const {error, value} = ics.createEvents(jsonEvents);
if (!error) {
return value;
}
console.log(error);
});
eleventyConfig.addFilter("toCalendarEvent", (event) => {
const jsonEvent = calendar.eventToJsonEvent(event, options);
const {error, value} = ics.createEvent(jsonEvent);
if (!error) {
return value;
}
console.log(error);
});
}