Openstatus
www.openstatus.dev
1/* eslint-disable @next/next/no-img-element */
2import { ImageResponse } from "next/og";
3
4import { TITLE } from "@/app/shared-metadata";
5import { BasicLayout } from "../_components/basic-layout";
6import {
7 DEFAULT_URL,
8 SIZE,
9 calSemiBold,
10 commitMonoBold,
11 commitMonoRegular,
12 interLight,
13 interRegular,
14} from "../utils";
15
16export const runtime = "edge";
17
18export async function GET(req: Request) {
19 const [
20 interRegularData,
21 interLightData,
22 calSemiBoldData,
23 commitMonoRegularData,
24 commitMonoBoldData,
25 ] = await Promise.all([
26 interRegular,
27 interLight,
28 calSemiBold,
29 commitMonoRegular,
30 commitMonoBold,
31 ]);
32
33 const { searchParams } = new URL(req.url);
34
35 const title =
36 (searchParams.has("title") && searchParams.get("title")) || TITLE;
37 const description = searchParams.has("description")
38 ? searchParams.get("description")
39 : undefined;
40 const image = searchParams.has("image")
41 ? searchParams.get("image")
42 : undefined;
43
44 return new ImageResponse(
45 <BasicLayout title={title} description={description}>
46 {image ? (
47 <img
48 alt=""
49 style={{ objectFit: "cover", height: 330 }} // h-80 = 320px
50 tw="flex w-full"
51 src={new URL(image, DEFAULT_URL).toString()}
52 />
53 ) : null}
54 </BasicLayout>,
55 {
56 ...SIZE,
57 fonts: [
58 {
59 name: "Inter",
60 data: interRegularData,
61 style: "normal",
62 weight: 400,
63 },
64 {
65 name: "Inter",
66 data: interLightData,
67 style: "normal",
68 weight: 300,
69 },
70 {
71 name: "Cal",
72 data: calSemiBoldData,
73 style: "normal",
74 weight: 600,
75 },
76 {
77 name: "Commit Mono",
78 data: commitMonoRegularData,
79 style: "normal",
80 weight: 400,
81 },
82 {
83 name: "Commit Mono",
84 data: commitMonoBoldData,
85 style: "normal",
86 weight: 700,
87 },
88 ],
89 },
90 );
91}