vercel-og-with-tweaks/pages/api/custom-font.tsx

43 lines
804 B
TypeScript
Raw Normal View History

2022-11-04 23:02:31 +00:00
import { ImageResponse } from '@vercel/og'
export const config = {
runtime: 'experimental-edge',
}
const font = fetch(new URL('../../assets/TYPEWR__.TTF', import.meta.url)).then(
(res) => res.arrayBuffer()
)
export default async function handler() {
const fontData = await font
return new ImageResponse(
(
<div
style={{
backgroundColor: 'white',
height: '100%',
width: '100%',
fontSize: 100,
fontFamily: 'Typewriter',
paddingTop: '100px',
paddingLeft: '50px',
}}
>
Hello world!
</div>
),
{
width: 1200,
height: 630,
fonts: [
{
name: 'Typewriter',
data: fontData,
style: 'normal',
},
],
}
)
}