diff --git a/docs/app/api/og/route.tsx b/docs/app/api/og/route.tsx index 0fcd5b6f..cbaa7e30 100644 --- a/docs/app/api/og/route.tsx +++ b/docs/app/api/og/route.tsx @@ -3,207 +3,213 @@ import { z } from "zod"; export const runtime = "edge"; const ogSchema = z.object({ - heading: z.string(), - mode: z.string(), - type: z.string(), + heading: z.string(), + mode: z.string(), + type: z.string(), }); - +const val = { + heading: "Some headin", + mode: "dark", + type: "documentation", +}; export async function GET(req: Request) { - try { - const geist = await fetch( - new URL("../../../assets/Geist.ttf", import.meta.url), - ).then((res) => res.arrayBuffer()); - const geistMono = await fetch( - new URL("../../../assets/GeistMono.ttf", import.meta.url), - ).then((res) => res.arrayBuffer()); - const url = new URL(req.url); - const urlParamsValues = Object.fromEntries(url.searchParams); - const validParams = ogSchema.parse(urlParamsValues); - const { heading, type } = validParams; - const trueHeading = - heading.length > 140 ? `${heading.substring(0, 140)}...` : heading; + try { + const geist = await fetch( + new URL("../../../assets/Geist.ttf", import.meta.url), + ).then((res) => res.arrayBuffer()); + const geistMono = await fetch( + new URL("../../../assets/GeistMono.ttf", import.meta.url), + ).then((res) => res.arrayBuffer()); + const url = new URL(req.url); + const urlParamsValues = Object.fromEntries(url.searchParams); + const validParams = ogSchema.parse(val); + const { heading, type } = validParams; + const trueHeading = + heading.length > 140 ? `${heading.substring(0, 140)}...` : heading; - const paint = "#fff"; + const paint = "#fff"; - const fontSize = trueHeading.length > 100 ? "30px" : "60px"; - return new ImageResponse( -
-
- - - + const fontSize = trueHeading.length > 100 ? "30px" : "60px"; + return new ImageResponse( + ( +
+
+ + + - - - - - - - - - -
- - - -
- {type === "documentaiton" ? ( - - - - ) : null} - {type} -
-
+ + + + + + + + +
+ + + +
+ {type === "documentaiton" ? ( + + + + ) : null} + {type} +
+
- {trueHeading} -
-
-
-
- Better Auth. -
-
- - - - - github.com/better-auth/better-auth - -
-
-
-
, - { - width: 1200, - height: 630, - fonts: [ - { - name: "Geist", - data: geist, - weight: 400, - style: "normal", - }, - { - name: "GeistMono", - data: geistMono, - weight: 700, - style: "normal", - }, - ], - }, - ); - } catch (err) { - console.log({ err }); - return new Response("Failed to generate the og image", { status: 500 }); - } + fontFamily: "GeistMono", + }} + > + {trueHeading} +
+
+
+
+ Better Auth. +
+
+ + + + + github.com/better-auth/better-auth + +
+
+
+
+ ), + { + width: 1200, + height: 630, + fonts: [ + { + name: "Geist", + data: geist, + weight: 400, + style: "normal", + }, + { + name: "GeistMono", + data: geistMono, + weight: 700, + style: "normal", + }, + ], + }, + ); + } catch (err) { + console.log({ err }); + return new Response("Failed to generate the og image", { status: 500 }); + } }