Jotley / website / scripts / generate-og.mjs
| 1 | // Rebuild the social card with the real app screenshots: npm run generate:og |
| 2 | import { ImageResponse } from 'next/og.js'; |
| 3 | import { createElement as h } from 'react'; |
| 4 | import sharp from 'sharp'; |
| 5 | import { readFile, writeFile, mkdir } from 'node:fs/promises'; |
| 6 | |
| 7 | const img = async (path) => `data:image/png;base64,${(await sharp(await readFile(path)).png().toBuffer()).toString('base64')}`; |
| 8 | const [logo, mac, phone] = await Promise.all([ |
| 9 | img('public/jotley-logo.png'), |
| 10 | img('public/media/shots/mac-summary-2.3.webp'), |
| 11 | img('public/media/shots/iphone-summary-2.3.webp'), |
| 12 | ]); |
| 13 | const box = (style, ...children) => h('div', { style: { display: 'flex', ...style } }, ...children); |
| 14 | const text = (value, style) => box(style, value); |
| 15 | |
| 16 | const card = box({ |
| 17 | width: '100%', height: '100%', background: '#0d0b14', color: '#faf7ff', |
| 18 | position: 'relative', overflow: 'hidden', fontFamily: 'sans-serif', |
| 19 | backgroundImage: 'radial-gradient(ellipse at 90% 65%, #34205b 0%, #0d0b14 65%)', |
| 20 | }, |
| 21 | box({ position: 'absolute', left: 54, top: 46, alignItems: 'center', gap: 14 }, |
| 22 | h('img', { src: logo, width: 48, height: 48, style: { borderRadius: 12 } }), |
| 23 | text('Jotley', { fontSize: 34, fontWeight: 700, letterSpacing: -1 }), |
| 24 | ), |
| 25 | text('MAC · IPHONE · IPAD', { position: 'absolute', left: 56, top: 141, fontSize: 15, fontWeight: 700, letterSpacing: 3, color: '#bfa2f4' }), |
| 26 | box({ position: 'absolute', left: 54, top: 192, flexDirection: 'column', fontSize: 61, lineHeight: 1.1, letterSpacing: -2.5, fontWeight: 700 }, |
| 27 | text('Every word,'), text('captured and'), text('understood.', { color: '#8b5cf6' }), |
| 28 | ), |
| 29 | text('Voice notes. Powered by Apple Intelligence.', { position: 'absolute', left: 56, top: 416, fontSize: 21, color: '#ccc2de', width: 460, lineHeight: 1.5 }), |
| 30 | box({ position: 'absolute', left: 56, bottom: 60, alignItems: 'center', gap: 16 }, |
| 31 | text('Completely free', { background: '#261a3e', border: '1px solid #604389', padding: '10px 16px', borderRadius: 30, fontSize: 16, color: '#dfccff', fontWeight: 700 }), |
| 32 | text('On-device AI', { fontSize: 16, color: '#afa5c1' }), |
| 33 | ), |
| 34 | // A desktop app window and an iPhone use the site's existing screenshots. |
| 35 | box({ position: 'absolute', left: 580, top: 178, width: 574, height: 361, flexDirection: 'column', border: '1px solid #6a5b84', borderRadius: 16, overflow: 'hidden', boxShadow: '0 24px 60px #00000080', background: '#222' }, |
| 36 | h('img', { src: mac, width: 572, height: 359, style: { objectFit: 'cover', objectPosition: 'top' } }), |
| 37 | ), |
| 38 | box({ position: 'absolute', left: 968, top: 100, width: 185, height: 403, background: '#08070b', padding: 5, border: '2px solid #82778f', borderRadius: 29, boxShadow: '0 18px 45px #00000080', overflow: 'hidden' }, |
| 39 | h('img', { src: phone, width: 171, height: 389, style: { borderRadius: 22 } }), |
| 40 | ), |
| 41 | text('jotley.ai', { position: 'absolute', right: 48, bottom: 35, fontSize: 17, color: '#b9a9d0', letterSpacing: 1 }), |
| 42 | ); |
| 43 | |
| 44 | const response = new ImageResponse(card, { width: 1200, height: 630 }); |
| 45 | await mkdir('public/og', { recursive: true }); |
| 46 | await writeFile('public/og/jotley-v2.png', Buffer.from(await response.arrayBuffer())); |
| 47 | console.log('Generated public/og/jotley-v2.png (1200 × 630)'); |