diff --git a/app/api/events/$id.mjs b/app/api/events/$id.mjs index 4baf27f..318dcb3 100644 --- a/app/api/events/$id.mjs +++ b/app/api/events/$id.mjs @@ -2,9 +2,10 @@ import events from '../../data/events.json' assert { type: 'json' } import { inflateEvent } from '../events.mjs' export async function get(req) { - let { path } = req + let { path, query } = req const event = events.find(e => e.id === req.params.id) - + let display = "page" + if (query && Object.hasOwn(query, "email")) display = "email" if (!event) { return { statusCode: 404, @@ -24,7 +25,8 @@ export async function get(req) { json: { events: inflatedEvent, sponsors: eventSponsors, - talks: eventTalks + talks: eventTalks, + display } }} -} \ No newline at end of file +} diff --git a/app/pages/events/$id.mjs b/app/pages/events/$id.mjs index d2b5dfb..366149e 100644 --- a/app/pages/events/$id.mjs +++ b/app/pages/events/$id.mjs @@ -3,9 +3,68 @@ import { marked } from "marked" export default function ({ html, state = {} }) { let { store = {} } = state let event = store.events[0] - let { id, title, sponsors, talks, description } = event + let display = store.display + let DEFAULT_LOCATION = "The Collective Seattle, 400 Dexter Ave N, Seattle, WA 98109" + let { + id, + title, + sponsors, + talks, + description, + date, + location=DEFAULT_LOCATION + } = event + let hasTalks = talks && talks.length > 0 let hasSponsors = sponsors && sponsors.length > 0 + if (display === "email") { + let eventDate = new Date(date) + return html` + +
GREETING TEXT
+ + ${hasSponsors ? sponsors.map(s => ` + +Special thanks to our friends at ${s.name} for sponsoring snacks for this month's event! 😎
+ `).join('') : null} +${marked(description)}
` } + `).join('') : null } + +See you all on ${eventDate.toLocaleDateString(undefined, {month: "long", day: "numeric"})}
+