aboutsummaryrefslogtreecommitdiff
path: root/common/renderPNG.tsx
blob: 223dc4ce74efabde92c787257072d05dc9e4bac4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { ImageResponse } from '@vercel/og'
import Card from '../src/components/preview/card'
import { getCardConfig, getFonts } from './renderCard'
import QueryType from './types/queryType'

const renderCardPNG = async (
  query: QueryType,
  opts: { headers?: Record<string, string> } = {}
) => {
  const config = await getCardConfig(query)

  return new ImageResponse(<Card {...config} />, {
    width: 1280,
    height: 640,
    fonts: await getFonts(config.font),
    emoji: 'twemoji',
    ...opts
  })
}

export default renderCardPNG