import { blog } from "@/lib/blog/config"; import { categoryOf } from "@/lib/blog/feeds"; import { getPublishedPost, listPublishedPosts } from "@/lib/blog/loader"; import { site } from "@/lib/site"; import { ImageResponse } from "next/og"; // The social preview image for a post without its own: the title on the site's colors export async function generateStaticParams() { return (await listPublishedPosts()).map((p) => ({ slug: p.slug })); } export async function GET( _req: Request, { params }: RouteContext<"/blog/og/[slug]">, ) { const { slug } = await params; const post = await getPublishedPost(slug); if (!post) return new Response("Not found", { status: 404 }); const { background, foreground, accent } = blog.image; return new ImageResponse(
{categoryOf(post.category)?.name ?? blog.name}
{post.title}
{site.domain}
, { width: 1200, height: 630 }, ); }