Upgrade Astro and Astro Paper to v5

This commit is contained in:
tiff 2025-03-08 19:45:21 -05:00
parent 8ebf7d5996
commit e719f7ccca
105 changed files with 7099 additions and 1939 deletions

View file

@ -0,0 +1,20 @@
import { Resvg } from "@resvg/resvg-js";
import { type CollectionEntry } from "astro:content";
import postOgImage from "./og-templates/post";
import siteOgImage from "./og-templates/site";
function svgBufferToPngBuffer(svg: string) {
const resvg = new Resvg(svg);
const pngData = resvg.render();
return pngData.asPng();
}
export async function generateOgImageForPost(post: CollectionEntry<"blog">) {
const svg = await postOgImage(post);
return svgBufferToPngBuffer(svg);
}
export async function generateOgImageForSite() {
const svg = await siteOgImage();
return svgBufferToPngBuffer(svg);
}