diff --git a/app/game/[id]/opengraph-image.tsx b/app/game/[id]/opengraph-image.tsx new file mode 100644 index 0000000..457e444 --- /dev/null +++ b/app/game/[id]/opengraph-image.tsx @@ -0,0 +1,81 @@ +import { ImageResponse } from "next/og" +import { db } from "@/lib/db/index" +import { games, gameVersions, performanceEntries } from "@/lib/db/schema" +import { eq, and, sql } from "drizzle-orm" +import { readFile } from "node:fs/promises" +import { join } from "node:path" + +export const alt = "DeckyVault - Game Benchmarks" +export const size = { width: 1200, height: 630 } +export const contentType = "image/png" + +export default async function Image({ params }: { params: Promise<{ id: string }> }) { + const { id } = await params + const isNumeric = /^\d+$/.test(id) + + let game + if (isNumeric) { + const rows = await db.select().from(games).where(eq(games.steamAppId, Number(id))).limit(1) + game = rows[0] + } else { + const rows = await db.select().from(games).where(eq(games.id, id)).limit(1) + game = rows[0] + } + + if (!game) { + return new ImageResponse( + ( +