fix: og image compat

This commit is contained in:
Kinfe123
2025-04-01 09:37:43 +03:00
parent 0d7fa1f99c
commit e2d6b2fdbe

View File

@@ -7,7 +7,11 @@ const ogSchema = z.object({
mode: z.string(), mode: z.string(),
type: z.string(), type: z.string(),
}); });
const val = {
heading: "Some headin",
mode: "dark",
type: "documentation",
};
export async function GET(req: Request) { export async function GET(req: Request) {
try { try {
const geist = await fetch( const geist = await fetch(
@@ -18,7 +22,7 @@ export async function GET(req: Request) {
).then((res) => res.arrayBuffer()); ).then((res) => res.arrayBuffer());
const url = new URL(req.url); const url = new URL(req.url);
const urlParamsValues = Object.fromEntries(url.searchParams); const urlParamsValues = Object.fromEntries(url.searchParams);
const validParams = ogSchema.parse(urlParamsValues); const validParams = ogSchema.parse(val);
const { heading, type } = validParams; const { heading, type } = validParams;
const trueHeading = const trueHeading =
heading.length > 140 ? `${heading.substring(0, 140)}...` : heading; heading.length > 140 ? `${heading.substring(0, 140)}...` : heading;
@@ -27,8 +31,9 @@ export async function GET(req: Request) {
const fontSize = trueHeading.length > 100 ? "30px" : "60px"; const fontSize = trueHeading.length > 100 ? "30px" : "60px";
return new ImageResponse( return new ImageResponse(
(
<div <div
tw="flex w-full relative flex-col p-9" tw="flex w-full relative flex-col p-12"
style={{ style={{
color: paint, color: paint,
backgroundColor: "transparent", backgroundColor: "transparent",
@@ -38,7 +43,7 @@ export async function GET(req: Request) {
}} }}
> >
<div <div
tw={`relative flex flex-col w-full h-full border-2 border-[${paint}]/20 p-8}`} tw={`relative flex flex-col w-full h-full border-2 border-[${paint}]/20 p-10}`}
> >
<svg <svg
style={{ style={{
@@ -182,7 +187,8 @@ export async function GET(req: Request) {
</div> </div>
</div> </div>
</div> </div>
</div>, </div>
),
{ {
width: 1200, width: 1200,
height: 630, height: 630,