diff --git a/layouts/_partials/head.html b/layouts/_partials/head.html index 9625fc8..6728962 100644 --- a/layouts/_partials/head.html +++ b/layouts/_partials/head.html @@ -67,27 +67,44 @@ console.log("ICS enthält", events.length, "Events"); - const fcEvents = events - .map(event => { - try { - const icalEvent = new ICAL.Event(event); + const fcEvents = []; + + events.forEach(event => { + try { + const icalEvent = new ICAL.Event(event); + + if (icalEvent.isRecurring()) { + const expand = new ICAL.RecurExpansion({ + component: event, + dtstart: icalEvent.startDate + }); + + for (let i = 0; i < 30; i++) { + if (!expand.next()) break; + + const next = expand.last; + fcEvents.push({ + title: icalEvent.summary || "Ohne Titel", + start: next.toJSDate(), + allDay: icalEvent.startDate.isDate + }); + } + } else { const start = icalEvent.startDate?.toJSDate(); const end = icalEvent.endDate?.toJSDate(); + if (!start) return; - if (!start) return null; - - return { + fcEvents.push({ title: icalEvent.summary || "Ohne Titel", start: start, end: end, - description: icalEvent.description || "" - }; - } catch (e) { - console.warn("Fehler beim Parsen eines Events:", e); - return null; + allDay: icalEvent.startDate.isDate + }); } - }) - .filter(Boolean); + } catch (e) { + console.warn("Fehler beim Parsen eines Events:", e); + } + }); console.log("Nach dem Mapping:", fcEvents.length, "Events");