|
| 1 | +import { renderToolOgImage } from "@/components/og/tool-og-image"; |
| 2 | +import { brand } from "@/lib/brand"; |
| 3 | +import { getGame } from "@/lib/games"; |
| 4 | +import { readFile } from "node:fs/promises"; |
| 5 | +import { join } from "node:path"; |
| 6 | + |
| 7 | +export const runtime = "nodejs"; |
| 8 | +export const alt = "As It Should Be — Randy Code"; |
| 9 | +export const size = { width: 1200, height: 630 }; |
| 10 | +export const contentType = "image/png"; |
| 11 | + |
| 12 | +// Raw node data from lucide-react's gamepad-2 icon |
| 13 | +// (dist/esm/icons/gamepad-2.mjs), with Lucide's internal `key` field dropped. |
| 14 | +const GAMEPAD_ICON = [ |
| 15 | + ["line", { x1: "6", x2: "10", y1: "11", y2: "11" }], |
| 16 | + ["line", { x1: "8", x2: "8", y1: "9", y2: "13" }], |
| 17 | + ["line", { x1: "15", x2: "15.01", y1: "12", y2: "12" }], |
| 18 | + ["line", { x1: "18", x2: "18.01", y1: "10", y2: "10" }], |
| 19 | + [ |
| 20 | + "path", |
| 21 | + { |
| 22 | + d: "M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z", |
| 23 | + }, |
| 24 | + ], |
| 25 | +] as const; |
| 26 | + |
| 27 | +const PANEL_WIDTH = 440; |
| 28 | +const BANNER_WIDTH = PANEL_WIDTH - 56; |
| 29 | + |
| 30 | +export default async function Image() { |
| 31 | + const game = getGame("as-it-should-be"); |
| 32 | + if (!game) throw new Error("Game not found"); |
| 33 | + |
| 34 | + const banner = await readFile(join(process.cwd(), "public", game.banner.src)); |
| 35 | + const bannerHeight = Math.round( |
| 36 | + (BANNER_WIDTH * game.banner.height) / game.banner.width, |
| 37 | + ); |
| 38 | + |
| 39 | + const preview = ( |
| 40 | + <div |
| 41 | + style={{ |
| 42 | + display: "flex", |
| 43 | + width: BANNER_WIDTH, |
| 44 | + height: bannerHeight, |
| 45 | + borderRadius: 12, |
| 46 | + overflow: "hidden", |
| 47 | + }} |
| 48 | + > |
| 49 | + <img |
| 50 | + src={`data:image/jpeg;base64,${banner.toString("base64")}`} |
| 51 | + width={BANNER_WIDTH} |
| 52 | + height={bannerHeight} |
| 53 | + alt="" |
| 54 | + /> |
| 55 | + </div> |
| 56 | + ); |
| 57 | + |
| 58 | + return renderToolOgImage({ |
| 59 | + title: game.name, |
| 60 | + tagline: game.tagline.fr, |
| 61 | + color: brand.colors.violet[400], |
| 62 | + iconNodes: GAMEPAD_ICON, |
| 63 | + label: "Games Arcade", |
| 64 | + preview, |
| 65 | + previewWidth: PANEL_WIDTH, |
| 66 | + }); |
| 67 | +} |
0 commit comments