Files
trumpsignal-monorepo/apps/web/pages/api/apple-icon.tsx
T

45 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Apple touch icon (180×180) — also used as the PWA icon source.
*
* iOS Safari grabs <link rel="apple-touch-icon"> when "Add to Home Screen"
* is invoked. Next.js auto-wires this file to that link.
*/
import { ImageResponse } from 'next/og'
const size = { width: 180, height: 180 }
const contentType = 'image/png'
function AppleIcon() {
return new ImageResponse(
<div
style={{
width: '100%',
height: '100%',
background: '#0a0907',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontSize: 132,
fontWeight: 700,
color: '#f5a524',
fontFamily: 'system-ui, sans-serif',
lineHeight: 1,
borderRadius: 24,
}}
>
α
</div>,
{ ...size },
)
}
export default async function handler(
_req: import('next').NextApiRequest,
res: import('next').NextApiResponse,
) {
const image = AppleIcon()
res.setHeader('Content-Type', 'image/png')
res.setHeader('Cache-Control', 'public, max-age=86400')
res.send(Buffer.from(await image.arrayBuffer()))
}