-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathog.tsx
48 lines (45 loc) · 1.16 KB
/
og.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { ImageResponse } from '@vercel/og'
import { NextRequest } from 'next/server'
export const config = {
runtime: 'edge',
}
export default async function handler(req: NextRequest) {
const { searchParams } = req.nextUrl
const username = searchParams.get('username')
return new ImageResponse(
(
<div
style={{
display: 'flex',
fontSize: 60,
color: 'black',
background: '#f6f6f6',
width: '100%',
height: '100%',
paddingTop: 50,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
}}
>
<img
width="256"
height="256"
src={`https://github.com/${username || 'netlify'}.png`}
style={{
borderRadius: 128,
}}
/>
{username ? <p>github.com/{username}</p> : <p>Visit with "?username=netlify"</p>}
</div>
),
{
width: 1200,
height: 630,
headers: {
// By default this has an immutable cache, but this is for testing
'Cache-Control': 'public, max-age=0, must-revalidate',
},
},
)
}