Skip to content

Commit 2198038

Browse files
authored
Embed a calendar with all the events on the Calendar page (#252)
* embed a calendar with the events on the community calendars page * Dont open zoom window on click * add colors to the calendar * use vega color scheme category10 to generate calendar colors * make some UI changes
1 parent 2b9d5c4 commit 2198038

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

layouts/calendars/list.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,47 @@ <h5 class="subtitle is-5 is-muted">{{ .Params.Subtitle }}</h5>
3636
{{ end }}
3737
</div>
3838

39+
<br>
40+
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
41+
<link href='https://cdn.jsdelivr.net/npm/fullcalendar@5.11.0/main.min.css' rel='stylesheet' />
42+
<script src="https://cdnjs.cloudflare.com/ajax/libs/ical.js/1.4.0/ical.min.js"></script>
43+
<script src='https://cdn.jsdelivr.net/npm/fullcalendar@5.11.0/main.min.js'></script>
44+
<script src="https://cdn.jsdelivr.net/npm/@fullcalendar/icalendar@5.11.0/main.global.min.js"></script>
45+
46+
<script>
47+
document.addEventListener('DOMContentLoaded', function() {
48+
var cal_colors = vega.scheme('category10');
49+
var community_calendar = document.getElementById('community_calendar');
50+
var calendar = new FullCalendar.Calendar(community_calendar, {
51+
aspectRatio: 1,
52+
timeZone: 'local',
53+
initialView: 'dayGridMonth',
54+
headerToolbar: {
55+
left: "prev,next today",
56+
center: "title",
57+
right: "dayGridMonth,timeGridWeek,listWeek",
58+
},
59+
eventSources: [
60+
{{ range $key, $value := $.Site.Data.calendars }}
61+
{
62+
url: '{{ $key }}.ics',
63+
format: 'ics',
64+
color: cal_colors.shift(),
65+
},
66+
{{ end }}
67+
],
68+
eventClick: function(info) {
69+
info.jsEvent.preventDefault();
70+
alert('Event: ' + info.event.title + '\n' + info.event.extendedProps.description + '\n' + 'URL: ' +info.event.url);
71+
},
72+
eventDisplay: 'block',
73+
});
74+
calendar.render();
75+
});
76+
77+
</script>
78+
<div id='community_calendar'></div>
79+
3980
<h3 id="subscribe-google-calendar">Google Calendar</h3>
4081
Instructions from <a href="https://support.google.com/calendar/answer/37100?hl=en&co=GENIE.Platform%3DDesktop">the Google Calendar docs</a>:
4182
<ol>

0 commit comments

Comments
 (0)