|
| 1 | +/** |
| 2 | + * Default OpenGraph + Twitter share card for the cockpit reference app. |
| 3 | + * |
| 4 | + * Renders a 1200×630 PNG at request time via Next.js ImageResponse. |
| 5 | + * Per-route overrides can be added by dropping an `opengraph-image.tsx` |
| 6 | + * file in any route folder (e.g. per-product or per-topic cards). |
| 7 | + * |
| 8 | + * Cockpit's chrome is Linear-style devtools (Phase 8 spec) — Inter Bold |
| 9 | + * for the headline rather than the marketing site's EB Garamond, so we |
| 10 | + * don't need to bundle a serif TTF. |
| 11 | + */ |
| 12 | +import { ImageResponse } from 'next/og'; |
| 13 | + |
| 14 | +export const runtime = 'edge'; |
| 15 | +export const alt = 'Cockpit — the live reference app for the Angular Agent Framework'; |
| 16 | +export const size = { width: 1200, height: 630 }; |
| 17 | +export const contentType = 'image/png'; |
| 18 | + |
| 19 | +async function loadFont(family: string, weight: number): Promise<ArrayBuffer | null> { |
| 20 | + try { |
| 21 | + const css = await fetch( |
| 22 | + `https://fonts.googleapis.com/css2?family=${encodeURIComponent(family)}:wght@${weight}&display=swap`, |
| 23 | + { headers: { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36' } }, |
| 24 | + ).then((res) => res.text()); |
| 25 | + const match = css.match(/src:\s*url\((https?:\/\/[^)]+)\)/); |
| 26 | + if (!match) return null; |
| 27 | + const fontRes = await fetch(match[1]); |
| 28 | + if (!fontRes.ok) return null; |
| 29 | + return await fontRes.arrayBuffer(); |
| 30 | + } catch { |
| 31 | + return null; |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +export default async function OpenGraphImage() { |
| 36 | + const [interRegular, interBold, monoBold] = await Promise.all([ |
| 37 | + loadFont('Inter', 400), |
| 38 | + loadFont('Inter', 600), |
| 39 | + loadFont('JetBrains+Mono', 700), |
| 40 | + ]); |
| 41 | + const fonts = [ |
| 42 | + interRegular && { name: 'Inter', data: interRegular, weight: 400 as const, style: 'normal' as const }, |
| 43 | + interBold && { name: 'Inter', data: interBold, weight: 700 as const, style: 'normal' as const }, |
| 44 | + monoBold && { name: 'JetBrains Mono', data: monoBold, weight: 700 as const, style: 'normal' as const }, |
| 45 | + ].filter((f): f is NonNullable<typeof f> => f !== null); |
| 46 | + |
| 47 | + return new ImageResponse( |
| 48 | + ( |
| 49 | + <div |
| 50 | + style={{ |
| 51 | + width: '100%', |
| 52 | + height: '100%', |
| 53 | + background: '#f4f6fb', |
| 54 | + display: 'flex', |
| 55 | + flexDirection: 'column', |
| 56 | + padding: '64px 72px', |
| 57 | + color: '#1a1a2e', |
| 58 | + fontFamily: 'Inter, sans-serif', |
| 59 | + }} |
| 60 | + > |
| 61 | + {/* Eyebrow */} |
| 62 | + <div |
| 63 | + style={{ |
| 64 | + fontFamily: 'JetBrains Mono, monospace', |
| 65 | + fontSize: 16, |
| 66 | + letterSpacing: '0.12em', |
| 67 | + color: '#004090', |
| 68 | + fontWeight: 700, |
| 69 | + textTransform: 'uppercase', |
| 70 | + marginBottom: 24, |
| 71 | + }} |
| 72 | + > |
| 73 | + Cockpit · Angular Agent Framework |
| 74 | + </div> |
| 75 | + |
| 76 | + {/* Headline — Inter Bold (cockpit chrome is sans-serif Linear-style) */} |
| 77 | + <div |
| 78 | + style={{ |
| 79 | + fontSize: 68, |
| 80 | + lineHeight: 1.08, |
| 81 | + fontWeight: 700, |
| 82 | + letterSpacing: '-0.02em', |
| 83 | + color: '#1a1a2e', |
| 84 | + marginBottom: 22, |
| 85 | + maxWidth: 1000, |
| 86 | + }} |
| 87 | + > |
| 88 | + The live reference app for the framework. |
| 89 | + </div> |
| 90 | + |
| 91 | + {/* Subhead */} |
| 92 | + <div |
| 93 | + style={{ |
| 94 | + fontSize: 24, |
| 95 | + lineHeight: 1.5, |
| 96 | + color: '#555770', |
| 97 | + maxWidth: 940, |
| 98 | + marginBottom: 'auto', |
| 99 | + }} |
| 100 | + > |
| 101 | + Real LangGraph and AG-UI agents running through the same Angular surface you'll ship. |
| 102 | + Switch between Run · Code · Docs · API for each capability. |
| 103 | + </div> |
| 104 | + |
| 105 | + {/* Mode pills + cockpit wordmark */} |
| 106 | + <div |
| 107 | + style={{ |
| 108 | + display: 'flex', |
| 109 | + alignItems: 'center', |
| 110 | + justifyContent: 'space-between', |
| 111 | + marginTop: 32, |
| 112 | + }} |
| 113 | + > |
| 114 | + <div style={{ display: 'flex', gap: 10 }}> |
| 115 | + {['Run', 'Code', 'Docs', 'API'].map((mode, i) => ( |
| 116 | + <ModePill key={mode} active={i === 0}>{mode}</ModePill> |
| 117 | + ))} |
| 118 | + </div> |
| 119 | + <div |
| 120 | + style={{ |
| 121 | + display: 'flex', |
| 122 | + alignItems: 'center', |
| 123 | + gap: 10, |
| 124 | + fontFamily: 'JetBrains Mono, monospace', |
| 125 | + fontSize: 18, |
| 126 | + fontWeight: 700, |
| 127 | + color: '#1a1a2e', |
| 128 | + }} |
| 129 | + > |
| 130 | + <span style={{ fontSize: 26 }}>🛩️</span> |
| 131 | + <span>cockpit.cacheplane.ai</span> |
| 132 | + </div> |
| 133 | + </div> |
| 134 | + </div> |
| 135 | + ), |
| 136 | + { |
| 137 | + ...size, |
| 138 | + fonts, |
| 139 | + }, |
| 140 | + ); |
| 141 | +} |
| 142 | + |
| 143 | +interface ModePillProps { |
| 144 | + active: boolean; |
| 145 | + children: React.ReactNode; |
| 146 | +} |
| 147 | + |
| 148 | +/** Mimics the cockpit mode-switcher: rounded pill, accent on the active one. */ |
| 149 | +function ModePill({ active, children }: ModePillProps) { |
| 150 | + return ( |
| 151 | + <div |
| 152 | + style={{ |
| 153 | + display: 'flex', |
| 154 | + alignItems: 'center', |
| 155 | + padding: '8px 20px', |
| 156 | + borderRadius: 999, |
| 157 | + background: active ? '#004090' : '#ffffff', |
| 158 | + border: `1px solid ${active ? '#004090' : '#e6e8ee'}`, |
| 159 | + color: active ? '#ffffff' : '#555770', |
| 160 | + fontFamily: 'JetBrains Mono, monospace', |
| 161 | + fontSize: 15, |
| 162 | + fontWeight: 700, |
| 163 | + }} |
| 164 | + > |
| 165 | + {children} |
| 166 | + </div> |
| 167 | + ); |
| 168 | +} |
0 commit comments