|
| 1 | +import { NextRequest } from "next/server"; |
| 2 | +import { ImageResponse } from "@vercel/og"; |
| 3 | + |
| 4 | +export const config = { |
| 5 | + runtime: "edge", |
| 6 | +}; |
| 7 | + |
| 8 | +export default async function handler(req: NextRequest) { |
| 9 | + const { searchParams } = new URL(req.url); |
| 10 | + const title = searchParams.get("title") || "BG Sand Garden"; |
| 11 | + |
| 12 | + // Load Share Tech Mono from Google Fonts (ttf format required by Satori) |
| 13 | + const font = await fetch("https://fonts.gstatic.com/s/sharetechmono/v16/J7aHnp1uDWRBEqV98dVQztYldFc7pA.ttf").then( |
| 14 | + res => res.arrayBuffer(), |
| 15 | + ); |
| 16 | + |
| 17 | + return new ImageResponse( |
| 18 | + ( |
| 19 | + <div |
| 20 | + style={{ |
| 21 | + display: "flex", |
| 22 | + flexDirection: "column", |
| 23 | + width: "100%", |
| 24 | + height: "100%", |
| 25 | + backgroundColor: "#000000", |
| 26 | + padding: "60px", |
| 27 | + justifyContent: "space-between", |
| 28 | + fontFamily: "Share Tech Mono", |
| 29 | + }} |
| 30 | + > |
| 31 | + {/* Top: Branding */} |
| 32 | + <div style={{ display: "flex", flexDirection: "column" }}> |
| 33 | + <div style={{ display: "flex", alignItems: "center", gap: "16px" }}> |
| 34 | + <div |
| 35 | + style={{ |
| 36 | + fontSize: 42, |
| 37 | + color: "#49ff13", |
| 38 | + fontWeight: 700, |
| 39 | + letterSpacing: "-1px", |
| 40 | + }} |
| 41 | + > |
| 42 | + BG Sand Garden |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + <div |
| 46 | + style={{ |
| 47 | + fontSize: 22, |
| 48 | + color: "#49ff13", |
| 49 | + opacity: 0.5, |
| 50 | + marginTop: "4px", |
| 51 | + }} |
| 52 | + > |
| 53 | + BuidlGuidl |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + |
| 57 | + {/* Center: Blog Title */} |
| 58 | + <div |
| 59 | + style={{ |
| 60 | + display: "flex", |
| 61 | + fontSize: title.length > 60 ? 48 : title.length > 40 ? 56 : 64, |
| 62 | + color: "#ffffff", |
| 63 | + fontWeight: 700, |
| 64 | + lineHeight: 1.15, |
| 65 | + maxWidth: "95%", |
| 66 | + }} |
| 67 | + > |
| 68 | + {title} |
| 69 | + </div> |
| 70 | + |
| 71 | + {/* Bottom: decorative line */} |
| 72 | + <div style={{ display: "flex", alignItems: "center", gap: "12px" }}> |
| 73 | + <div |
| 74 | + style={{ |
| 75 | + display: "flex", |
| 76 | + width: "60px", |
| 77 | + height: "3px", |
| 78 | + backgroundColor: "#c913ff", |
| 79 | + }} |
| 80 | + /> |
| 81 | + <div |
| 82 | + style={{ |
| 83 | + display: "flex", |
| 84 | + width: "100%", |
| 85 | + height: "1px", |
| 86 | + backgroundColor: "#49ff13", |
| 87 | + opacity: 0.2, |
| 88 | + }} |
| 89 | + /> |
| 90 | + </div> |
| 91 | + </div> |
| 92 | + ), |
| 93 | + { |
| 94 | + width: 1200, |
| 95 | + height: 630, |
| 96 | + fonts: [ |
| 97 | + { |
| 98 | + name: "Share Tech Mono", |
| 99 | + data: font, |
| 100 | + style: "normal", |
| 101 | + weight: 400, |
| 102 | + }, |
| 103 | + ], |
| 104 | + }, |
| 105 | + ); |
| 106 | +} |
0 commit comments