Skip to content

Commit 3f8fe6d

Browse files
committed
Add Outlook calendar link support in calendarLinks function
1 parent 95734b4 commit 3f8fe6d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pcd-website/src/components/NodePanel.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@ async function copyLink(node: Node) {
336336
role="menuitem"
337337
@click="calDropdownOpen = false"
338338
>Google Calendar</a>
339+
<a
340+
:href="calendarLinks(node).outlookCalUrl"
341+
target="_blank"
342+
rel="noopener noreferrer"
343+
role="menuitem"
344+
@click="calDropdownOpen = false"
345+
>Outlook</a>
339346
<button role="menuitem" @click="downloadIcs(node); calDropdownOpen = false">
340347
Download .ics
341348
</button>

pcd-website/src/lib/format.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function escapeIcs(str: string): string {
6666
.replace(/\n/g, '\\n');
6767
}
6868

69-
export function calendarLinks(node: Node): { googleCalUrl: string; icsContent: string } {
69+
export function calendarLinks(node: Node): { googleCalUrl: string; outlookCalUrl: string; icsContent: string } {
7070
const startDate = toICalDate(node.event_date ?? '');
7171
const endDate = node.event_end_date ? toICalDate(node.event_end_date) : nextDay(node.event_date ?? '');
7272
const location = node.location_tbd
@@ -83,6 +83,16 @@ export function calendarLinks(node: Node): { googleCalUrl: string; icsContent: s
8383
});
8484
const googleCalUrl = `https://calendar.google.com/calendar/render?${params.toString()}`;
8585

86+
// Outlook Web Calendar URL
87+
const outlookParams = new URLSearchParams({
88+
subject: node.event_name,
89+
startdt: node.event_date ?? '',
90+
enddt: node.event_end_date ?? node.event_date ?? '',
91+
body: node.details_text || node.event_short_description,
92+
location,
93+
});
94+
const outlookCalUrl = `https://outlook.live.com/calendar/0/action/compose?${outlookParams.toString()}`;
95+
8696
// ICS content
8797
const now = new Date();
8898
const dtstamp = now.toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z';
@@ -109,7 +119,7 @@ export function calendarLinks(node: Node): { googleCalUrl: string; icsContent: s
109119
'END:VCALENDAR',
110120
].join('\r\n');
111121

112-
return { googleCalUrl, icsContent };
122+
return { googleCalUrl, outlookCalUrl, icsContent };
113123
}
114124

115125
export function formatShortDate(dateStr: string): string {

0 commit comments

Comments
 (0)