2
0
Files
bot/ee/apps/landing-page/app/og/route.tsx
2024-05-23 10:42:23 +02:00

60 lines
1.4 KiB
TypeScript

import { ImageResponse } from 'next/og'
import { NextRequest } from 'next/server'
import { env } from '@typebot.io/env'
export const runtime = 'edge'
export async function GET(req: NextRequest) {
const { searchParams } = req.nextUrl
const postTitle = searchParams.get('title')
const font = fetch(
new URL('../../assets/Outfit-Medium.ttf', import.meta.url)
).then((res) => res.arrayBuffer())
const fontData = await font
return new ImageResponse(
(
<div
style={{
height: '100%',
width: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-start',
justifyContent: 'center',
backgroundImage: `url(${env.LANDING_PAGE_URL}/images/og-bg.png)`,
}}
>
<div
style={{
marginLeft: 190,
marginRight: 190,
display: 'flex',
fontSize: 130,
fontFamily: 'Outfit',
letterSpacing: '-0.05em',
fontStyle: 'normal',
color: 'white',
lineHeight: '120px',
whiteSpace: 'pre-wrap',
}}
>
{postTitle}
</div>
</div>
),
{
width: 1280,
height: 720,
fonts: [
{
name: 'Outfit',
data: fontData,
style: 'normal',
},
],
}
)
}