@@ -4,9 +4,7 @@ import type { NextApiRequest } from "next/index";
4
4
import { RepoLogo } from "../../_components/logos/og/repo-logo" ;
5
5
import { VercelLogo } from "../../_components/logos/og/vercel-logo" ;
6
6
7
- export const config = {
8
- runtime : "edge" ,
9
- } ;
7
+ export const runtime = "edge" ;
10
8
11
9
function _arrayBufferToBase64 ( buffer : ArrayBuffer ) : string {
12
10
let binary = "" ;
@@ -20,7 +18,7 @@ function _arrayBufferToBase64(buffer: ArrayBuffer): string {
20
18
21
19
export async function GET ( req : NextApiRequest ) : Promise < Response > {
22
20
try {
23
- const [ geistSans , geistMono , bg ] = await Promise . all ( [
21
+ const [ geist , geistMono , bg ] = await Promise . all ( [
24
22
fetch ( new URL ( "./Geist-Regular.ttf" , import . meta. url ) ) . then ( ( res ) =>
25
23
res . arrayBuffer ( )
26
24
) ,
@@ -34,11 +32,7 @@ export async function GET(req: NextApiRequest): Promise<Response> {
34
32
) ,
35
33
] ) ;
36
34
37
- if ( ! req . url ) {
38
- throw new Error ( "No URL was provided" ) ;
39
- }
40
-
41
- const { searchParams } = new URL ( req . url ) ;
35
+ const { searchParams } = new URL ( req . url ! ) ;
42
36
43
37
let title : string | null = null ;
44
38
@@ -57,10 +51,10 @@ export async function GET(req: NextApiRequest): Promise<Response> {
57
51
justifyContent : "center" ,
58
52
width : "100%" ,
59
53
height : "100%" ,
60
- fontFamily : "Geist Sans " ,
54
+ fontFamily : "Geist Mono " ,
61
55
fontWeight : 700 ,
62
56
fontSize : 60 ,
63
- backgroundImage : `url(${ bg } )` ,
57
+ backgroundImage : `url(data:image/jpeg;base64, ${ bg } )` ,
64
58
backgroundSize : "1200px 630px" ,
65
59
color : "#fff" ,
66
60
} }
@@ -73,7 +67,7 @@ export async function GET(req: NextApiRequest): Promise<Response> {
73
67
{ title ? (
74
68
< div
75
69
style = { {
76
- fontFamily : "Geist Sans " ,
70
+ fontFamily : "Geist Mono " ,
77
71
fontSize : 36 ,
78
72
letterSpacing : - 1.5 ,
79
73
padding : "40px 20px 30px" ,
@@ -111,24 +105,25 @@ export async function GET(req: NextApiRequest): Promise<Response> {
111
105
} ,
112
106
{
113
107
name : "Geist Sans" ,
114
- data : geistSans ,
108
+ data : geist ,
115
109
weight : 400 as const ,
116
110
style : "normal" as const ,
117
111
} ,
118
112
] ,
119
113
}
120
114
) ;
121
115
} catch ( err : unknown ) {
122
- // Protects us from serving no image at all if something is broken .
116
+ // Prevents us from have no OG image at all in production .
123
117
if ( process . env . VERCEL_ENV === "production" ) {
124
118
return new Response ( undefined , {
125
119
status : 302 ,
126
120
headers : {
127
- Location : "/og-image.png" ,
121
+ Location : "https://turbo.build /og-image.png" ,
128
122
} ,
129
123
} ) ;
130
124
}
131
125
126
+ // We want to see the 500s everywhere else.
132
127
return new Response ( undefined , {
133
128
status : 500 ,
134
129
} ) ;
0 commit comments