import { ImageResponse } from 'next/og' import { getSharedChat } from '@/app/actions' export const runtime = 'edge' export const alt = 'AI Chatbot' export const size = { width: 1200, height: 630 } export const contentType = 'image/png' const interRegular = fetch( new URL('../../../assets/fonts/Inter-Regular.woff', import.meta.url) ).then(res => res.arrayBuffer()) const interBold = fetch( new URL('../../../assets/fonts/Inter-Bold.woff', import.meta.url) ).then(res => res.arrayBuffer()) interface ImageProps { params: { id: string } } export default async function Image({ params }: ImageProps) { const chat = await getSharedChat(params.id) if (!chat || !chat?.sharePath) { return null } const textAlign = chat?.title?.length > 40 ? 'items-start' : 'items-center' return new ImageResponse( (
{chat.title.length > 120 ? `${chat.title.slice(0, 120)}...` : chat.title}
...
Built with{' '}
Vercel AI SDK
&
KV
chat.vercel.ai
), { ...size, fonts: [ { name: 'Inter', data: await interRegular, style: 'normal', weight: 400 }, { name: 'Inter', data: await interBold, style: 'normal', weight: 700 } ] } ) }