--- import "fluent-svelte/theme.css"; import "@fontsource/inter-tight/variable.css"; import "@fontsource/inter/variable.css"; import RegisterSw from "../components/register-sw.svelte"; export interface Props { title: string; description: string; } const { title, description } = Astro.props; const _url = new URL(Astro.url).searchParams.get("q") ?? ""; const result = async () => { if (_url && _url.length > 0) { try { const req = await fetch( Astro.url.origin + "/api/twitter?url=" + encodeURIComponent(_url) ); return req.json() as Promise<{ url: string; type: string }[]>; } catch (e) { console.warn(e); } } return []; }; --- {title} { _url && _url.length > 0 ? ( ) : null } { (await result?.())?.map?.(({ url, type }) => { if (url && url.length > 0) return ( ); return null; }) }