/** * Dynamic OG image generator — renders social share previews. * Uses next/og (ImageResponse) to create 1200×630 cards. * Reads accent color from theme config. * * GET /api/og?title=Album+Name&subtitle=12+photos */ import { ImageResponse } from 'next/og'; import { NextRequest } from 'next/server'; import { getConfig } from '@/lib/config'; export async function GET(request: NextRequest) { const { searchParams } = request.nextUrl; const title = (searchParams.get('title') || 'Gallery').slice(0, 200); const subtitle = (searchParams.get('subtitle') || '').slice(0, 100); const { theme } = getConfig(); return new ImageResponse(
{/* Decorative top line */}
{/* Title */}
{title}
{/* Subtitle */} {subtitle && (
{subtitle}
)} {/* Bottom decorative line */}
, { width: 1200, height: 630, headers: { 'Cache-Control': 'public, max-age=86400, s-maxage=86400', }, }, ); }