Created
October 12, 2022 13:27
-
-
Save zachleat/9eac32724a9b7711c9a270d71a0fe3f5 to your computer and use it in GitHub Desktop.
Add to Calendar Urls in Eleventy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { google, outlook, office365, yahoo, ics } = require("calendar-link"); | |
module.exports = function(eleventyConfig) { | |
// `event` structure documented on https://www.npmjs.com/package/calendar-link | |
eleventyConfig.addLiquidFilter("addToCalendar", (event, type) => { | |
if(type === "google") { | |
return google(event); | |
} else if(type === "office365") { | |
return office365(event); | |
} else if(type === "outlook") { | |
return outlook(event); | |
} else if(type === "ics") { | |
return ics(event); | |
} | |
throw new Error(`Invalid type (${type}) received in addToCalendar filter.`); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment