import { ImageResponse } from "next/og"; import { loadRehberOgFonts } from "@/lib/og-fonts"; export const OG_SIZE = { width: 1200, height: 630 }; export const OG_CONTENT_TYPE = "image/png"; const PIXELS: [number, number, number][] = [ [960, 50, 0.16], [980, 50, 0.28], [1020, 50, 0.12], [940, 70, 0.24], [980, 70, 0.12], [1000, 70, 0.3], [1060, 70, 0.18], [960, 90, 0.12], [1000, 90, 0.2], [1040, 90, 0.1], [1080, 90, 0.26], [1080, 110, 0.14], [1120, 110, 0.22], [1140, 110, 0.12], [60, 490, 0.12], [100, 490, 0.25], [120, 490, 0.14], [40, 510, 0.24], [80, 510, 0.12], [120, 510, 0.3], [160, 510, 0.16], [60, 530, 0.14], [100, 530, 0.22], [140, 530, 0.1], [180, 530, 0.27], ]; function baslikBoyutu(title: string): number { if (title.length > 70) return 44; if (title.length > 52) return 50; if (title.length > 36) return 56; return 62; } /** Sayfa OG kartı — rehber kapağıyla aynı dil: eyebrow, başlık, marka. */ export async function createOgSayfaImage(opts: { eyebrow: string; title: string; description?: string; /** data: URI — sağ üstte beyaz rozet içinde gösterilir (üniversite logosu). */ logo?: string; }): Promise { const fonts = await loadRehberOgFonts(); const { eyebrow, title, description, logo } = opts; return new ImageResponse( (
{PIXELS.map(([left, top, opacity], i) => ( ))}
{eyebrow} {logo ? ( {/* eslint-disable-next-line @next/next/no-img-element */} ) : null}
{title}
{description ? (
{description}
) : null}
Kolay Tercih
), { ...OG_SIZE, fonts }, ); }