This commit is contained in:
Adrian Altner 2026-03-30 14:16:43 +02:00
commit 017bf6e067
115 changed files with 19650 additions and 0 deletions

View file

@ -0,0 +1,23 @@
import { getCollection } from "astro:content";
import { buildArticleVNode, renderOgImage } from "@/lib/og";
export async function getStaticPaths() {
const posts = await getCollection("blog", ({ data }) => !data.draft);
return posts.map((post) => ({
params: { slug: post.id },
props: { title: post.data.title, description: post.data.description },
}));
}
export async function GET({
props,
}: {
props: { title: string; description: string };
}) {
const buffer = await renderOgImage(
buildArticleVNode({ title: props.title, description: props.description }),
);
return new Response(buffer, {
headers: { "Content-Type": "image/png" },
});
}