Skip to content

Instantly share code, notes, and snippets.

@ankedsgn
Created May 12, 2017 13:26
Show Gist options
  • Save ankedsgn/76a1c594845700012d51580bb4844207 to your computer and use it in GitHub Desktop.
Save ankedsgn/76a1c594845700012d51580bb4844207 to your computer and use it in GitHub Desktop.
{#
MADE FOR A SPECIFIC SITE, BUT THE ICS IDEA IS PROBABLY CLEAR HERE - AW 2017
#}
{% if (item.start_event is not empty) and (item.end_event is not empty) %}
{# when no times, we make no add to calendar blokkie #}
{% set icslink =
'data:text/calendar;
charset=utf8,
BEGIN:VCALENDAR%0A
VERSION:2.0%0A
BEGIN:VEVENT%0A
URL:'~item.link()~'%0A
DTSTART:'~item.start_event|localedatetime("%Y%m%dT%H%M%S")~'%0A
DTEND:'~item.end_event|localedatetime("%Y%m%dT%H%M%S")~'%0A
SUMMARY:'~item.title~'%0A
LOCATION:'~item.geolocation.address|default("No location given")~'%0A
END:VEVENT%0A
END:VCALENDAR'
%}
<a class="add-calendar" href="{{ icslink }}">
<svg class="icon icon-calendar">
<use xlink:href="#icon-calendar"></use>
</svg>
Add to calendar
</a>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment