your personal website on atproto - mirror blento.app
at bump-text-padding 26 lines 847 B view raw
1import { loadData } from '$lib/website/load'; 2import { env } from '$env/dynamic/public'; 3import { env as privateEnv } from '$env/dynamic/private'; 4import { createCache } from '$lib/cache'; 5import type { ActorIdentifier } from '@atcute/lexicons'; 6 7export async function load({ platform, request }) { 8 const handle = env.PUBLIC_HANDLE; 9 10 const kv = platform?.env?.CUSTOM_DOMAINS; 11 12 const cache = createCache(platform); 13 const customDomain = request.headers.get('X-Custom-Domain')?.toLocaleLowerCase(); 14 15 if (kv && customDomain) { 16 try { 17 const did = await kv.get(customDomain); 18 19 if (did) return await loadData(did as ActorIdentifier, cache, false, 'self', privateEnv); 20 } catch (error) { 21 console.error('failed to get custom domain kv', error); 22 } 23 } 24 25 return await loadData(handle as ActorIdentifier, cache, false, 'self', privateEnv); 26}