Skip to content

Instantly share code, notes, and snippets.

@zachleat
Created October 12, 2022 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachleat/9eac32724a9b7711c9a270d71a0fe3f5 to your computer and use it in GitHub Desktop.
Save zachleat/9eac32724a9b7711c9a270d71a0fe3f5 to your computer and use it in GitHub Desktop.
Add to Calendar Urls in Eleventy
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