your personal website on atproto - mirror blento.app
at button 35 lines 1.1 kB view raw
1import { env } from '$env/dynamic/public'; 2import type { UserCache, WebsiteData } from '$lib/types.js'; 3import { loadData } from '$lib/website/load'; 4import type { Handle } from '@atcute/lexicons'; 5import type { AppBskyActorDefs } from '@atcute/bluesky'; 6 7export async function load({ platform }) { 8 const cache = platform?.env?.USER_DATA_CACHE; 9 10 const list = await cache?.list(); 11 12 const profiles: AppBskyActorDefs.ProfileViewDetailed[] = []; 13 for (const value of list?.keys ?? []) { 14 // check if at least one card 15 const result = await cache?.get(value.name); 16 if (!result) continue; 17 const parsed = JSON.parse(result) as WebsiteData; 18 19 if (parsed.version !== 1 || !parsed.cards?.length) continue; 20 21 profiles.push(parsed.profile); 22 } 23 24 profiles.sort((a, b) => a.handle.localeCompare(b.handle)); 25 26 const handle = env.PUBLIC_HANDLE; 27 28 const data = await loadData(handle as Handle, cache as unknown as UserCache); 29 30 data.publication ??= {}; 31 data.publication.preferences ??= {}; 32 data.publication.preferences.hideProfileSection = true; 33 34 return { ...data, profiles }; 35}