your personal website on atproto - mirror blento.app

Merge pull request #197 from flo-bit/events-pages

Events pages

authored by

Florian and committed by
GitHub
67f9af14 79cf9964

+30 -10
+29 -9
src/routes/[[actor=actor]]/e/[rkey]/+page.server.ts
··· 3 3 import { getBlentoOrBskyProfile, getRecord, resolveHandle } from '$lib/atproto/methods.js'; 4 4 import { isHandle } from '@atcute/lexicons/syntax'; 5 5 import { createCache, type CachedProfile } from '$lib/cache'; 6 - import type { Did } from '@atcute/lexicons'; 6 + import type { ActorIdentifier, Did } from '@atcute/lexicons'; 7 + import { env as publicEnv } from '$env/dynamic/public'; 7 8 8 - export async function load({ params, platform }) { 9 + export async function load({ params, platform, request }) { 9 10 const { rkey } = params; 10 - const did = isHandle(params.actor) ? await resolveHandle({ handle: params.actor }) : params.actor; 11 + 12 + const cache = createCache(platform); 13 + 14 + const customDomain = request.headers.get('X-Custom-Domain')?.toLowerCase(); 15 + 16 + let actor: ActorIdentifier | undefined = params.actor; 17 + 18 + if (!actor) { 19 + const kv = platform?.env?.CUSTOM_DOMAINS; 20 + 21 + if (kv && customDomain) { 22 + try { 23 + const did = await kv.get(customDomain); 24 + 25 + if (did) actor = did as ActorIdentifier; 26 + } catch (error) { 27 + console.error('failed to get custom domain kv', error); 28 + } 29 + } else { 30 + actor = publicEnv.PUBLIC_HANDLE as ActorIdentifier; 31 + } 32 + } else if (customDomain && params.actor) { 33 + actor = undefined; 34 + } 35 + 36 + const did = isHandle(actor) ? await resolveHandle({ handle: actor }) : actor; 11 37 12 38 if (!did || !rkey) { 13 39 throw error(404, 'Event not found'); 14 40 } 15 41 16 42 try { 17 - const cache = createCache(platform); 18 - 19 - console.log( 20 - `https://smokesignal.events/xrpc/community.lexicon.calendar.GetEvent?repository=${encodeURIComponent(did)}&record_key=${encodeURIComponent(rkey)}` 21 - ); 22 - 23 43 const [eventResponse, hostProfile, eventRecord] = await Promise.all([ 24 44 fetch( 25 45 `https://smokesignal.events/xrpc/community.lexicon.calendar.GetEvent?repository=${encodeURIComponent(did)}&record_key=${encodeURIComponent(rkey)}`
+1 -1
src/routes/[[actor=actor]]/e/[rkey]/+page.svelte
··· 262 262 Links 263 263 </p> 264 264 <div class="space-y-3"> 265 - {#each eventData.uris as link} 265 + {#each eventData.uris as link (link.name + link.uri)} 266 266 <a 267 267 href={link.uri} 268 268 target="_blank"