diff --git a/app/api/events/$id.mjs b/app/api/events/$id.mjs index 544c6c0..318dcb3 100644 --- a/app/api/events/$id.mjs +++ b/app/api/events/$id.mjs @@ -1,11 +1,11 @@ import events from '../../data/events.json' assert { type: 'json' } -import { inflateEvent } from '../events.mjs' +import { inflateEvent } from '../events.mjs' export async function get(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' + let display = "page" + if (query && Object.hasOwn(query, "email")) display = "email" if (!event) { return { statusCode: 404, @@ -15,19 +15,18 @@ export async function get(req) { } } } else { - // We have to convert event from an object to an array to inflate it - let inflatedEvent = [event].map(inflateEvent) - let eventSponsors = event.sponsors - let eventTalks = event.talks + // We have to convert event from an object to an array to inflate it + let inflatedEvent = [event].map(inflateEvent) + let eventSponsors = event.sponsors + let eventTalks = event.talks - // In event/$id we are reusing the element which expects a list of events - return { - json: { - events: inflatedEvent, - sponsors: eventSponsors, - talks: eventTalks, - display - } + // In event/$id we are reusing the element which expects a list of events + return { + json: { + events: inflatedEvent, + sponsors: eventSponsors, + talks: eventTalks, + display } - } + }} } diff --git a/app/pages/events/$id.mjs b/app/pages/events/$id.mjs index 91ed188..470bc59 100644 --- a/app/pages/events/$id.mjs +++ b/app/pages/events/$id.mjs @@ -1,4 +1,4 @@ -import { marked } from 'marked' +import { marked } from "marked" export default function ({ html, state = {} }) { let { store = {} } = state @@ -7,60 +7,31 @@ export default function ({ html, state = {} }) { let { id, title, sponsors, talks, description, date } = event let hasTalks = talks && talks.length > 0 let hasSponsors = sponsors && sponsors.length > 0 - if (display === 'email') { + if (display === "email") { let eventDate = new Date(date) let htmlContents = `

GREETING TEXT

- ${ - hasSponsors - ? sponsors - .map( - s => ` + ${hasSponsors ? sponsors.map(s => `

${s.name} logo

Special thanks to our friends at ${s.name} for sponsoring snacks for this month's event! 😎

- ` - ) - .join('') - : null - } + `).join('') : null} - ${ - hasTalks - ? talks - .map( - t => ` -

${ - t.title - } by ${t.speaker.name}

-

${
-            t.name
-          }

- ${description && `

${marked(description)}

`} - ` - ) - .join('') - : null - } + ${hasTalks ? talks.map(t => ` +

${t.title} by ${t.speaker.name}

+

${t.name}

+ ${description && `

${marked(description)}

` } + `).join('') : null } -

See you all on ${eventDate.toLocaleDateString(undefined, { - month: 'long', - day: 'numeric' - })}

+

See you all on ${eventDate.toLocaleDateString(undefined, {month: "long", day: "numeric"})}

` return html`