diff --git a/src/lib/cards/social/EventCard/index.ts b/src/lib/cards/social/EventCard/index.ts index 3df1db7..caba18d 100644 --- a/src/lib/cards/social/EventCard/index.ts +++ b/src/lib/cards/social/EventCard/index.ts @@ -1,8 +1,6 @@ -import { parseUri, getRecord } from '$lib/atproto'; import type { CardDefinition } from '../../types'; import CreateEventCardModal from './CreateEventCardModal.svelte'; import EventCard from './EventCard.svelte'; -import type { Did } from '@atcute/lexicons'; const EVENT_COLLECTION = 'community.lexicon.calendar.event'; @@ -58,35 +56,20 @@ export const EventCardDefinition = { card.mobileH = 6; }, - loadData: async (items) => { - const eventDataMap: Record = {}; - - for (const item of items) { - const uri = item.cardData?.uri; - if (!uri) continue; - - const parsedUri = parseUri(uri); - if (!parsedUri || !parsedUri.rkey || !parsedUri.repo) continue; - - try { - const record = await getRecord({ - did: parsedUri.repo as Did, - collection: EVENT_COLLECTION, - rkey: parsedUri.rkey - }); - - if (record?.value) { - eventDataMap[item.id] = record.value as EventData; - } - } catch (error) { - console.error('Failed to fetch event data:', error); - } + onUrlHandler: (url, item) => { + // Match atmo.rsvp URLs: https://atmo.rsvp/p/{didOrHandle}/e/{rkey} + const atmoMatch = url.match(/^https?:\/\/atmo\.rsvp\/p\/([^/]+)\/e\/([^/?#]+)/); + if (atmoMatch) { + const [, repo, rkey] = atmoMatch; + item.w = 4; + item.h = 4; + item.mobileW = 8; + item.mobileH = 6; + item.cardType = 'event'; + item.cardData.uri = `at://${repo}/${EVENT_COLLECTION}/${rkey}`; + return item; } - return eventDataMap; - }, - - onUrlHandler: (url, item) => { // Match smokesignal.events URLs: https://smokesignal.events/{did}/{rkey} const smokesignalMatch = url.match(/^https?:\/\/smokesignal\.events\/(did:[^/]+)\/([^/?#]+)/); if (smokesignalMatch) { @@ -100,17 +83,17 @@ export const EventCardDefinition = { return item; } - // Match AT URIs: at://{did}/community.lexicon.calendar.event/{rkey} - const atUriMatch = url.match(/^at:\/\/(did:[^/]+)\/([^/]+)\/([^/?#]+)/); + // Match AT URIs: at://{didOrHandle}/community.lexicon.calendar.event/{rkey} + const atUriMatch = url.match(/^at:\/\/([^/]+)\/([^/]+)\/([^/?#]+)/); if (atUriMatch) { - const [, did, collection, rkey] = atUriMatch; + const [, repo, collection, rkey] = atUriMatch; if (collection === EVENT_COLLECTION) { item.w = 4; item.h = 4; item.mobileW = 8; item.mobileH = 6; item.cardType = 'event'; - item.cardData.uri = `at://${did}/${collection}/${rkey}`; + item.cardData.uri = `at://${repo}/${collection}/${rkey}`; return item; } } @@ -122,7 +105,7 @@ export const EventCardDefinition = { name: 'Event', - keywords: ['calendar', 'meetup', 'schedule', 'date', 'rsvp', 'smokesignal'], + keywords: ['calendar', 'meetup', 'schedule', 'date', 'rsvp', 'atmo', 'smokesignal'], groups: ['Social'], icon: `` } as CardDefinition & { type: 'event' }; diff --git a/src/lib/cards/social/UpcomingEventsCard/UpcomingEventsCard.svelte b/src/lib/cards/social/UpcomingEventsCard/UpcomingEventsCard.svelte index 3e49506..cd61ff2 100644 --- a/src/lib/cards/social/UpcomingEventsCard/UpcomingEventsCard.svelte +++ b/src/lib/cards/social/UpcomingEventsCard/UpcomingEventsCard.svelte @@ -1,13 +1,12 @@ + + + Create event · Blento + + +
+ +
diff --git a/src/routes/[[actor=actor]]/event/r/[rkey]/+page.server.ts b/src/routes/[[actor=actor]]/event/r/[rkey]/+page.server.ts new file mode 100644 index 0000000..58d5ff2 --- /dev/null +++ b/src/routes/[[actor=actor]]/event/r/[rkey]/+page.server.ts @@ -0,0 +1,11 @@ +import { error } from '@sveltejs/kit'; +import { getActor } from '$lib/actor'; + +export async function load({ params, request, platform }) { + if (!params.rkey) error(404, 'Event URL missing rkey'); + + const actor = await getActor({ request, paramActor: params.actor, platform }); + if (!actor) error(404, 'Could not resolve actor'); + + return { actor, rkey: params.rkey }; +} diff --git a/src/routes/[[actor=actor]]/event/r/[rkey]/+page.svelte b/src/routes/[[actor=actor]]/event/r/[rkey]/+page.svelte new file mode 100644 index 0000000..789c1a1 --- /dev/null +++ b/src/routes/[[actor=actor]]/event/r/[rkey]/+page.svelte @@ -0,0 +1,63 @@ + + + + Event · Blento + + + + + + + +
+ +