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