@vermeulen.solutions/eventual 0.18.7 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  <p align="center">
8
8
  <a href="https://github.com/Vermeulen-Solutions/eventual-rsvp-core/actions/workflows/ci.yml"><img src="https://github.com/Vermeulen-Solutions/eventual-rsvp-core/actions/workflows/ci.yml/badge.svg" alt="CI Status" /></a>
9
9
  <a href="https://www.npmjs.com/package/@vermeulen.solutions/eventual"><img src="https://img.shields.io/npm/v/%40vermeulen.solutions%2Feventual?color=176b57&label=npm%20helpers" alt="Latest npm version of the helpers" /></a>
10
- <a href="https://plugins.emdashcms.com/plugins/@vermeulen.solutions/eventual"><img src="https://img.shields.io/badge/EmDash_Registry-0.18.7-0b4d3d" alt="EmDash Plugin Registry" /></a>
10
+ <a href="https://plugins.emdashcms.com/plugins/@vermeulen.solutions/eventual"><img src="https://img.shields.io/badge/EmDash_Registry-0.19.0-0b4d3d" alt="EmDash Plugin Registry" /></a>
11
11
  <a href="https://emdashcms.com"><img src="https://img.shields.io/badge/EmDash-1.2%20to%201.6-0b4d3d" alt="EmDash Compatibility" /></a>
12
12
  <a href="./LICENSE"><img src="https://img.shields.io/badge/License-MIT-d89521" alt="License: MIT" /></a>
13
13
  <img src="https://img.shields.io/badge/TypeScript-strict-3178c6" alt="TypeScript Strict" />
@@ -18,7 +18,7 @@
18
18
 
19
19
  Plan and publish events in [EmDash CMS](https://emdashcms.com). Write announcements, choose venues and organizers, set repeat schedules, and share events through your website and calendar subscriptions.
20
20
 
21
- **Current release: 0.18.7**, the same version on the EmDash Registry and on npm. Events are edited in EmDash's own collections, with rich text, images, drafts and translations. Your site builder connects the feeds to visitor pages; the screenshots below show the optional Astro showcase.
21
+ **Current release: 0.19.0**, the same version on the EmDash Registry and on npm. Events are edited in EmDash's own collections, with rich text, images, drafts and translations. Your site builder adds the visitor pages from the package; the screenshots below show them.
22
22
 
23
23
  In 0.14.x, old events stored inside the plugin are shown only when an administrator explicitly enables **Show old events saved inside the plugin**. Native collections remain authoritative. See [what changed](./docs/release-notes-0.14.0.md).
24
24
 
@@ -49,19 +49,19 @@ Requires **EmDash >=1.2.0 <2.0.0**; tested on 1.2.0, 1.4.0, 1.5.0 and 1.6.0. **1
49
49
  ## Visual Tour
50
50
 
51
51
  ### 1. Website Calendar
52
- Render public events on your site using the included Astro showcase with seven responsive layouts, month navigation, and category filtering—with zero client-side JavaScript.
52
+ Show events on your site with two ready-made Astro pages from the package: an events page with seven views (list, timeline, cards, schedule, date strip, month and locations), month navigation and a category filter, and an event page with calendar buttons. They come in 21 languages, in light and dark, and without client-side JavaScript; see [Event pages](./docs/developer-guide.md#event-pages).
53
53
 
54
54
  <p align="center">
55
- <img src="./images/registry-0.11.0/05-public-events.jpg" alt="Public Event Browser" width="90%" />
55
+ <img src="./images/registry-0.19.0/event-pages-list.png" alt="The events page in the list view" width="90%" />
56
56
  </p>
57
57
 
58
58
  ---
59
59
 
60
60
  ### 2. Event Details & One-Click Calendar Sync
61
- Visitors can view full event details, join virtual meetings, get venue directions, and add events to Google Calendar, Outlook, Yahoo, or Apple Calendar.
61
+ Visitors can view full event details, join virtual meetings, get venue directions, and add events to Google Calendar, Outlook, Office 365 or any calendar app (iCal file).
62
62
 
63
63
  <p align="center">
64
- <img src="./images/registry-0.13.4/public-event-detail-fr-desktop.png" alt="Public event detail view" width="90%" />
64
+ <img src="./images/registry-0.19.0/event-page-detail.png" alt="An event page with date, place and calendar buttons" width="90%" />
65
65
  </p>
66
66
 
67
67
  ---
@@ -108,7 +108,7 @@ npm install @vermeulen.solutions/eventual
108
108
 
109
109
  Keep its version the same as the Registry backend. **Do not run `npm install eventual`:** the unscoped name is an unrelated package by another author.
110
110
 
111
- Use the **installed plugin ID** in API URLs and MCP tool names. A config-managed site uses `eventual`; a Registry install gets a generated ID that starts with `r_`. The **Subscribe** links on the Eventual RSVP admin page show it. Pass it as `pluginId` to `fetchPublicFeed`, and as `EVENTUAL_PLUGIN_ID` to the showcase. Install the backend one way only, from the Registry or from the config: the [developer guide](./docs/developer-guide.md#installation-and-plugin-id) explains what goes wrong otherwise, and [what to do before moving a site to the Registry](./docs/developer-guide.md#moving-a-site-from-the-config-to-the-registry).
111
+ Use the **installed plugin ID** in API URLs and MCP tool names. A config-managed site uses `eventual`; a Registry install gets a generated ID that starts with `r_`. The **Subscribe** links on the Eventual RSVP admin page show it. Pass it as `pluginId` to `fetchPublicFeed`, and to the event page loaders. Install the backend one way only, from the Registry or from the config: the [developer guide](./docs/developer-guide.md#installation-and-plugin-id) explains what goes wrong otherwise, and [what to do before moving a site to the Registry](./docs/developer-guide.md#moving-a-site-from-the-config-to-the-registry).
112
112
 
113
113
  The [developer guide](./docs/developer-guide.md) covers public JSON/ICS/image routes, SSR dispatch, tool names, settings, transfer formats, permissions and sandbox limits. It also explains installing the matching npm helpers. Eventual RSVP's MCP tools inspect native data; native edits and publication use EmDash's core tools.
114
114
 
@@ -134,8 +134,8 @@ The backend shares EmDash's sandbox call budget: the public feeds use up to 30 c
134
134
  - [Install and connect](./docs/collection-setup.md) — administrators and schema setup.
135
135
  - [Upgrade and migrate](./docs/upgrade-0.13.0.md) — existing sites and old plugin data.
136
136
  - [Developer guide](./docs/developer-guide.md) — integration and API reference.
137
- - [Changelog](./CHANGELOG.md) · [0.18.7 release notes](./docs/release-notes-0.18.7.md) · [0.18.6 release notes](./docs/release-notes-0.18.6.md) · [0.18.5 release notes](./docs/release-notes-0.18.5.md) · [0.15.0 cache integration](./docs/release-notes-0.15.0.md) · [0.14.0 native collections](./docs/release-notes-0.14.0.md).
138
- - [Astro showcase](./examples/astro-events/README.md) — optional visitor pages.
137
+ - [Changelog](./CHANGELOG.md) · [0.19.0 release notes](./docs/release-notes-0.19.0.md) · [0.18.7 release notes](./docs/release-notes-0.18.7.md) · [0.18.6 release notes](./docs/release-notes-0.18.6.md) · [0.18.5 release notes](./docs/release-notes-0.18.5.md) · [0.15.0 cache integration](./docs/release-notes-0.15.0.md) · [0.14.0 native collections](./docs/release-notes-0.14.0.md).
138
+ - [Astro example site](./examples/astro-events/README.md) — the event pages in a small site.
139
139
  - [Release evidence and older records](./docs/history.md).
140
140
 
141
141
  ---
@@ -0,0 +1,261 @@
1
+ ---
2
+ /**
3
+ * The events page body: view switch, month navigation, category filter and one of seven views.
4
+ * Render it inside your own layout with data from `loadEventBrowser` (which also gives the HTTP
5
+ * status and the page title). Styles: ./parts/Styles.astro, in the `eventual` cascade layer.
6
+ */
7
+ import type { EventBrowserData } from "./index";
8
+ import { eventHref } from "./index";
9
+ import { eventTimeParts } from "./grid";
10
+ import AgendaItem from "./parts/AgendaItem.astro";
11
+ import DateTile from "./parts/DateTile.astro";
12
+ import EventCard from "./parts/EventCard.astro";
13
+ import Icon from "./parts/Icon.astro";
14
+ import StatusBadge from "./parts/StatusBadge.astro";
15
+ import Styles from "./parts/Styles.astro";
16
+
17
+ interface Props {
18
+ data: EventBrowserData;
19
+ /** Level of the page heading (1 on an events page, 2 inside another page). */
20
+ headingLevel?: 1 | 2;
21
+ /** Page heading; default "Events in <month>". */
22
+ title?: string;
23
+ /** Text under the heading; false for none. */
24
+ intro?: string | false;
25
+ /** ID of the root element (a target for skip links). */
26
+ id?: string;
27
+ /** Colour scheme of this block; default: the page's. */
28
+ scheme?: "light" | "dark" | "light dark";
29
+ showFilter?: boolean;
30
+ showViewSwitch?: boolean;
31
+ class?: string;
32
+ }
33
+
34
+ const { data, headingLevel = 1, title, intro, id = "eventual-events", scheme, showFilter = true, showViewSwitch = true, class: className } = Astro.props;
35
+ const { text, state, locale } = data;
36
+ const H1 = `h${headingLevel}` as "h1";
37
+ const H2 = `h${headingLevel + 1}` as "h2";
38
+ const H3 = `h${headingLevel + 2}` as "h3";
39
+ const level3 = headingLevel + 2;
40
+ const fullDate = new Intl.DateTimeFormat(locale, { dateStyle: "full", timeZone: "UTC" });
41
+ const count = data.events.length;
42
+ const dots = (n: number) => Array.from({ length: Math.min(n, 3) });
43
+ const filterCategories = state.category && !data.categories.includes(state.category) ? [state.category, ...data.categories] : data.categories;
44
+ const viewHeading = state.view === "month" || state.view === "list" || state.view === "cards" || state.view === "dates"
45
+ ? text.month.events(data.monthTitle)
46
+ : `${text.views[state.view]}: ${data.monthTitle}`;
47
+ ---
48
+
49
+ <Styles />
50
+ <section id={id} class:list={["eventual-browser", className]} lang={data.lang} dir={data.dir} style={scheme ? `color-scheme: ${scheme}` : undefined} aria-labelledby={`${id}-title`}>
51
+ <header class="eventual-browser__header">
52
+ <H1 id={`${id}-title`} class="eventual-browser__title">{title ?? text.month.events(data.monthTitle)}</H1>
53
+ {intro !== false && <p class="eventual-browser__intro">{intro ?? text.intro}</p>}
54
+ </header>
55
+
56
+ <div class="eventual-controls">
57
+ {showViewSwitch && data.views.length > 1 && (
58
+ <nav class="eventual-views" aria-label={text.views.label}>
59
+ <ul>
60
+ {data.views.map((item) => <li><a href={item.href} aria-current={item.current ? "page" : undefined}><span>{item.label}</span></a></li>)}
61
+ </ul>
62
+ </nav>
63
+ )}
64
+ <div class="eventual-toolbar">
65
+ <nav class="eventual-months" aria-label={text.month.navigation}>
66
+ <span class="eventual-months__step">
67
+ <a class="eventual-button eventual-button--icon" href={data.previous.href}><Icon name="chevron-left" /><span class="eventual-sr-only">{data.previous.label}</span></a>
68
+ <a class="eventual-button eventual-button--icon" href={data.next.href}><Icon name="chevron-right" /><span class="eventual-sr-only">{data.next.label}</span></a>
69
+ </span>
70
+ <a class="eventual-button" href={data.current.href} aria-current={data.current.isCurrent ? "date" : undefined}>{data.current.label}</a>
71
+ </nav>
72
+ {showFilter && (
73
+ <form method="get" class="eventual-filter">
74
+ <input type="hidden" name="month" value={state.month} />
75
+ <input type="hidden" name="view" value={state.view} />
76
+ <label for={`${id}-category`}>{text.filter.label}</label>
77
+ <span class="eventual-select">
78
+ <select id={`${id}-category`} name="category">
79
+ <option value="">{text.filter.all}</option>
80
+ {filterCategories.map((category) => <option value={category} selected={category === state.category}>{category}</option>)}
81
+ </select>
82
+ <Icon name="chevron-down" />
83
+ </span>
84
+ <button type="submit" class="eventual-button">{text.filter.apply}</button>
85
+ </form>
86
+ )}
87
+ </div>
88
+ <p class="eventual-summary">
89
+ <span>{text.count(count)}</span>
90
+ {state.category && <><span aria-hidden="true">·</span><span>{text.filter.active(state.category)}</span><a href={data.clearHref}>{text.filter.clear}</a></>}
91
+ </p>
92
+ </div>
93
+
94
+ {data.status === 502 ? (
95
+ <div class="eventual-notice eventual-notice--error" role="alert">
96
+ <H2>{text.notice.unavailable}</H2>
97
+ <p>{text.notice.unavailableDetail}</p>
98
+ <p><a class="eventual-button" href={data.views.find((item) => item.current)?.href ?? "?"}>{text.notice.tryAgain}</a></p>
99
+ </div>
100
+ ) : count === 0 ? (
101
+ <div class="eventual-notice">
102
+ <Icon name="calendar" class="eventual-notice__icon" />
103
+ <H2>{state.category ? text.notice.emptyFiltered : text.notice.empty}</H2>
104
+ {state.category && <p><a href={data.clearHref}>{text.filter.clear}</a></p>}
105
+ </div>
106
+ ) : (
107
+ <section class={`eventual-view eventual-view--${state.view}`} aria-labelledby={`${id}-view`}>
108
+ <H2 id={`${id}-view`} class="eventual-sr-only">{viewHeading}</H2>
109
+
110
+ {state.view === "list" && (
111
+ <ul class="eventual-stack">
112
+ {data.events.map((event) => <li><AgendaItem event={event} data={data} level={level3} /></li>)}
113
+ </ul>
114
+ )}
115
+
116
+ {state.view === "timeline" && (
117
+ <ol class="eventual-timeline">
118
+ {data.dateGroups.map((group) => (
119
+ <li class="eventual-timeline__day">
120
+ <H3 class="eventual-timeline__date"><DateTile date={group.date} locale={locale} labelled={false} /><span class="eventual-sr-only">{group.label}</span></H3>
121
+ <span class="eventual-timeline__dot" aria-hidden="true"></span>
122
+ <ul class="eventual-stack eventual-timeline__events">
123
+ {group.events.map((event) => <li><EventCard event={event} data={data} level={level3 + 1} variant="timeline" /></li>)}
124
+ </ul>
125
+ </li>
126
+ ))}
127
+ </ol>
128
+ )}
129
+
130
+ {state.view === "cards" && (
131
+ <ul class="eventual-grid">
132
+ {data.events.map((event) => <li><EventCard event={event} data={data} level={level3} /></li>)}
133
+ </ul>
134
+ )}
135
+
136
+ {state.view === "schedule" && (
137
+ <ul class="eventual-stack">
138
+ {data.dateGroups.map((group, index) => (
139
+ <li>
140
+ <details class="eventual-day" open={index === 0}>
141
+ <summary>
142
+ <DateTile date={group.date} locale={locale} layout="short" labelled={false} />
143
+ <span class="eventual-day__text">
144
+ <span class="eventual-day__label">{group.label}</span>
145
+ <span class="eventual-day__count">{text.count(group.events.length)}</span>
146
+ </span>
147
+ <Icon name="chevron-down" class="eventual-day__chevron" />
148
+ </summary>
149
+ <ul class="eventual-rows">
150
+ {group.events.map((event) => <li><AgendaItem event={event} data={data} level={level3} showDate={false} compact /></li>)}
151
+ </ul>
152
+ </details>
153
+ </li>
154
+ ))}
155
+ </ul>
156
+ )}
157
+
158
+ {state.view === "dates" && (
159
+ <>
160
+ <nav class="eventual-datestrip" aria-label={text.dates.jump}>
161
+ <ul>
162
+ {data.dateGroups.map((group) => (
163
+ <li>
164
+ <a href={`#${group.id}`}>
165
+ <span class="eventual-datestrip__weekday" aria-hidden="true">{group.weekday}</span>
166
+ <span class="eventual-datestrip__day" aria-hidden="true">{group.day}</span>
167
+ <span class="eventual-datestrip__dots" aria-hidden="true">{dots(group.events.length).map(() => <i></i>)}</span>
168
+ <span class="eventual-sr-only">{group.label}</span>
169
+ </a>
170
+ </li>
171
+ ))}
172
+ </ul>
173
+ </nav>
174
+ {data.dateGroups.map((group) => (
175
+ <section class="eventual-group" id={group.id} tabindex="-1" aria-labelledby={`${group.id}-title`}>
176
+ <header class="eventual-group__header">
177
+ <DateTile date={group.date} locale={locale} layout="short" labelled={false} />
178
+ <H3 id={`${group.id}-title`} class="eventual-group__title">{group.label}</H3>
179
+ <span class="eventual-group__count">{text.count(group.events.length)}</span>
180
+ </header>
181
+ <ul class="eventual-rows">
182
+ {group.events.map((event) => <li><AgendaItem event={event} data={data} level={level3 + 1} showDate={false} compact /></li>)}
183
+ </ul>
184
+ </section>
185
+ ))}
186
+ </>
187
+ )}
188
+
189
+ {state.view === "locations" && data.locationGroups.map((group, index) => (
190
+ <section class="eventual-group eventual-group--place" aria-labelledby={`${id}-place-${index}`}>
191
+ <header class="eventual-group__header">
192
+ <span class="eventual-group__icon"><Icon name="pin" /></span>
193
+ <H3 id={`${id}-place-${index}`} class="eventual-group__title">{group.location}</H3>
194
+ {group.directionsUrl
195
+ ? <a class="eventual-group__link" href={group.directionsUrl} target="_blank" rel="noopener noreferrer">{text.event.directions}<Icon name="external" /><span class="eventual-sr-only"> {text.newTab}</span></a>
196
+ : <span class="eventual-group__count">{text.count(group.events.length)}</span>}
197
+ </header>
198
+ <ul class="eventual-rows">
199
+ {group.events.map((event) => <li><AgendaItem event={event} data={data} level={level3 + 1} compact showPlace={false} /></li>)}
200
+ </ul>
201
+ </section>
202
+ ))}
203
+
204
+ {state.view === "month" && (
205
+ <>
206
+ <div class="eventual-month-frame">
207
+ <table class="eventual-month">
208
+ <caption class="eventual-sr-only">{viewHeading}</caption>
209
+ <thead>
210
+ <tr>{data.weekdays.short.map((day, index) => <th scope="col"><span aria-hidden="true">{day}</span><span class="eventual-sr-only">{data.weekdays.long[index]}</span></th>)}</tr>
211
+ </thead>
212
+ <tbody>
213
+ {data.weeks.map((week) => (
214
+ <tr>
215
+ {week.map((cell) => (
216
+ <td class:list={["eventual-month__day", !cell.inMonth && "eventual-month__day--outside", cell.date === data.today && "eventual-month__day--today"]}>
217
+ <time class="eventual-month__number" datetime={cell.date} aria-current={cell.date === data.today ? "date" : undefined}>
218
+ <span aria-hidden="true">{cell.dayNumber}</span><span class="eventual-sr-only">{fullDate.format(new Date(`${cell.date}T12:00:00Z`))}</span>
219
+ </time>
220
+ {cell.events.length > 0 && (
221
+ <ul class="eventual-month__events">
222
+ {cell.events.map((event) => (
223
+ <li class:list={[event.status === "cancelled" && "eventual-is-cancelled"]}>
224
+ <a href={eventHref(event, data)}>
225
+ <span class="eventual-month__time">{event.allDay ? text.event.allDay : eventTimeParts(event, locale)?.start}</span>
226
+ <span class="eventual-month__name">{event.title}</span>
227
+ </a>
228
+ <StatusBadge event={event} text={text} locale={locale} />
229
+ </li>
230
+ ))}
231
+ </ul>
232
+ )}
233
+ </td>
234
+ ))}
235
+ </tr>
236
+ ))}
237
+ </tbody>
238
+ </table>
239
+ </div>
240
+ <div class="eventual-month-list" data-narrow-month>
241
+ {data.dateGroups.map((group) => (
242
+ <section class="eventual-group" aria-labelledby={`${group.id}-m`}>
243
+ <header class="eventual-group__header">
244
+ <DateTile date={group.date} locale={locale} layout="short" labelled={false} />
245
+ <H3 id={`${group.id}-m`} class="eventual-group__title">{group.label}</H3>
246
+ </header>
247
+ <ul class="eventual-rows">
248
+ {group.events.map((event) => <li><AgendaItem event={event} data={data} level={level3 + 1} showDate={false} compact /></li>)}
249
+ </ul>
250
+ </section>
251
+ ))}
252
+ </div>
253
+ </>
254
+ )}
255
+ </section>
256
+ )}
257
+
258
+ {data.subscriptionUrl && (
259
+ <p class="eventual-subscribe"><Icon name="rss" /><a href={data.subscriptionUrl}>{text.calendar.subscribe}</a></p>
260
+ )}
261
+ </section>
@@ -0,0 +1,113 @@
1
+ ---
2
+ /**
3
+ * An event's page body. Render it inside your own layout with data from `loadEventDetail`
4
+ * (which also gives the HTTP status, the title and the description for the head). Anything
5
+ * passed as children (for example RsvpForm or TicketCheckout) appears after the description.
6
+ */
7
+ import type { EventDetailData } from "./index";
8
+ import Icon from "./parts/Icon.astro";
9
+ import StatusBadge from "./parts/StatusBadge.astro";
10
+ import Styles from "./parts/Styles.astro";
11
+
12
+ interface Props {
13
+ data: EventDetailData;
14
+ headingLevel?: 1 | 2;
15
+ /** Link back to the events page; false for none. */
16
+ backHref?: string | false;
17
+ showSubscribe?: boolean;
18
+ /** Structured data for search engines (Event JSON-LD). */
19
+ jsonLd?: boolean;
20
+ scheme?: "light" | "dark" | "light dark";
21
+ class?: string;
22
+ }
23
+
24
+ const { data, headingLevel = 1, backHref = data.backHref, showSubscribe = true, jsonLd = true, scheme, class: className } = Astro.props;
25
+ const { text, event, locale } = data;
26
+ const H1 = `h${headingLevel}` as "h1";
27
+ const H2 = `h${headingLevel + 1}` as "h2";
28
+ const links = data.calendarLinks;
29
+ const contentLang = event?.locale && event.locale.split("-")[0] !== data.lang.split("-")[0] ? event.locale : undefined;
30
+ const newTab = { target: "_blank", rel: "noopener noreferrer" };
31
+ ---
32
+
33
+ <Styles />
34
+ <article class:list={["eventual-detail", className, event?.status === "cancelled" && "eventual-is-cancelled"]} lang={data.lang} dir={data.dir} style={scheme ? `color-scheme: ${scheme}` : undefined}>
35
+ {backHref && <p class="eventual-detail__back"><a href={backHref}><Icon name="chevron-left" />{text.event.back}</a></p>}
36
+
37
+ {data.status === 502 ? (
38
+ <div class="eventual-notice eventual-notice--error" role="alert">
39
+ <H1>{text.notice.unavailable}</H1>
40
+ <p>{text.notice.unavailableDetail}</p>
41
+ </div>
42
+ ) : !event ? (
43
+ <div class="eventual-notice">
44
+ <Icon name="calendar" class="eventual-notice__icon" />
45
+ <H1>{text.event.details}</H1>
46
+ <p>{text.notice.notFound}</p>
47
+ </div>
48
+ ) : (
49
+ <>
50
+ <header class="eventual-detail__header" lang={contentLang}>
51
+ <StatusBadge event={event} text={text} locale={locale} />
52
+ <H1 class="eventual-detail__title">{event.title}</H1>
53
+ </header>
54
+
55
+ <div class="eventual-detail__layout">
56
+ <div class="eventual-detail__panel">
57
+ <ul class="eventual-facts">
58
+ <li>
59
+ <Icon name="calendar" />
60
+ <span><time class="eventual-facts__strong" datetime={event.start}>{data.dateText}</time>{data.timeText && <span class="eventual-facts__line">{data.timeText}</span>}</span>
61
+ </li>
62
+ {event.location && (
63
+ <li>
64
+ <Icon name="pin" />
65
+ <span>
66
+ <span class="eventual-facts__strong">{event.location}</span>
67
+ {data.directionsUrl && <a class="eventual-facts__line" href={data.directionsUrl} {...newTab}>{text.event.directions}<Icon name="external" /><span class="eventual-sr-only"> {text.newTab}</span></a>}
68
+ </span>
69
+ </li>
70
+ )}
71
+ {event.organizer && <li><Icon name="user" /><span>{text.event.organizer(event.organizer)}</span></li>}
72
+ {data.websiteUrl && <li><Icon name="globe" /><a href={data.websiteUrl} {...newTab}>{text.event.website}<Icon name="external" /><span class="eventual-sr-only"> {text.newTab}</span></a></li>}
73
+ </ul>
74
+
75
+ <ul class="eventual-detail__actions">
76
+ {links && (
77
+ <li>
78
+ <details class="eventual-calmenu">
79
+ <summary class="eventual-button eventual-button--primary"><Icon name="calendar-plus" />{text.calendar.add}<Icon name="chevron-down" class="eventual-calmenu__chevron" /></summary>
80
+ <ul class="eventual-calmenu__options" aria-label={text.calendar.addFor(event.title)}>
81
+ <li><a href={links.google} {...newTab}>{text.calendar.google}<span class="eventual-sr-only"> {text.newTab}</span></a></li>
82
+ <li><a href={links.outlook} {...newTab}>{text.calendar.outlook}<span class="eventual-sr-only"> {text.newTab}</span></a></li>
83
+ <li><a href={links.office365} {...newTab}>{text.calendar.office365}<span class="eventual-sr-only"> {text.newTab}</span></a></li>
84
+ <li><a href={links.ics} download>{text.calendar.ics}</a></li>
85
+ </ul>
86
+ </details>
87
+ </li>
88
+ )}
89
+ {data.onlineUrl && <li><a class="eventual-button" href={data.onlineUrl} {...newTab}>{text.event.joinOnline}<Icon name="external" /><span class="eventual-sr-only"> {text.newTab}</span></a></li>}
90
+ {showSubscribe && data.subscriptionUrl && <li><a class="eventual-button eventual-button--quiet" href={data.subscriptionUrl}><Icon name="rss" />{text.calendar.subscribe}</a></li>}
91
+ </ul>
92
+ </div>
93
+
94
+ <div class="eventual-detail__main">
95
+ {data.imageUrl && <img class="eventual-detail__image" src={data.imageUrl} alt={event.imageMedia?.alt ?? ""} width={event.imageMedia?.width} height={event.imageMedia?.height} decoding="async" />}
96
+
97
+ {data.descriptionHtml && <div class="eventual-detail__description" lang={contentLang} set:html={data.descriptionHtml} />}
98
+
99
+ {event.categories.length > 0 && (
100
+ <section class="eventual-detail__categories" aria-labelledby="eventual-detail-categories">
101
+ <H2 id="eventual-detail-categories" class="eventual-sr-only">{text.event.categories}</H2>
102
+ <ul class="eventual-tags">{event.categories.map((category) => <li><Icon name="tag" />{category}</li>)}</ul>
103
+ </section>
104
+ )}
105
+
106
+ <slot />
107
+ </div>
108
+ </div>
109
+
110
+ {jsonLd && data.jsonLd && <script type="application/ld+json" set:html={data.jsonLd} />}
111
+ </>
112
+ )}
113
+ </article>
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Event descriptions as safe HTML. Native events carry Portable Text (`descriptionBlocks`);
3
+ * older or imported events carry plain text, rendered with the showcase's small markdown subset.
4
+ * Everything is escaped; only http(s) and mailto links survive, and they open in a new tab.
5
+ */
6
+
7
+ interface Span { _type?: string; text?: string; marks?: string[] }
8
+ interface MarkDef { _key: string; _type: string; href?: string }
9
+ interface Block { _type?: string; style?: string; listItem?: string; level?: number; children?: Span[]; markDefs?: MarkDef[] }
10
+
11
+ export interface DescriptionOptions {
12
+ /** Level for the description's top headings (default 2). */
13
+ headingBase?: number;
14
+ /** Visually hidden text after links that open a new tab, in the page language. */
15
+ newTabText?: string;
16
+ }
17
+
18
+ /** HTML for a description: Portable Text when present, else plain text with light markdown. */
19
+ export function descriptionHtml(blocks: unknown[] | undefined, text: string, options: DescriptionOptions = {}): string {
20
+ return Array.isArray(blocks) && blocks.length ? portableTextHtml(blocks, options) : markdownHtml(text, options);
21
+ }
22
+
23
+ /** A plain one-paragraph excerpt for lists and cards. */
24
+ export function descriptionExcerpt(source: string, limit = 180): string {
25
+ const plain = source
26
+ .replace(/<[^>]*>/g, " ")
27
+ .replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
28
+ .replace(/(^|\s)#{1,3}\s+/g, "$1")
29
+ .replace(/\*\*|__|[*_]/g, "")
30
+ .replace(/(^|\s)[-*]\s+/g, "$1")
31
+ .replace(/\s+/g, " ")
32
+ .trim();
33
+ if (plain.length <= limit) return plain;
34
+ const cut = plain.slice(0, limit + 1);
35
+ const boundary = cut.lastIndexOf(" ");
36
+ return `${cut.slice(0, boundary > limit * 0.7 ? boundary : limit).trimEnd()}…`;
37
+ }
38
+
39
+ export function portableTextHtml(blocks: unknown[], options: DescriptionOptions = {}): string {
40
+ const base = clampHeading(options.headingBase ?? 2);
41
+ const out: string[] = [];
42
+ let list: { tag: "ul" | "ol"; items: string[] } | null = null;
43
+ const flush = () => {
44
+ if (list) out.push(`<${list.tag}>${list.items.map((item) => `<li>${item}</li>`).join("")}</${list.tag}>`);
45
+ list = null;
46
+ };
47
+ for (const raw of blocks) {
48
+ if (!raw || typeof raw !== "object") continue;
49
+ const block = raw as Block;
50
+ if (block._type && block._type !== "block") continue;
51
+ const inline = renderSpans(block.children ?? [], block.markDefs ?? [], options);
52
+ if (block.listItem) {
53
+ const tag = block.listItem === "number" ? "ol" : "ul";
54
+ if (!list || list.tag !== tag) {
55
+ flush();
56
+ list = { tag, items: [] };
57
+ }
58
+ list.items.push(inline);
59
+ continue;
60
+ }
61
+ flush();
62
+ if (!inline.trim()) continue;
63
+ const heading = /^h([1-6])$/.exec(block.style ?? "");
64
+ if (heading) {
65
+ const level = clampHeading(base + Math.max(0, Number(heading[1]) - 2));
66
+ out.push(`<h${level}>${inline}</h${level}>`);
67
+ } else if (block.style === "blockquote") out.push(`<blockquote><p>${inline}</p></blockquote>`);
68
+ else out.push(`<p>${inline}</p>`);
69
+ }
70
+ flush();
71
+ return out.join("");
72
+ }
73
+
74
+ function renderSpans(spans: Span[], markDefs: MarkDef[], options: DescriptionOptions): string {
75
+ return spans
76
+ .map((span) => {
77
+ if (!span || typeof span.text !== "string") return "";
78
+ let html = escapeHtml(span.text).replace(/\n/g, "<br>");
79
+ for (const mark of span.marks ?? []) {
80
+ if (mark === "strong") html = `<strong>${html}</strong>`;
81
+ else if (mark === "em") html = `<em>${html}</em>`;
82
+ else if (mark === "code") html = `<code>${html}</code>`;
83
+ else {
84
+ const def = markDefs.find((item) => item._key === mark);
85
+ const href = def?._type === "link" ? safeLink(def.href ?? "") : "";
86
+ if (href) html = linkHtml(href, html, options);
87
+ }
88
+ }
89
+ return html;
90
+ })
91
+ .join("");
92
+ }
93
+
94
+ export function markdownHtml(source: string, options: DescriptionOptions = {}): string {
95
+ const base = clampHeading(options.headingBase ?? 2);
96
+ const lines = source.replace(/\r\n?/g, "\n").split("\n");
97
+ const blocks: string[] = [];
98
+ let paragraph: string[] = [];
99
+ let list: string[] = [];
100
+ const flushParagraph = () => {
101
+ if (paragraph.length) blocks.push(`<p>${renderInline(paragraph.join(" ").trim(), options)}</p>`);
102
+ paragraph = [];
103
+ };
104
+ const flushList = () => {
105
+ if (list.length) blocks.push(`<ul>${list.map((item) => `<li>${renderInline(item, options)}</li>`).join("")}</ul>`);
106
+ list = [];
107
+ };
108
+ for (const line of lines) {
109
+ const heading = line.match(/^\s{0,3}(#{1,3})\s+(.+?)\s*$/);
110
+ const item = line.match(/^\s*[-*]\s+(.+?)\s*$/);
111
+ if (!line.trim()) {
112
+ flushParagraph();
113
+ flushList();
114
+ } else if (heading) {
115
+ flushParagraph();
116
+ flushList();
117
+ // Same mapping as Portable Text: # and ## are the top level, ### one below.
118
+ const level = clampHeading(base + Math.max(0, heading[1]!.length - 2));
119
+ blocks.push(`<h${level}>${renderInline(heading[2]!, options)}</h${level}>`);
120
+ } else if (item) {
121
+ flushParagraph();
122
+ list.push(item[1]!);
123
+ } else {
124
+ flushList();
125
+ paragraph.push(line.trim());
126
+ }
127
+ }
128
+ flushParagraph();
129
+ flushList();
130
+ return blocks.join("");
131
+ }
132
+
133
+ function renderInline(source: string, options: DescriptionOptions): string {
134
+ let html = "";
135
+ let index = 0;
136
+ while (index < source.length) {
137
+ const rest = source.slice(index);
138
+ const link = rest.match(/^\[([^\]]+)\]\(([^)]+)\)/);
139
+ if (link) {
140
+ const href = safeLink(link[2]!);
141
+ html += href ? linkHtml(href, renderInline(link[1]!, options), options) : escapeHtml(link[0]);
142
+ index += link[0].length;
143
+ continue;
144
+ }
145
+ const strong = rest.match(/^\*\*(.+?)\*\*/);
146
+ if (strong) {
147
+ html += `<strong>${renderInline(strong[1]!, options)}</strong>`;
148
+ index += strong[0].length;
149
+ continue;
150
+ }
151
+ const emphasis = rest.match(/^_([^_]+?)_/);
152
+ if (emphasis) {
153
+ html += `<em>${renderInline(emphasis[1]!, options)}</em>`;
154
+ index += emphasis[0].length;
155
+ continue;
156
+ }
157
+ html += escapeHtml(source[index]!);
158
+ index += 1;
159
+ }
160
+ return html;
161
+ }
162
+
163
+ function linkHtml(href: string, inner: string, options: DescriptionOptions): string {
164
+ const hint = options.newTabText ? `<span class="eventual-sr-only"> ${escapeHtml(options.newTabText)}</span>` : "";
165
+ return `<a href="${escapeHtml(href)}" target="_blank" rel="noopener noreferrer">${inner}${hint}</a>`;
166
+ }
167
+
168
+ function safeLink(value: string): string {
169
+ try {
170
+ const url = new URL(value);
171
+ return url.protocol === "http:" || url.protocol === "https:" || url.protocol === "mailto:" ? url.href : "";
172
+ } catch {
173
+ return "";
174
+ }
175
+ }
176
+
177
+ function clampHeading(level: number): number {
178
+ return Math.min(6, Math.max(2, Math.round(level)));
179
+ }
180
+
181
+ export function escapeHtml(value: string): string {
182
+ return value.replace(/[&<>"']/g, (character) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[character]!);
183
+ }