Socialify

Folder ..

Viewing renderPNG.tsx
21 lines (18 loc) • 539.0 B

 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