Skip to content

Commit e6d926d

Browse files
committed
fix OG preview: use lazy loading, inline width, overflow-x-auto for thumbnails
1 parent c80f0a0 commit e6d926d

1 file changed

Lines changed: 36 additions & 39 deletions

File tree

  • packages/app/src/app/blog/og-preview

packages/app/src/app/blog/og-preview/page.tsx

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,54 +50,51 @@ const VARIANTS = [
5050
{ id: 'v25', name: 'V25: Gold Accent Stripe — Thick gold left stripe, massive title, minimal' },
5151
];
5252

53-
// Common platform render sizes for OG images
54-
const SIZES = [
55-
{ label: 'Full (1200×630)', w: 1200, h: 630 },
56-
{ label: 'Twitter/X (~500×262)', w: 500, h: 262 },
57-
{ label: 'Slack (~360×189)', w: 360, h: 189 },
58-
{ label: 'iMessage (~300×157)', w: 300, h: 157 },
59-
];
53+
function OgImg({ v, w, label }: { v: string; w: number; label: string }) {
54+
const h = Math.round(w * (630 / 1200));
55+
return (
56+
<div style={{ width: w, flexShrink: 0 }}>
57+
<span className="text-xs text-muted-foreground block mb-1">{label}</span>
58+
{/* eslint-disable-next-line @next/next/no-img-element */}
59+
<img
60+
src={`/api/og-preview?slug=hello-world&v=${v}`}
61+
alt={`${v} at ${w}px`}
62+
width={w}
63+
height={h}
64+
loading="lazy"
65+
style={{ display: 'block', width: w, height: h }}
66+
className="rounded border border-border"
67+
/>
68+
</div>
69+
);
70+
}
6071

6172
export default function OgPreviewPage() {
6273
return (
63-
<main className="container mx-auto px-4 py-12 max-w-7xl overflow-hidden">
74+
<main className="container mx-auto px-4 py-12 max-w-5xl">
6475
<h1 className="text-3xl font-bold mb-2">OG Image Variants Preview</h1>
6576
<p className="text-muted-foreground mb-10">
66-
Each variant shown at actual platform render sizes. V1–V10: generic. V11–V15: brand palette.
67-
V16–V20: GSA slide style. V21–V25: thumbnail-optimized.
77+
Each variant at full size, then at Twitter, Slack, and iMessage render sizes.
6878
</p>
69-
<div className="flex flex-col gap-14">
79+
<div className="flex flex-col gap-12">
7080
{VARIANTS.map((v) => (
7181
<div key={v.id} className="flex flex-col gap-3">
7282
<h2 className="text-lg font-semibold">{v.name}</h2>
73-
{/* Full size */}
74-
<div className="flex flex-col gap-1">
75-
<span className="text-xs text-muted-foreground">Full (1200×630)</span>
76-
{/* eslint-disable-next-line @next/next/no-img-element */}
77-
<img
78-
src={`/api/og-preview?slug=hello-world&v=${v.id}`}
79-
alt={`${v.name} full size`}
80-
width={1200}
81-
height={630}
82-
className="w-full rounded border border-border"
83-
/>
84-
</div>
85-
{/* Platform sizes */}
86-
<div className="flex gap-4 items-end">
87-
{SIZES.slice(1).map((s) => (
88-
<div key={s.label} className="flex flex-col gap-1">
89-
<span className="text-xs text-muted-foreground">{s.label}</span>
90-
{/* eslint-disable-next-line @next/next/no-img-element */}
91-
<img
92-
src={`/api/og-preview?slug=hello-world&v=${v.id}`}
93-
alt={`${v.name} at ${s.label}`}
94-
width={s.w}
95-
height={s.h}
96-
style={{ width: s.w, height: s.h, maxWidth: 'none' }}
97-
className="rounded border border-border shrink-0"
98-
/>
99-
</div>
100-
))}
83+
{/* Full width */}
84+
{/* eslint-disable-next-line @next/next/no-img-element */}
85+
<img
86+
src={`/api/og-preview?slug=hello-world&v=${v.id}`}
87+
alt={`${v.name} full`}
88+
width={1200}
89+
height={630}
90+
loading="lazy"
91+
className="w-full rounded border border-border"
92+
/>
93+
{/* Platform thumbnails */}
94+
<div className="flex gap-4 items-start overflow-x-auto">
95+
<OgImg v={v.id} w={500} label="Twitter/X" />
96+
<OgImg v={v.id} w={360} label="Slack" />
97+
<OgImg v={v.id} w={300} label="iMessage" />
10198
</div>
10299
</div>
103100
))}

0 commit comments

Comments
 (0)