From b351f1ad1c632d7c835fd8a4a1de7a5467ccd64d Mon Sep 17 00:00:00 2001
From: Bram Suurd
Date: Wed, 28 Aug 2024 15:20:03 +0200
Subject: [PATCH] refactor: revert to old image generation image.
---
src/app/api/og/route.tsx | 106 +++++++++++++++++----------------------
1 file changed, 45 insertions(+), 61 deletions(-)
diff --git a/src/app/api/og/route.tsx b/src/app/api/og/route.tsx
index 5ba9db5..db12209 100644
--- a/src/app/api/og/route.tsx
+++ b/src/app/api/og/route.tsx
@@ -2,85 +2,75 @@ import { pb } from "@/lib/pocketbase";
import { Script } from "@/lib/types";
import { ImageResponse } from "next/og";
import { NextRequest } from "next/server";
-import { ClientResponseError } from 'pocketbase';
-
-const size = {
- width: 1200,
- height: 630,
-};
+import { ClientResponseError } from "pocketbase";
export async function GET(req: NextRequest) {
- const title = req.nextUrl.searchParams.get("title");
+ const { searchParams } = new URL(req.url);
+ const title = searchParams.get("title");
if (!title) {
return new Response("Missing title parameter", { status: 400 });
}
try {
- const item = await fetchScript(title);
+ const script: Script = await pb
+ .collection("proxmox_scripts")
+ .getFirstListItem(`title="${title}"`, {
+ fields: "logo,id",
+ });
+
return new ImageResponse(
(
-
*/}
+

+
-
-

-

-
-
- {item.title}
-
-
+ {title}
+
),
{
- ...size,
+ width: 1200,
+ height: 630,
},
);
} catch (error) {
@@ -93,9 +83,3 @@ export async function GET(req: NextRequest) {
return new Response("Error generating image", { status: 500 });
}
}
-
-async function fetchScript(title: string): Promise