init
This commit is contained in:
commit
017bf6e067
115 changed files with 19650 additions and 0 deletions
23
src/pages/og/blog/[...slug].png.ts
Normal file
23
src/pages/og/blog/[...slug].png.ts
Normal 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" },
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue