+page.ts (775B)
1 import { _env } from "$lib/utils/_env"; 2 import { load_profile_indexed } from "$lib/utils/profile"; 3 import { error } from "@sveltejs/kit"; 4 import type { EntryGenerator, PageLoad } from "./$types"; 5 6 const { RADROOTS_MARKET_INDEXES_URL: idx_url } = _env; 7 8 export const entries: EntryGenerator = async () => { 9 if (!idx_url) return []; 10 const indexes: string[] = await fetch(`${idx_url}/events/0/npub/indexes.json`).then(r => r.json()); 11 return indexes.map(i => ({ 0: i })); 12 }; 13 14 export const load: PageLoad = async ({ fetch, params }) => { 15 const { 0: npub } = params; 16 const result = await load_profile_indexed(fetch, "npub", npub); 17 if (!result.ok) throw error(result.status ?? 500, result.message); 18 return result.data; 19 }; 20 21 export const prerender = true;