import { ImageResponse } from "@vercel/og"; export const config = { runtime: "edge", }; const karla = fetch( new URL("../../assets/Karla-MediumItalic.ttf", import.meta.url) ).then((res) => res.arrayBuffer()); const outfit = fetch( new URL("../../assets/Outfit-Regular.ttf", import.meta.url) ).then((res) => res.arrayBuffer()); export default async function handler(request) { const Karla = await karla; const Outfit = await outfit; const { searchParams } = request.nextUrl; const hasTitle = searchParams.has("title"); const title = hasTitle ? searchParams.get("title").length > 64 ? searchParams.get("title").slice(0, 64) + "..." : searchParams.get("title") : "Watch Now"; const image = searchParams.get("image"); if (!title) { return new ImageResponse(<>Visit with "?username=vercel", { width: 1200, height: 630, }); } return new ImageResponse( (
moopa

{title}

), { width: 1900, height: 400, fonts: [ { name: "Karla", data: Karla, style: "normal", }, { name: "Outfit", data: Outfit, style: "normal", }, ], } ); }