mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
fix(og-images): wrap Buffer in Uint8Array for Response body (#568)
Astro uses Web API typings; Response doesn’t accept Node Buffer. Convert the generated OG image Buffer to Uint8Array before constructing Response to satisfy BodyInit and fix the build/type error. Closes #560
This commit is contained in:
+4
-2
@@ -1,7 +1,9 @@
|
|||||||
import type { APIRoute } from "astro";
|
import type { APIRoute } from "astro";
|
||||||
import { generateOgImageForSite } from "@/utils/generateOgImages";
|
import { generateOgImageForSite } from "@/utils/generateOgImages";
|
||||||
|
|
||||||
export const GET: APIRoute = async () =>
|
export const GET: APIRoute = async () => {
|
||||||
new Response(await generateOgImageForSite(), {
|
const buffer = await generateOgImageForSite();
|
||||||
|
return new Response(new Uint8Array(buffer), {
|
||||||
headers: { "Content-Type": "image/png" },
|
headers: { "Content-Type": "image/png" },
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -27,10 +27,8 @@ export const GET: APIRoute = async ({ props }) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(
|
const buffer = await generateOgImageForPost(props as CollectionEntry<"blog">);
|
||||||
await generateOgImageForPost(props as CollectionEntry<"blog">),
|
return new Response(new Uint8Array(buffer), {
|
||||||
{
|
|
||||||
headers: { "Content-Type": "image/png" },
|
headers: { "Content-Type": "image/png" },
|
||||||
}
|
});
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user