Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): redesign OG images in the homepage sky style (#2338)
Richie McIlroy26e1a6d882f3
diff --git a/apps/web/__tests__/unit/og-thumbnail.test.ts b/apps/web/__tests__/unit/og-thumbnail.test.tsnew file mode 100644index 000000000..7fb91d2d0--- /dev/null+++ b/apps/web/__tests__/unit/og-thumbnail.test.ts@@ -0,0 +1,126 @@+import { afterEach, describe, expect, it, vi } from "vitest";+import { coverRect, imageSize, loadOgThumbnail } from "../../lib/og/thumbnail";++const png = (width: number, height: number) => {+ const buf = Buffer.alloc(33);+ buf.writeUInt32BE(0x89504e47, 0);+ buf.writeUInt32BE(0x0d0a1a0a, 4);+ buf.writeUInt32BE(13, 8);+ buf.write("IHDR", 12, "ascii");+ buf.writeUInt32BE(width, 16);+ buf.writeUInt32BE(height, 20);+ return buf;+};++const jpeg = (width: number, height: number) =>+ Buffer.from([+ 0xff,+ 0xd8,+ 0xff,+ 0xe0,+ 0x00,+ 0x04,+ 0x00,+ 0x00,+ 0xff,+ 0xc0,+ 0x00,+ 0x11,+ 0x08,+ height >> 8,+ height & 0xff,+ width >> 8,+ width & 0xff,+ 0x03,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ ]);++const webpLossless = (width: number, height: number) => {+ const buf = Buffer.alloc(30);+ buf.write("RIFF", 0, "ascii");+ buf.write("WEBP", 8, "ascii");+ buf.write("VP8L", 12, "ascii");+ buf.writeUInt32LE((width - 1) | ((height - 1) << 14), 21);+ return buf;+};++describe("imageSize", () => {+ it("reads PNG, JPEG, WebP and GIF headers", () => {+ expect(imageSize(png(1920, 1080))).toEqual({ width: 1920, height: 1080 });+ expect(imageSize(jpeg(1440, 900))).toEqual({ width: 1440, height: 900 });+ expect(imageSize(webpLossless(800, 600))).toEqual({+ width: 800,+ height: 600,+ });+ const gif = Buffer.alloc(10);+ gif.write("GIF89a", 0, "ascii");+ gif.writeUInt16LE(320, 6);+ gif.writeUInt16LE(240, 8);+ expect(imageSize(gif)).toEqual({ width: 320, height: 240 });+ });++ it("rejects unknown or truncated data", () => {+ expect(imageSize(Buffer.from("not an image"))).toBeUndefined();+ expect(imageSize(Buffer.from([0xff, 0xd8, 0xff]))).toBeUndefined();+ expect(imageSize(png(0, 100))).toBeUndefined();+ });+});++describe("coverRect", () => {+ const box = { width: 600, height: 338 };++ it("fills the box and centres the overflow", () => {+ const tall = coverRect({ width: 1440, height: 1080 }, box);+ expect(tall.width).toBe(600);+ expect(tall.height).toBeGreaterThanOrEqual(338);+ expect(tall.top).toBe(Math.floor((338 - tall.height) / 2));+ const wide = coverRect({ width: 3000, height: 1000 }, box);+ expect(wide.height).toBe(338);+ expect(wide.width).toBeGreaterThanOrEqual(600);+ expect(wide.left).toBe(Math.floor((600 - wide.width) / 2));+ });+});++describe("loadOgThumbnail", () => {+ afterEach(() => vi.unstubAllGlobals());++ it("keeps data URIs and measures them", async () => {+ const uri = `data:image/png;base64,${png(1280, 720).toString("base64")}`;+ expect(await loadOgThumbnail(uri)).toEqual({+ src: uri,+ width: 1280,+ height: 720,+ });+ });++ it("inlines remote images", async () => {+ vi.stubGlobal(+ "fetch",+ vi.fn(async () => new Response(jpeg(1440, 900))),+ );+ const thumb = await loadOgThumbnail("https://example.com/shot.jpg");+ expect(thumb?.width).toBe(1440);+ expect(thumb?.src.startsWith("data:image/jpeg;base64,")).toBe(true);+ });++ it("returns undefined when the image can't be loaded", async () => {+ vi.stubGlobal(+ "fetch",+ vi.fn(async () => new Response("nope", { status: 403 })),+ );+ expect(await loadOgThumbnail("https://example.com/x.png")).toBeUndefined();+ vi.stubGlobal(+ "fetch",+ vi.fn(async () => {+ throw new Error("network");+ }),+ );+ expect(await loadOgThumbnail("https://example.com/x.png")).toBeUndefined();+ expect(await loadOgThumbnail("file:///etc/passwd")).toBeUndefined();+ });+});diff --git a/apps/web/app/(site)/pricing/page.tsx b/apps/web/app/(site)/pricing/page.tsxindex a0a9175d2..d2d924b99 100644--- a/apps/web/app/(site)/pricing/page.tsx+++ b/apps/web/app/(site)/pricing/page.tsx@@ -7,7 +7,9 @@ export const metadata: Metadata = buildMarketingMetadata({description:"Self-serve Cap Pro for organizations with thousands of members, with SOC 2 Type II, ISO 27001 & HIPAA compliance. Add SAML SSO ($199/mo) or a signed BAA ($99/mo) from your dashboard. SCIM can be arranged.",path: "/pricing",- ogTitle: "Simple, transparent pricing",+ ogTitle: "Simple, honest pricing",+ ogDescription:+ "Start free. Pay when you need commercial rights or the cloud, and cancel whenever you like.",ogTag: "Pricing",});diff --git a/apps/web/app/api/og/route.tsx b/apps/web/app/api/og/route.tsxindex 65db863c6..261fde36a 100644--- a/apps/web/app/api/og/route.tsx+++ b/apps/web/app/api/og/route.tsx@@ -1,16 +1,18 @@import { ImageResponse } from "next/og";import type { NextRequest } from "next/server";+import { PRICING } from "@/data/pricing";+import { loadOgAssets } from "@/lib/og/assets";import { loadOgFonts } from "@/lib/og/fonts";import { verifyOgSignature } from "@/lib/og/signature";import {+ Body,CapWordmark,+ DesktopArt,+ Headline,OG_HEIGHT,- OG_INK,- OG_INK_SOFT,OG_WIDTH,- RecorderCard,- SkyBackground,- TagChip,+ OgCanvas,+ PricingArt,titleFontSize,} from "@/lib/og/template";@@ -51,89 +53,66 @@ export async function GET(req: NextRequest) {: undefined;const isDefault = !isSigned;+ const [fonts, assets] = await Promise.all([loadOgFonts(), loadOgAssets()]);+ const body = description ?? (isDefault ? DEFAULT_DESCRIPTION : undefined);+ const art =+ tag === "Pricing" ? (+ <div+ style={{ display: "flex", position: "absolute", left: 660, top: 96 }}+ >+ <PricingArt+ mesh={assets.mesh}+ pro={{+ monthly: PRICING.pro.monthly,+ annualPerMonth: PRICING.pro.annualPerMonth,+ savePercent: Math.round(+ (1 - PRICING.pro.annualPerMonth / PRICING.pro.monthly) * 100,+ ),+ }}+ />+ </div>+ ) : (+ <div+ style={{ display: "flex", position: "absolute", left: 668, top: 112 }}+ >+ <DesktopArt mesh={assets.mesh} wallpaper={assets.wallpaper} />+ </div>+ );+return new ImageResponse(- <SkyBackground>+ <OgCanvas background={assets.skySplit}>+ {art}<divstyle={{display: "flex",position: "absolute",top: 0,left: 0,- width: "100%",+ width: 620,height: "100%",- padding: "56px 64px",- alignItems: "center",- gap: 56,+ padding: "58px 0 54px 64px",+ flexDirection: "column",+ justifyContent: "space-between",}}>- <div- style={{- display: "flex",- flexDirection: "column",- flexGrow: 1,- flexShrink: 1,- minWidth: 0,- height: "100%",- justifyContent: "space-between",- }}- >- <CapWordmark height={60} color={OG_INK} />- <div- style={{- display: "flex",- flexDirection: "column",- gap: 22,- paddingBottom: 8,- }}- >- {tag && <TagChip label={tag} />}- <span- style={{- display: "block",- fontSize: titleFontSize(title),- fontWeight: 500,- color: OG_INK,- lineHeight: 1.1,- letterSpacing: -0.5,- lineClamp: 4,- }}- >- {title}- </span>- {(description ?? (isDefault ? DEFAULT_DESCRIPTION : undefined)) && (- <span- style={{- display: "block",- fontSize: 27,- fontWeight: 400,- color: OG_INK_SOFT,- lineHeight: 1.4,- lineClamp: 2,- }}- >- {description ?? DEFAULT_DESCRIPTION}- </span>- )}- </div>- <span- style={{- fontSize: 24,- fontWeight: 500,- color: OG_INK_SOFT,- }}- >- Cap.so- </span>- </div>- <div style={{ display: "flex", flexShrink: 0 }}>- <RecorderCard width={384} />+ <CapWordmark />+ <div style={{ display: "flex", flexDirection: "column", gap: 26 }}>+ <Headline size={titleFontSize(title)} lines={4}>+ {title}+ </Headline>+ {body && (+ <Body size={25} lines={title.length > 30 ? 2 : 3}>+ {body}+ </Body>+ )}</div>+ <div style={{ display: "flex", height: 52 }} /></div>- </SkyBackground>,+ </OgCanvas>,{width: OG_WIDTH,height: OG_HEIGHT,- fonts: await loadOgFonts(),+ fonts,headers: {// The image is a pure function of the URL, so it can be cached// forever — changed copy produces a different URL.diff --git a/apps/web/lib/og/assets.ts b/apps/web/lib/og/assets.tsnew file mode 100644index 000000000..8285174e0--- /dev/null+++ b/apps/web/lib/og/assets.ts@@ -0,0 +1,37 @@+import { readFile } from "node:fs/promises";+import path from "node:path";++// Baked by scripts/og-sky/render.py: the painted hero sky, the Instant-mode+// mesh used for product frames, and the desktop wallpaper. Satori can't draw+// clouds or grain, so they ship as JPEGs and are inlined as data URIs.+const FILES = {+ skySplit: "sky-split.jpg",+ skyCenter: "sky-center.jpg",+ mesh: "mesh-instant.jpg",+ wallpaper: "wallpaper.jpg",+} as const;++export type OgAssets = Record<keyof typeof FILES, string>;++let assetsPromise: Promise<OgAssets> | null = null;++const loadAsset = async (file: string) => {+ const data = await readFile(+ path.join(process.cwd(), "lib", "og", "assets", file),+ );+ return `data:image/jpeg;base64,${data.toString("base64")}`;+};++export const loadOgAssets = () => {+ assetsPromise ??= Promise.all(+ Object.entries(FILES).map(+ async ([key, file]) => [key, await loadAsset(file)] as const,+ ),+ )+ .then((entries) => Object.fromEntries(entries) as OgAssets)+ .catch((error) => {+ assetsPromise = null;+ throw error;+ });+ return assetsPromise;+};diff --git a/apps/web/lib/og/assets/mesh-instant.jpg b/apps/web/lib/og/assets/mesh-instant.jpgnew file mode 100644index 000000000..74e6ad5f4Binary files /dev/null and b/apps/web/lib/og/assets/mesh-instant.jpg differdiff --git a/apps/web/lib/og/assets/sky-center.jpg b/apps/web/lib/og/assets/sky-center.jpgnew file mode 100644index 000000000..049f8c5e4Binary files /dev/null and b/apps/web/lib/og/assets/sky-center.jpg differdiff --git a/apps/web/lib/og/assets/sky-split.jpg b/apps/web/lib/og/assets/sky-split.jpgnew file mode 100644index 000000000..5bbeef93dBinary files /dev/null and b/apps/web/lib/og/assets/sky-split.jpg differdiff --git a/apps/web/lib/og/assets/wallpaper.jpg b/apps/web/lib/og/assets/wallpaper.jpgnew file mode 100644index 000000000..50afe8b1eBinary files /dev/null and b/apps/web/lib/og/assets/wallpaper.jpg differdiff --git a/apps/web/lib/og/fonts.ts b/apps/web/lib/og/fonts.tsindex bda5c1271..5adfef4ad 100644--- a/apps/web/lib/og/fonts.ts+++ b/apps/web/lib/og/fonts.ts@@ -4,13 +4,18 @@ import path from "node:path";export type OgFont = {name: string;data: ArrayBuffer;- weight: 400 | 500 | 700;+ weight: 300 | 400 | 500;style: "normal";};+export const OG_SANS = "Instrument Sans";+export const OG_SERIF = "Source Serif";+export const OG_MONO = "DM Mono";+let fontsPromise: Promise<OgFont[]> | null = null;const loadFont = async (+ name: string,file: string,weight: OgFont["weight"],): Promise<OgFont> => {@@ -18,7 +23,7 @@ const loadFont = async (path.join(process.cwd(), "lib", "og", "fonts", file),);return {- name: "Neue Montreal",+ name,data: data.buffer.slice(data.byteOffset,data.byteOffset + data.byteLength,@@ -30,9 +35,11 @@ const loadFont = async (export const loadOgFonts = () => {fontsPromise ??= Promise.all([- loadFont("NeueMontreal-Regular.ttf", 400),- loadFont("NeueMontreal-Medium.ttf", 500),- loadFont("NeueMontreal-Bold.ttf", 700),+ loadFont(OG_SANS, "InstrumentSans-Regular.ttf", 400),+ loadFont(OG_SANS, "InstrumentSans-Medium.ttf", 500),+ loadFont(OG_SERIF, "SourceSerif4-Light.ttf", 300),+ loadFont(OG_MONO, "DMMono-Regular.ttf", 400),+ loadFont(OG_MONO, "DMMono-Medium.ttf", 500),]).catch((error) => {fontsPromise = null;throw error;diff --git a/apps/web/lib/og/fonts/DMMono-Medium.ttf b/apps/web/lib/og/fonts/DMMono-Medium.ttfnew file mode 100644index 000000000..e7705f861Binary files /dev/null and b/apps/web/lib/og/fonts/DMMono-Medium.ttf differdiff --git a/apps/web/lib/og/fonts/DMMono-Regular.ttf b/apps/web/lib/og/fonts/DMMono-Regular.ttfnew file mode 100644index 000000000..ec7540a3cBinary files /dev/null and b/apps/web/lib/og/fonts/DMMono-Regular.ttf differdiff --git a/apps/web/lib/og/fonts/InstrumentSans-Medium.ttf b/apps/web/lib/og/fonts/InstrumentSans-Medium.ttfnew file mode 100644index 000000000..9b00a5295Binary files /dev/null and b/apps/web/lib/og/fonts/InstrumentSans-Medium.ttf differdiff --git a/apps/web/lib/og/fonts/InstrumentSans-Regular.ttf b/apps/web/lib/og/fonts/InstrumentSans-Regular.ttfnew file mode 100644index 000000000..177e4ec11Binary files /dev/null and b/apps/web/lib/og/fonts/InstrumentSans-Regular.ttf differdiff --git a/apps/web/lib/og/fonts/NeueMontreal-Bold.ttf b/apps/web/lib/og/fonts/NeueMontreal-Bold.ttfdeleted file mode 100644index aa8220026..000000000Binary files a/apps/web/lib/og/fonts/NeueMontreal-Bold.ttf and /dev/null differdiff --git a/apps/web/lib/og/fonts/NeueMontreal-Medium.ttf b/apps/web/lib/og/fonts/NeueMontreal-Medium.ttfdeleted file mode 100644index 558793156..000000000Binary files a/apps/web/lib/og/fonts/NeueMontreal-Medium.ttf and /dev/null differdiff --git a/apps/web/lib/og/fonts/NeueMontreal-Regular.ttf b/apps/web/lib/og/fonts/NeueMontreal-Regular.ttfdeleted file mode 100644index 06bbfc6c5..000000000Binary files a/apps/web/lib/og/fonts/NeueMontreal-Regular.ttf and /dev/null differdiff --git a/apps/web/lib/og/fonts/SourceSerif4-Light.ttf b/apps/web/lib/og/fonts/SourceSerif4-Light.ttfnew file mode 100644index 000000000..6afef9648Binary files /dev/null and b/apps/web/lib/og/fonts/SourceSerif4-Light.ttf differdiff --git a/apps/web/lib/og/template.tsx b/apps/web/lib/og/template.tsxindex a43459968..8ef6c129f 100644--- a/apps/web/lib/og/template.tsx+++ b/apps/web/lib/og/template.tsx@@ -1,14 +1,14 @@import type { CSSProperties, ReactNode } from "react";+import { OG_MONO, OG_SANS, OG_SERIF } from "@/lib/og/fonts";export const OG_WIDTH = 1200;export const OG_HEIGHT = 630;export const OG_BLUE = "#4785FF";-export const OG_BLUE_DEEP = "#2E6FF2";export const OG_BLUE_LIGHT = "#ADC9FF";-/** Dark ink for text on the light sky — deep navy so it stays on-palette. */-export const OG_INK = "#122142";-export const OG_INK_SOFT = "rgba(18,33,66,0.74)";+export const OG_INK = "#111111";+export const OG_INK_SOFT = "rgba(17,17,17,0.74)";+export const OG_INK_MUTED = "rgba(17,17,17,0.5)";// Light-mode UI palette approximating the desktop app's gray scale.const UI = {@@ -31,185 +31,123 @@ const flex = (extra: CSSProperties = {}): CSSProperties => ({...extra,});-const CloudPuff = ({- size,- left,- top,- opacity = 1,+export const OgCanvas = ({+ background,+ children,}: {- size: number;- left: number;- top: number;- opacity?: number;+ background: string;+ children: ReactNode;}) => (<divstyle={flex({- position: "absolute",- left,- top,- width: size,- height: size,- borderRadius: 9999,- opacity,- background:- "radial-gradient(circle, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0.45) 42%, rgba(255,255,255,0) 68%)",+ width: "100%",+ height: "100%",+ position: "relative",+ fontFamily: OG_SANS,+ color: OG_INK,+ background: "#EDF1F6",})}- />+ >+ <div+ style={flex({+ position: "absolute",+ top: 0,+ left: 0,+ width: OG_WIDTH,+ height: OG_HEIGHT,+ backgroundImage: `url(${background})`,+ backgroundSize: `${OG_WIDTH}px ${OG_HEIGHT}px`,+ })}+ />+ {children}+ </div>);-/** A soft glowing star — a point of light with falloff, not a clip-art shape. */-const Star = ({+export const Headline = ({+ children,size,- left,- top,- opacity = 0.7,+ lines = 3,}: {+ children: string;size: number;- left: number;- top: number;- opacity?: number;+ lines?: number;}) => (- <div- style={flex({- position: "absolute",- left,- top,- width: size,- height: size,- opacity,- background:- "radial-gradient(circle, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.4) 28%, rgba(255,255,255,0) 62%)",- })}- />+ <span+ style={{+ display: "block",+ fontSize: size,+ fontWeight: 400,+ lineHeight: 1.02,+ letterSpacing: -size * 0.03,+ color: OG_INK,+ lineClamp: lines,+ }}+ >+ {children}+ </span>);-/** A brighter star with thin lens-flare points and its own halo. */-const Twinkle = ({- size,- left,- top,- opacity = 0.8,+export const Body = ({+ children,+ size = 27,+ lines = 2,}: {- size: number;- left: number;- top: number;- opacity?: number;+ children: string;+ size?: number;+ lines?: number;}) => (- <div- style={flex({- position: "absolute",- left,- top,- width: size,- height: size,- opacity,- alignItems: "center",- justifyContent: "center",- background:- "radial-gradient(circle, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.18) 34%, rgba(255,255,255,0) 62%)",- })}+ <span+ style={{+ display: "block",+ fontFamily: OG_SERIF,+ fontSize: size,+ fontWeight: 300,+ lineHeight: 1.38,+ letterSpacing: -size * 0.01,+ color: OG_INK_SOFT,+ lineClamp: lines,+ }}>- <svg- role="img"- aria-label="Star"- width={Math.round(size * 0.72)}- height={Math.round(size * 0.72)}- viewBox="0 0 24 24"- >- <path- d="M12 0 Q12.7 10.6 24 12 Q12.7 13.4 12 24 Q11.3 13.4 0 12 Q11.3 10.6 12 0 Z"- fill="white"- />- </svg>- </div>+ {children}+ </span>);-/**- * The signature Cap sky — dusk blue gradient, a natural drift of stars high- * in the sky, soft cloud banks at the horizon. Pure vectors, no remote assets.- * Star/cloud placement assumes the shared layout: wordmark top-left, text- * column on the left, app card on the right — the upper band (y < 110,- * x > 330) and the horizon stay clear of both.- */-export const SkyBackground = ({ children }: { children: ReactNode }) => (+export const MeshFrame = ({+ mesh,+ width,+ height,+ padding = 12,+ radius = 28,+ children,+}: {+ mesh: string;+ width: number;+ height: number;+ padding?: number;+ radius?: number;+ children: ReactNode;+}) => (<divstyle={flex({- width: "100%",- height: "100%",position: "relative",- fontFamily: "Neue Montreal",- background: `linear-gradient(172deg, #9DBEFF 0%, ${OG_BLUE_LIGHT} 44%, #C6D9FF 76%, #E1ECFF 100%)`,+ width,+ height,+ padding,+ borderRadius: radius,+ overflow: "hidden",+ boxShadow:+ "0 40px 80px -24px rgba(40,72,130,0.35), 0 0 0 1px rgba(255,255,255,0.55)",})}>- {/* horizon glow, behind the card */}<divstyle={flex({position: "absolute",top: 0,left: 0,- width: "100%",- height: "100%",- background:- "radial-gradient(circle at 80% 118%, rgba(255,255,255,0.42) 0%, rgba(255,255,255,0) 52%)",- })}- />- {/* high atmosphere haze */}- <div- style={flex({- position: "absolute",- top: 0,- left: 0,- width: "100%",- height: "100%",- background:- "radial-gradient(circle at 62% -30%, rgba(120,165,255,0.4) 0%, rgba(120,165,255,0) 55%)",- })}- />- {/* cloud bank at the horizon, mostly behind the card */}- <CloudPuff size={560} left={760} top={440} opacity={0.85} />- <CloudPuff size={420} left={980} top={390} opacity={0.8} />- <CloudPuff size={360} left={640} top={520} opacity={0.65} />- <CloudPuff size={380} left={-150} top={540} opacity={0.35} />- {/* distant drift, high and faint */}- <CloudPuff size={280} left={310} top={-190} opacity={0.28} />- <CloudPuff size={300} left={950} top={-200} opacity={0.3} />- {/* stars — denser toward the top of the sky, fading out lower down */}- <Star size={12} left={352} top={38} opacity={0.6} />- <Star size={7} left={432} top={92} opacity={0.4} />- <Star size={15} left={520} top={26} opacity={0.75} />- <Star size={8} left={606} top={74} opacity={0.5} />- <Star size={6} left={672} top={20} opacity={0.45} />- <Star size={12} left={766} top={54} opacity={0.65} />- <Star size={8} left={864} top={22} opacity={0.5} />- <Star size={6} left={938} top={68} opacity={0.4} />- <Star size={9} left={1096} top={88} opacity={0.5} />- <Star size={11} left={1152} top={36} opacity={0.6} />- <Star size={6} left={288} top={26} opacity={0.35} />- <Star size={7} left={36} top={168} opacity={0.35} />- <Twinkle size={26} left={478} top={48} opacity={0.7} />- <Twinkle size={20} left={702} top={30} opacity={0.55} />- <Twinkle size={30} left={1032} top={18} opacity={0.8} />- {/* readability scrims — over the scenery, under the content */}- <div- style={flex({- position: "absolute",- top: 0,- left: 0,- width: "100%",- height: "100%",- background:- "linear-gradient(97deg, rgba(255,255,255,0.36) 0%, rgba(255,255,255,0.12) 40%, rgba(255,255,255,0) 62%)",- })}- />- <div- style={flex({- position: "absolute",- top: 0,- left: 0,- width: "100%",- height: "100%",- background:- "linear-gradient(0deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 28%)",+ width,+ height,+ backgroundImage: `url(${mesh})`,+ backgroundSize: `${width}px ${height}px`,})}/>{children}@@ -229,7 +167,6 @@ const logoMark = () => [const WORDMARK_PATH ="M58.416 30.448c-5.404 0-9.212-3.864-9.212-10.36 0-6.384 3.668-10.416 9.268-10.416 5.068 0 7.784 2.66 8.624 7.168l-3.808.196c-.476-2.604-2.072-4.2-4.816-4.2-3.388 0-5.488 2.828-5.488 7.252 0 4.48 2.156 7.196 5.46 7.196 2.94 0 4.508-1.708 4.956-4.564l3.808.196c-.784 4.676-3.752 7.532-8.792 7.532zm16.23-.112c-3.137 0-5.209-1.484-5.209-4.088 0-2.576 1.596-3.948 4.872-4.592l4.956-.98c0-2.1-.98-3.192-2.856-3.192-1.764 0-2.716.812-3.052 2.324l-3.668-.168c.588-3.136 2.996-4.928 6.72-4.928 4.256 0 6.44 2.24 6.44 6.216v5.432c0 .812.28 1.036.84 1.036h.476V30c-.224.056-.812.112-1.288.112-1.624 0-2.828-.588-3.136-2.436-.728 1.596-2.632 2.66-5.096 2.66zm.727-2.604c2.38 0 3.892-1.512 3.892-3.78v-.84l-3.864.784c-1.596.308-2.24.98-2.24 2.016 0 1.176.784 1.82 2.212 1.82zM86.874 34.2V15.048h3.444l.056 2.212c.868-1.652 2.52-2.548 4.48-2.548 4.256 0 6.356 3.5 6.356 7.812s-2.128 7.812-6.384 7.812c-1.904 0-3.556-.924-4.368-2.38V34.2h-3.584zm7.112-6.776c2.184 0 3.5-1.82 3.5-4.9s-1.316-4.9-3.5-4.9-3.528 1.652-3.528 4.9 1.316 4.9 3.528 4.9z";-/** The Cap app icon — the real LogoBadge: white rounded square, mark at 80%. */export const CapAppIcon = ({ size }: { size: number }) => (<divstyle={flex({@@ -252,10 +189,9 @@ export const CapAppIcon = ({ size }: { size: number }) => (</div>);-/** App icon + drawn "Cap" wordmark lockup (the brand OG header). */export const CapWordmark = ({- height = 60,- color = "white",+ height = 52,+ color = OG_INK,}: {height?: number;color?: string;@@ -862,42 +798,292 @@ export const RecorderCard = ({ width = 380 }: { width?: number }) => (</div>);-/**- * Pill chip used for page categories ("Pricing", "Blog", …), rendered as- * Liquid Glass: a mostly-transparent body over the sky with a bright- * refracted edge (inset highlights top and bottom) and a soft lift shadow.- * Single layer — a translucent fill over a nested "rim" gradient just shows- * the rim through the fill and reads as frosted plastic.- */-export const TagChip = ({ label }: { label: string }) => (+const AppleGlyph = ({ size }: { size: number }) => (+ <svg+ role="img"+ aria-label="Apple"+ width={size}+ height={size}+ viewBox="0 0 24 24"+ >+ <path+ fill="#111111"+ d="M16.37 12.7c-.02-2.3 1.88-3.4 1.96-3.46-1.07-1.56-2.73-1.77-3.32-1.8-1.41-.14-2.76.83-3.47.83-.72 0-1.82-.81-3-.79-1.54.02-2.96.9-3.76 2.28-1.6 2.78-.41 6.9 1.15 9.16.76 1.1 1.67 2.34 2.86 2.3 1.15-.05 1.58-.74 2.97-.74 1.38 0 1.78.74 2.99.72 1.24-.02 2.02-1.12 2.77-2.23.87-1.28 1.23-2.52 1.25-2.58-.03-.01-2.39-.92-2.4-3.65ZM14.1 5.94c.63-.77 1.06-1.83.94-2.9-.91.04-2.02.61-2.67 1.37-.58.67-1.1 1.76-.96 2.8 1.02.08 2.06-.52 2.69-1.27Z"+ />+ </svg>+);++const MenuBar = () => (<divstyle={flex({alignItems: "center",- alignSelf: "flex-start",- borderRadius: 999,- padding: "8px 21px",- background:- "linear-gradient(180deg, rgba(255,255,255,0.34) 0%, rgba(255,255,255,0.1) 100%)",- border: "1px solid rgba(255,255,255,0.65)",- boxShadow:- "inset 0 2px 4px rgba(255,255,255,0.7), inset 0 -3px 6px rgba(255,255,255,0.35), 0 8px 20px rgba(46,80,160,0.18)",+ height: 30,+ padding: "0 16px",+ gap: 18,+ background: "rgba(255,255,255,0.55)",+ fontSize: 13,+ fontWeight: 500,+ color: "#111111",})}>- <span- style={{- fontSize: 21,- fontWeight: 500,- color: OG_INK,- }}+ <AppleGlyph size={15} />+ <span style={{ fontWeight: 600 }}>Cap</span>+ <span style={{ fontWeight: 400 }}>File</span>+ <span style={{ fontWeight: 400 }}>Edit</span>+ <span style={{ fontWeight: 400 }}>View</span>+ <span style={{ fontWeight: 400 }}>Window</span>+ </div>+);++export const DesktopArt = ({+ mesh,+ wallpaper,+}: {+ mesh: string;+ wallpaper: string;+}) => (+ <MeshFrame mesh={mesh} width={640} height={580}>+ <div+ style={flex({+ position: "relative",+ flexDirection: "column",+ width: 616,+ height: 556,+ borderRadius: 18,+ overflow: "hidden",+ background: "#9FC0E6",+ })}>- {label}+ <div+ style={flex({+ position: "absolute",+ top: -10,+ left: -150,+ width: 1024,+ height: 576,+ backgroundImage: `url(${wallpaper})`,+ backgroundSize: "1024px 576px",+ })}+ />+ <MenuBar />+ <div+ style={flex({+ position: "absolute",+ left: 132,+ top: 64,+ })}+ >+ <RecorderCard width={380} />+ </div>+ </div>+ </MeshFrame>+);++const Segment = ({+ label,+ active,+ badge,+}: {+ label: string;+ active?: boolean;+ badge?: string;+}) => (+ <div+ style={flex({+ flexGrow: 1,+ flexBasis: 0,+ alignItems: "center",+ justifyContent: "center",+ gap: 8,+ height: 42,+ borderRadius: 10,+ background: active ? "#DCEBFC" : "transparent",+ fontSize: 16,+ fontWeight: 500,+ color: active ? OG_INK : "rgba(17,17,17,0.55)",+ })}+ >+ {label}+ {badge && (+ <span+ style={{+ fontFamily: OG_MONO,+ fontSize: 11,+ letterSpacing: 0.8,+ padding: "3px 7px",+ borderRadius: 6,+ background: "#E1EFFE",+ color: "#3D77C2",+ }}+ >+ {badge}+ </span>+ )}+ </div>+);++const PlanCardArt = ({+ name,+ chip,+ chipBg,+ chipColor,+ blurb,+ price,+ unit,+ note,+ children,+ width,+}: {+ name: string;+ chip: string;+ chipBg: string;+ chipColor: string;+ blurb: string;+ price: string;+ unit: string;+ note: string;+ children?: ReactNode;+ width: number;+}) => (+ <div+ style={flex({+ flexDirection: "column",+ width,+ height: "100%",+ padding: "30px 32px",+ borderRadius: 20,+ background: "white",+ })}+ >+ <div+ style={flex({ alignItems: "center", justifyContent: "space-between" })}+ >+ <span style={{ fontSize: 30, letterSpacing: -0.9 }}>{name}</span>+ <span+ style={{+ fontSize: 14,+ fontWeight: 500,+ padding: "5px 11px",+ borderRadius: 999,+ background: chipBg,+ color: chipColor,+ }}+ >+ {chip}+ </span>+ </div>+ <div style={flex({ marginTop: 14 })}>+ <Body size={19} lines={3}>+ {blurb}+ </Body>+ </div>+ <div style={flex({ alignItems: "flex-end", gap: 12, marginTop: 30 })}>+ <span style={{ fontSize: 68, lineHeight: 1, letterSpacing: -2.4 }}>+ {price}+ </span>+ <span+ style={{+ fontSize: 18,+ color: "rgba(17,17,17,0.6)",+ paddingBottom: 8,+ }}+ >+ {unit}+ </span>+ </div>+ <span style={{ marginTop: 18, fontSize: 16, color: "rgba(17,17,17,0.6)" }}>+ {note}</span>+ {children}+ </div>+);++export const PricingArt = ({+ mesh,+ pro,+}: {+ mesh: string;+ pro: { monthly: number; annualPerMonth: number; savePercent: number };+}) => (+ <MeshFrame mesh={mesh} width={500} height={620} padding={10} radius={30}>+ <PlanCardArt+ width={480}+ name="Cap Pro"+ chip="Most popular"+ chipBg="#DCEBFC"+ chipColor="#2F62D4"+ blurb="Everything in Desktop, plus unlimited cloud sharing, AI, and team collaboration."+ price={`$${pro.monthly}`}+ unit="per user, per month"+ note={`Or $${pro.annualPerMonth} a month, billed annually.`}+ >+ <div+ style={flex({+ marginTop: 26,+ padding: 5,+ borderRadius: 14,+ border: "1px solid #E1E7EE",+ })}+ >+ <Segment label="Monthly" active />+ <Segment label="Annual" badge={`SAVE ${pro.savePercent}%`} />+ </div>+ <div+ style={flex({+ marginTop: 24,+ alignItems: "center",+ justifyContent: "space-between",+ fontSize: 17,+ })}+ >+ <span>Users</span>+ <div style={flex({ alignItems: "center", gap: 18 })}>+ <StepperDot label="−" />+ <span>1</span>+ <StepperDot label="+" />+ </div>+ </div>+ <div+ style={flex({+ marginTop: 26,+ height: 54,+ borderRadius: 13,+ alignItems: "center",+ justifyContent: "center",+ fontSize: 18,+ fontWeight: 500,+ background:+ "linear-gradient(180deg, #F5FAFE 0%, #E3EFFB 52%, #CFE2F6 100%)",+ border: "1px solid rgba(63,127,205,0.65)",+ boxShadow: "0 10px 24px -10px rgba(120,178,240,0.55)",+ })}+ >+ Get Cap Pro+ </div>+ </PlanCardArt>+ </MeshFrame>+);++const StepperDot = ({ label }: { label: string }) => (+ <div+ style={flex({+ width: 32,+ height: 32,+ borderRadius: 9999,+ background: "#F1F4F8",+ alignItems: "center",+ justifyContent: "center",+ fontSize: 20,+ color: "rgba(17,17,17,0.6)",+ })}+ >+ {label}</div>);export const titleFontSize = (title: string) => {- if (title.length <= 24) return 76;- if (title.length <= 48) return 62;- if (title.length <= 72) return 52;- return 44;+ if (title.length <= 22) return 84;+ if (title.length <= 30) return 70;+ if (title.length <= 56) return 60;+ return 50;};diff --git a/apps/web/lib/og/thumbnail.ts b/apps/web/lib/og/thumbnail.tsnew file mode 100644index 000000000..fbc79b652--- /dev/null+++ b/apps/web/lib/og/thumbnail.ts@@ -0,0 +1,134 @@+// Satori has no working `background-size: cover` (non-matching aspect ratios+// leave gaps and remote URLs can render blank), so the thumbnail is loaded+// here, measured from its header, and drawn at an explicit cover size.++export type ImageSize = { width: number; height: number };++export type OgThumbnail = ImageSize & { src: string };++const FETCH_TIMEOUT_MS = 8000;+const MAX_BYTES = 12 * 1024 * 1024;++const pngSize = (buf: Buffer): ImageSize | undefined => {+ if (buf.length < 24 || buf.readUInt32BE(0) !== 0x89504e47) return;+ return { width: buf.readUInt32BE(16), height: buf.readUInt32BE(20) };+};++const gifSize = (buf: Buffer): ImageSize | undefined => {+ if (buf.length < 10 || buf.toString("ascii", 0, 3) !== "GIF") return;+ return { width: buf.readUInt16LE(6), height: buf.readUInt16LE(8) };+};++const webpSize = (buf: Buffer): ImageSize | undefined => {+ if (+ buf.length < 30 ||+ buf.toString("ascii", 0, 4) !== "RIFF" ||+ buf.toString("ascii", 8, 12) !== "WEBP"+ )+ return;+ const chunk = buf.toString("ascii", 12, 16);+ if (chunk === "VP8 ")+ return {+ width: buf.readUInt16LE(26) & 0x3fff,+ height: buf.readUInt16LE(28) & 0x3fff,+ };+ if (chunk === "VP8L") {+ const bits = buf.readUInt32LE(21);+ return { width: (bits & 0x3fff) + 1, height: ((bits >> 14) & 0x3fff) + 1 };+ }+ if (chunk === "VP8X")+ return {+ width: buf.readUIntLE(24, 3) + 1,+ height: buf.readUIntLE(27, 3) + 1,+ };+};++const jpegSize = (buf: Buffer): ImageSize | undefined => {+ if (buf.length < 4 || buf[0] !== 0xff || buf[1] !== 0xd8) return;+ let offset = 2;+ while (offset + 9 < buf.length) {+ if (buf[offset] !== 0xff) {+ offset++;+ continue;+ }+ const marker = buf[offset + 1] ?? 0;+ if (marker === 0xff) {+ offset++;+ continue;+ }+ const isStartOfFrame =+ marker >= 0xc0 &&+ marker <= 0xcf &&+ marker !== 0xc4 &&+ marker !== 0xc8 &&+ marker !== 0xcc;+ if (isStartOfFrame)+ return {+ height: buf.readUInt16BE(offset + 5),+ width: buf.readUInt16BE(offset + 7),+ };+ offset += 2 + buf.readUInt16BE(offset + 2);+ }+};++export const imageSize = (buf: Buffer): ImageSize | undefined => {+ const size = pngSize(buf) ?? jpegSize(buf) ?? webpSize(buf) ?? gifSize(buf);+ if (!size || size.width <= 0 || size.height <= 0) return;+ return size;+};++const mimeType = (buf: Buffer) => {+ if (pngSize(buf)) return "image/png";+ if (webpSize(buf)) return "image/webp";+ if (gifSize(buf)) return "image/gif";+ return "image/jpeg";+};++const readSource = async (url: string): Promise<Buffer | undefined> => {+ if (url.startsWith("data:")) {+ const comma = url.indexOf(",");+ if (comma === -1 || !url.slice(0, comma).endsWith(";base64")) return;+ return Buffer.from(url.slice(comma + 1), "base64");+ }+ if (!/^https?:\/\//i.test(url)) return;+ const res = await fetch(url, {+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),+ });+ if (!res.ok) return;+ const length = Number(res.headers.get("content-length") ?? 0);+ if (length > MAX_BYTES) return;+ const buf = Buffer.from(await res.arrayBuffer());+ if (buf.length > MAX_BYTES) return;+ return buf;+};++export const loadOgThumbnail = async (+ url: string,+): Promise<OgThumbnail | undefined> => {+ try {+ const buf = await readSource(url);+ if (!buf) return;+ const size = imageSize(buf);+ if (!size) return;+ return {+ ...size,+ src: url.startsWith("data:")+ ? url+ : `data:${mimeType(buf)};base64,${buf.toString("base64")}`,+ };+ } catch {+ return;+ }+};++export const coverRect = (image: ImageSize, box: ImageSize) => {+ const scale = Math.max(box.width / image.width, box.height / image.height);+ const width = Math.ceil(image.width * scale);+ const height = Math.ceil(image.height * scale);+ return {+ width,+ height,+ left: Math.floor((box.width - width) / 2),+ top: Math.floor((box.height - height) / 2),+ };+};diff --git a/apps/web/lib/og/video-og.tsx b/apps/web/lib/og/video-og.tsxindex 9d1946d25..ce8739372 100644--- a/apps/web/lib/og/video-og.tsx+++ b/apps/web/lib/og/video-og.tsx@@ -1,15 +1,21 @@import { ImageResponse } from "next/og";-import { loadOgFonts } from "@/lib/og/fonts";+import { loadOgAssets } from "@/lib/og/assets";+import { loadOgFonts, OG_MONO } from "@/lib/og/fonts";import {- CapAppIcon,+ Body,CapWordmark,- OG_BLUE,+ Headline,+ MeshFrame,OG_HEIGHT,OG_INK,- OG_INK_SOFT,OG_WIDTH,- SkyBackground,+ OgCanvas,} from "@/lib/og/template";+import {+ coverRect,+ loadOgThumbnail,+ type OgThumbnail,+} from "@/lib/og/thumbnail";export type VideoOgData = {title: string;@@ -50,23 +56,25 @@ const PlayButton = ({ size }: { size: number }) => (width: size,height: size,borderRadius: 9999,- background: OG_BLUE,- border: "5px solid rgba(255,255,255,0.9)",+ background: "rgba(255,255,255,0.92)",alignItems: "center",justifyContent: "center",- boxShadow: "0 12px 32px rgba(20,52,120,0.45)",+ boxShadow:+ "0 18px 40px -8px rgba(17,24,39,0.45), 0 0 0 8px rgba(255,255,255,0.28)",}}><svgrole="img"aria-label="Play"- width={Math.round(size * 0.42)}- height={Math.round(size * 0.42)}+ width={Math.round(size * 0.36)}+ height={Math.round(size * 0.36)}viewBox="0 0 24 24"- fill="white"style={{ marginLeft: Math.round(size * 0.05) }}>- <path d="M7 4.5 L19.5 12 L7 19.5 Z" />+ <path+ d="M7 3.8c0-.8.9-1.3 1.6-.9l12 7.6c.6.4.6 1.3 0 1.7l-12 7.6c-.7.4-1.6-.1-1.6-.9Z"+ fill={OG_INK}+ /></svg></div>);@@ -79,156 +87,125 @@ const LockIcon = ({ size }: { size: number }) => (height={size}viewBox="0 0 24 24"fill="none"- stroke="white"- strokeWidth="2"+ stroke={OG_INK}+ strokeWidth="1.7"strokeLinecap="round"strokeLinejoin="round">- <rect width="18" height="11" x="3" y="11" rx="2" ry="2" />- <path d="M7 11V7a5 5 0 0 1 10 0v4" />+ <rect width="16" height="11" x="4" y="10.5" rx="2.5" />+ <path d="M8 10.5V7a4 4 0 0 1 8 0v3.5" />+ <path d="M12 15v2" /></svg>);-/** Browser-chrome card holding the video thumbnail (or a branded fill). */-const VideoCard = ({- screenshotUrl,- width,- fill = "play",-}: {- screenshotUrl?: string;- width: number;- fill?: "play" | "lock" | "logo";-}) => {- const bodyHeight = Math.round((width * 9) / 16);+const SearchIcon = ({ size }: { size: number }) => (+ <svg+ role="img"+ aria-label="Not found"+ width={size}+ height={size}+ viewBox="0 0 24 24"+ fill="none"+ stroke={OG_INK}+ strokeWidth="1.7"+ strokeLinecap="round"+ strokeLinejoin="round"+ >+ <circle cx="11" cy="11" r="7" />+ <path d="m20 20-3.5-3.5" />+ </svg>+);++const THUMB_W = 600;+const THUMB_H = Math.round((THUMB_W * 9) / 16);+const FRAME_PAD = 12;++const ThumbnailImage = ({ thumbnail }: { thumbnail: OgThumbnail }) => {+ const rect = coverRect(thumbnail, { width: THUMB_W, height: THUMB_H });return (<divstyle={{display: "flex",- flexDirection: "column",- width,- borderRadius: 20,- background: "white",- boxShadow: "0 30px 60px rgba(20,52,120,0.25)",+ position: "absolute",+ top: rect.top,+ left: rect.left,+ width: rect.width,+ height: rect.height,+ backgroundImage: `url(${thumbnail.src})`,+ backgroundSize: `${rect.width}px ${rect.height}px`,+ backgroundRepeat: "no-repeat",+ }}+ />+ );+};++const Thumbnail = ({+ mesh,+ thumbnail,+ duration,+}: {+ mesh: string;+ thumbnail?: OgThumbnail;+ duration?: number;+}) => (+ <MeshFrame+ mesh={mesh}+ width={THUMB_W + FRAME_PAD * 2}+ height={THUMB_H + FRAME_PAD * 2}+ padding={FRAME_PAD}+ >+ <div+ style={{+ display: "flex",+ position: "relative",+ width: THUMB_W,+ height: THUMB_H,+ borderRadius: 16,+ overflow: "hidden",+ alignItems: "center",+ justifyContent: "center",+ background: thumbnail ? "#0B0F17" : "rgba(255,255,255,0.35)",+ boxShadow: "0 0 0 1px rgba(17,24,39,0.06)",}}>- <div- style={{- display: "flex",- alignItems: "center",- height: 44,- padding: "0 18px",- gap: 8,- }}- >+ {thumbnail && <ThumbnailImage thumbnail={thumbnail} />}+ {thumbnail && (<divstyle={{display: "flex",- width: 12,- height: 12,- borderRadius: 9999,- background: "#FF5F57",+ position: "absolute",+ top: 0,+ left: 0,+ width: "100%",+ height: "100%",+ background:+ "linear-gradient(180deg, rgba(17,24,39,0.06) 0%, rgba(17,24,39,0.18) 55%, rgba(17,24,39,0.42) 100%)",}}/>+ )}+ <PlayButton size={96} />+ {duration != null && duration > 0 && (<divstyle={{display: "flex",- width: 12,- height: 12,- borderRadius: 9999,- background: "#FEBC2E",- }}- />- <div- style={{- display: "flex",- width: 12,- height: 12,- borderRadius: 9999,- background: "#28C840",- }}- />- <div style={{ display: "flex", flexGrow: 1 }} />- <div- style={{- display: "flex",- alignItems: "center",- background: "#F3F4F6",- borderRadius: 8,- padding: "4px 14px",- fontSize: 15,- fontWeight: 500,- color: "#6B7280",+ position: "absolute",+ right: 16,+ bottom: 16,+ padding: "6px 12px",+ borderRadius: 999,+ background: "rgba(17,17,17,0.72)",+ fontFamily: OG_MONO,+ fontSize: 18,+ letterSpacing: 0.6,+ color: "white",}}>- cap.so+ {formatDuration(duration)}</div>- <div style={{ display: "flex", flexGrow: 1 }} />- <div style={{ display: "flex", width: 52 }} />- </div>- <div- style={{- display: "flex",- position: "relative",- width: "100%",- height: bodyHeight,- borderBottomLeftRadius: 20,- borderBottomRightRadius: 20,- overflow: "hidden",- alignItems: "center",- justifyContent: "center",- background: `linear-gradient(160deg, #D3E5FF 0%, ${OG_BLUE} 120%)`,- }}- >- {screenshotUrl && (- // biome-ignore lint/performance/noImgElement: satori renders raw img tags- <img- alt="Video thumbnail"- src={screenshotUrl}- width={width}- height={bodyHeight}- style={{- position: "absolute",- top: 0,- left: 0,- objectFit: "cover",- }}- />- )}- {screenshotUrl && (- // Fade the frame so the play button carries the card.- <div- style={{- display: "flex",- position: "absolute",- top: 0,- left: 0,- width: "100%",- height: "100%",- background: "rgba(18,32,66,0.32)",- }}- />- )}- {fill === "play" && <PlayButton size={92} />}- {fill === "lock" && (- <div- style={{- display: "flex",- width: 96,- height: 96,- borderRadius: 9999,- background: "rgba(30,64,150,0.55)",- alignItems: "center",- justifyContent: "center",- }}- >- <LockIcon size={44} />- </div>- )}- {fill === "logo" && <CapAppIcon size={96} />}- </div>+ )}</div>- );-};+ </MeshFrame>+);const InitialAvatar = ({ name }: { name: string }) => (<div@@ -237,145 +214,100 @@ const InitialAvatar = ({ name }: { name: string }) => (width: 44,height: 44,borderRadius: 9999,- background: "white",- color: OG_BLUE,- fontSize: 22,- fontWeight: 700,+ background: "#111111",+ color: "white",+ fontSize: 20,+ fontWeight: 500,alignItems: "center",justifyContent: "center",+ boxShadow: "0 0 0 3px rgba(255,255,255,0.7)",}}>{name.trim().charAt(0).toUpperCase()}</div>);-const videoLayout = (video: VideoOgData) => (- <SkyBackground>- <div- style={{- display: "flex",- position: "absolute",- top: 0,- left: 0,- width: "100%",- height: "100%",- padding: "52px 60px",- alignItems: "center",- gap: 48,- }}- >+const videoTitleSize = (title: string) => {+ if (title.length <= 24) return 60;+ if (title.length <= 48) return 50;+ return 42;+};++const videoLayout = (+ video: VideoOgData,+ thumbnail: OgThumbnail | undefined,+ assets: Awaited<ReturnType<typeof loadOgAssets>>,+) => {+ return (+ <OgCanvas background={assets.skySplit}><divstyle={{display: "flex",- flexDirection: "column",- flexGrow: 1,- flexShrink: 1,- minWidth: 0,+ position: "absolute",+ right: 52,+ top: Math.round((OG_HEIGHT - THUMB_H - FRAME_PAD * 2) / 2) + 20,+ }}+ >+ <Thumbnail+ mesh={assets.mesh}+ thumbnail={thumbnail}+ duration={video.duration}+ />+ </div>+ <div+ style={{+ display: "flex",+ position: "absolute",+ top: 0,+ left: 0,+ width: 500,height: "100%",+ padding: "58px 0 54px 64px",+ flexDirection: "column",justifyContent: "space-between",}}>- <CapWordmark height={52} color={OG_INK} />- <div- style={{- display: "flex",- flexDirection: "column",- gap: 26,- paddingBottom: 6,- }}- >- <span- style={{- display: "block",- fontSize: video.title.length <= 40 ? 52 : 42,- fontWeight: 500,- color: OG_INK,- lineHeight: 1.15,- letterSpacing: -0.5,- lineClamp: 3,- }}- >+ <CapWordmark />+ <div style={{ display: "flex", flexDirection: "column", gap: 28 }}>+ <Headline size={videoTitleSize(video.title)} lines={4}>{video.title}- </span>- {(video.ownerName || video.duration != null) && (- <div- style={{- display: "flex",- alignItems: "center",- gap: 14,- }}- >- {video.ownerName && <InitialAvatar name={video.ownerName} />}- {video.ownerName && (- <span- style={{- fontSize: 24,- fontWeight: 500,- color: OG_INK_SOFT,- }}- >- {video.ownerName}- </span>- )}- {video.duration != null && video.duration > 0 && (- <div- style={{- display: "flex",- alignItems: "center",- gap: 8,- background: "rgba(255,255,255,0.42)",- border: "1px solid rgba(255,255,255,0.7)",- borderRadius: 999,- padding: "6px 16px",- }}- >- <svg- role="img"- aria-label="Play"- width="14"- height="14"- viewBox="0 0 24 24"- fill={OG_INK}- >- <path d="M7 4.5 L19.5 12 L7 19.5 Z" />- </svg>- <span- style={{ fontSize: 20, fontWeight: 500, color: OG_INK }}- >- {formatDuration(video.duration)}- </span>- </div>- )}+ </Headline>+ {video.ownerName && (+ <div style={{ display: "flex", alignItems: "center", gap: 14 }}>+ <InitialAvatar name={video.ownerName} />+ <span+ style={{+ display: "block",+ fontSize: 22,+ fontWeight: 500,+ color: "rgba(17,17,17,0.72)",+ lineClamp: 1,+ }}+ >+ {video.ownerName}+ </span></div>)}</div>- <span- style={{- fontSize: 23,- fontWeight: 500,- color: OG_INK_SOFT,- }}- >- Watch on Cap.so- </span>- </div>- <div style={{ display: "flex", flexShrink: 0 }}>- <VideoCard screenshotUrl={video.screenshotUrl} width={560} />+ <div style={{ display: "flex", height: 52 }} /></div>- </div>- </SkyBackground>-);+ </OgCanvas>+ );+};-const statusLayout = ({- heading,- subline,- fill,-}: {- heading: string;- subline: string;- fill: "lock" | "logo";-}) => (- <SkyBackground>+const statusLayout = (+ {+ heading,+ subline,+ icon,+ }: {+ heading: string;+ subline: string;+ icon: "lock" | "search";+ },+ assets: Awaited<ReturnType<typeof loadOgAssets>>,+) => (+ <OgCanvas background={assets.skyCenter}><divstyle={{display: "flex",@@ -384,93 +316,96 @@ const statusLayout = ({left: 0,width: "100%",height: "100%",- padding: "52px 60px",+ padding: "58px 120px 54px",flexDirection: "column",+ alignItems: "center",+ justifyContent: "space-between",}}>- <CapWordmark height={52} color={OG_INK} />+ <CapWordmark /><divstyle={{display: "flex",- flexGrow: 1,+ flexDirection: "column",alignItems: "center",- gap: 48,+ gap: 26,+ textAlign: "center",}}><divstyle={{display: "flex",- flexDirection: "column",- flexGrow: 1,- flexShrink: 1,- minWidth: 0,- gap: 20,+ width: 104,+ height: 104,+ borderRadius: 30,+ alignItems: "center",+ justifyContent: "center",+ background:+ "linear-gradient(180deg, rgba(255,255,255,0.86) 0%, rgba(236,243,252,0.7) 100%)",+ border: "1px solid rgba(255,255,255,0.9)",+ boxShadow:+ "0 24px 48px -16px rgba(40,72,130,0.35), inset 0 -2px 4px rgba(61,119,194,0.12)",}}>- <span- style={{- display: "block",- fontSize: 56,- fontWeight: 500,- color: OG_INK,- lineHeight: 1.12,- letterSpacing: -0.5,- lineClamp: 3,- }}- >- {heading}- </span>- <span- style={{- display: "block",- fontSize: 26,- fontWeight: 400,- color: OG_INK_SOFT,- lineHeight: 1.4,- lineClamp: 2,- }}- >- {subline}- </span>- </div>- <div style={{ display: "flex", flexShrink: 0 }}>- <VideoCard width={520} fill={fill} />+ {icon === "lock" ? <LockIcon size={48} /> : <SearchIcon size={46} />}</div>+ <Headline size={64} lines={2}>+ {heading}+ </Headline>+ <Body size={26}>{subline}</Body></div>+ <div style={{ display: "flex", height: 52 }} /></div>- </SkyBackground>+ </OgCanvas>);export async function renderVideoOg(variant: VideoOgVariant) {+ const screenshotUrl =+ variant.kind === "video" ? variant.video.screenshotUrl : undefined;+ const [fonts, assets, thumbnail] = await Promise.all([+ loadOgFonts(),+ loadOgAssets(),+ screenshotUrl ? loadOgThumbnail(screenshotUrl) : undefined,+ ]);const element = (() => {switch (variant.kind) {case "video":- return videoLayout(variant.video);+ return videoLayout(variant.video, thumbnail, assets);case "locked":- return statusLayout({- heading: "This Cap is private",- subline: "Ask the owner for access, or sign in to watch it on Cap.",- fill: "lock",- });+ return statusLayout(+ {+ heading: "This Cap is private",+ subline: "Ask the owner for access, or sign in to watch it on Cap.",+ icon: "lock",+ },+ assets,+ );case "password":- return statusLayout({- heading: "This Cap is password protected",- subline: "Enter the password on Cap to watch this recording.",- fill: "lock",- });+ return statusLayout(+ {+ heading: "This Cap is password protected",+ subline: "Enter the password on Cap to watch this recording.",+ icon: "lock",+ },+ assets,+ );case "not-found":- return statusLayout({- heading: "This Cap doesn't exist",- subline: "The recording you're looking for has moved or was deleted.",- fill: "logo",- });+ return statusLayout(+ {+ heading: "This Cap doesn't exist",+ subline:+ "The recording you're looking for has moved or was deleted.",+ icon: "search",+ },+ assets,+ );}})();return new ImageResponse(element, {width: OG_WIDTH,height: OG_HEIGHT,- fonts: await loadOgFonts(),+ fonts,headers: {"Cache-Control": VIDEO_OG_CACHE_CONTROL,"X-Robots-Tag": "noindex",diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjsindex ddd1f378b..657f6a3bb 100644--- a/apps/web/next.config.mjs+++ b/apps/web/next.config.mjs@@ -31,8 +31,12 @@ const nextConfig = {outputFileTracingIncludes: {"/.well-known/workflow/v1/step": ffmpegTracingIncludes,"/api/tools/loom-download": ffmpegTracingIncludes,- "/api/og": ["./lib/og/fonts/*.ttf"],- "/api/video/og": ["./lib/og/fonts/*.ttf", ...ffmpegTracingIncludes],+ "/api/og": ["./lib/og/fonts/*.ttf", "./lib/og/assets/*.jpg"],+ "/api/video/og": [+ "./lib/og/fonts/*.ttf",+ "./lib/og/assets/*.jpg",+ ...ffmpegTracingIncludes,+ ],"/dashboard/settings/organization/billing": ["./lib/baa/*.pdf"],"/api/settings/billing/baa/download": ["./lib/baa/*.pdf"],},diff --git a/scripts/og-sky/render.py b/scripts/og-sky/render.pynew file mode 100644index 000000000..9fd78a2c6--- /dev/null+++ b/scripts/og-sky/render.py@@ -0,0 +1,153 @@+"""Bakes the painted-sky OG image backgrounds.++ python3 scripts/og-sky/render.py++Satori (next/og) can't run SVG filters, blend WebP clouds or draw film grain,+so the atmosphere is baked here once: the homepage hero sky (HeroSky.tsx+gradients + the real cloud art from public/backgrounds/clouds) and the+Instant-mode mesh used for product frames. The route composites text and UI+on top at request time. Outputs land in apps/web/lib/og/assets.+"""++from __future__ import annotations++from pathlib import Path++import numpy as np+from PIL import Image++ROOT = Path(__file__).resolve().parents[2]+WEB = ROOT / "apps" / "web"+CLOUDS = WEB / "public" / "backgrounds" / "clouds"+OUT = WEB / "lib" / "og" / "assets"++W, H = 1200, 630+++def hex_rgb(value: str) -> np.ndarray:+ value = value.lstrip("#")+ return np.array([int(value[i : i + 2], 16) for i in (0, 2, 4)], dtype=np.float32) / 255.0+++def grid(w: int, h: int) -> tuple[np.ndarray, np.ndarray]:+ ys, xs = np.mgrid[0:h, 0:w].astype(np.float32)+ return xs + 0.5, ys + 0.5+++def over(base: np.ndarray, color: np.ndarray, alpha: np.ndarray) -> np.ndarray:+ a = alpha[..., None]+ return base * (1 - a) + color * a+++def radial(w: int, h: int, rx: float, ry: float, cx: float, cy: float, stop: float) -> np.ndarray:+ xs, ys = grid(w, h)+ d = np.sqrt(((xs - cx * w) / (rx * w)) ** 2 + ((ys - cy * h) / (ry * h)) ** 2)+ t = np.clip(d / stop, 0, 1)+ return 1 - t+++def vertical(w: int, h: int, stops: list[tuple[float, str]]) -> np.ndarray:+ _, ys = grid(w, h)+ t = ys / h+ pos = np.array([p for p, _ in stops], dtype=np.float32)+ cols = np.stack([hex_rgb(c) for _, c in stops])+ out = np.zeros((h, w, 3), dtype=np.float32)+ for ch in range(3):+ out[..., ch] = np.interp(t, pos, cols[:, ch])+ return out+++def grain(img: np.ndarray, strength: float, seed: int) -> np.ndarray:+ rng = np.random.default_rng(seed)+ noise = rng.normal(0, 1, img.shape[:2]).astype(np.float32)+ noise = (np.floor(np.clip(noise * 40 + 128, 0, 255)) - 128) / 40+ return img + noise[..., None] * strength+++def paste_cloud(img: np.ndarray, name: str, left: int, top: int, width: int, opacity: float, flip: bool = False) -> np.ndarray:+ art = Image.open(CLOUDS / f"{name}.webp").convert("RGBA")+ if flip:+ art = art.transpose(Image.FLIP_LEFT_RIGHT)+ height = round(art.height * width / art.width)+ art = art.resize((width, height), Image.LANCZOS)+ rgba = np.asarray(art, dtype=np.float32) / 255.0+ h, w = img.shape[:2]+ x0, y0 = max(left, 0), max(top, 0)+ x1, y1 = min(left + width, w), min(top + height, h)+ if x0 >= x1 or y0 >= y1:+ return img+ crop = rgba[y0 - top : y1 - top, x0 - left : x1 - left]+ region = img[y0:y1, x0:x1]+ img[y0:y1, x0:x1] = over(region, crop[..., :3], crop[..., 3] * opacity)+ return img+++def sky() -> np.ndarray:+ img = vertical(W, H, [(0, "#C4DAF5"), (0.36, "#D6E5F7"), (0.7, "#E4ECF6"), (1, "#EDF1F6")])+ img = over(img, hex_rgb("#FFF0E0"), radial(W, H, 0.8, 0.46, 0.5, 0.82, 0.72) * 0.45)+ img = over(img, hex_rgb("#FFE0C0"), radial(W, H, 0.34, 0.5, 0.8, 0.0, 0.7) * 0.75)+ return img+++def save(img: np.ndarray, name: str, quality: int = 90) -> None:+ out = Image.fromarray((img.clip(0, 1) * 255).round().astype(np.uint8), mode="RGB")+ out.save(OUT / name, quality=quality, optimize=True, progressive=True)+ print(f"{name}: {(OUT / name).stat().st_size // 1024}KB")+++def marketing_sky() -> None:+ img = sky()+ img = paste_cloud(img, "wisp-a", 250, -30, 420, 0.55)+ img = paste_cloud(img, "tuft-a", -70, 60, 250, 0.5, flip=True)+ img = paste_cloud(img, "cumulus-b", 800, -40, 420, 0.8)+ img = paste_cloud(img, "bank-a", 470, 150, 380, 0.45)+ img = paste_cloud(img, "cumulus-a", -170, 420, 620, 0.9)+ img = paste_cloud(img, "bank-a", 360, 520, 520, 0.8, flip=True)+ img = grain(img, 0.006, 7)+ save(img, "sky-split.jpg")+++def centered_sky() -> None:+ img = sky()+ img = paste_cloud(img, "wisp-a", 60, 20, 380, 0.6)+ img = paste_cloud(img, "cumulus-b", 860, 40, 400, 0.85)+ img = paste_cloud(img, "tuft-a", 420, -40, 260, 0.45)+ img = paste_cloud(img, "cumulus-a", -200, 380, 640, 0.95)+ img = paste_cloud(img, "bank-a", 760, 430, 560, 0.9, flip=True)+ img = grain(img, 0.006, 11)+ save(img, "sky-center.jpg")+++def mesh(name: str, w: int, h: int, layers: list[tuple[float, float, float, float, str, float]], base: str) -> None:+ img = np.ones((h, w, 3), dtype=np.float32) * hex_rgb(base)+ # CSS paints the first layer on top, so composite in reverse.+ for rx, ry, cx, cy, color, stop in reversed(layers):+ img = over(img, hex_rgb(color), radial(w, h, rx, ry, cx, cy, stop))+ img = grain(img, 0.01, 3)+ save(img, name, 88)+++def main() -> None:+ OUT.mkdir(parents=True, exist_ok=True)+ marketing_sky()+ centered_sky()+ mesh(+ "mesh-instant.jpg",+ 720,+ 640,+ [+ (0.92, 0.95, 0.06, 0.06, "#8FC1F7", 0.66),+ (0.70, 0.78, 0.96, 0.02, "#CDEBF4", 0.60),+ (0.82, 0.76, 0.92, 0.96, "#DDD7F8", 0.62),+ (0.92, 0.88, 0.24, 1.00, "#AFD6F8", 0.70),+ ],+ "#E4F0FB",+ )+ wall = Image.open(WEB / "public" / "backgrounds" / "sf.webp").convert("RGB")+ wall = wall.resize((1024, round(wall.height * 1024 / wall.width)), Image.LANCZOS)+ wall.save(OUT / "wallpaper.jpg", quality=86, optimize=True, progressive=True)+ print(f"wallpaper.jpg: {(OUT / 'wallpaper.jpg').stat().st_size // 1024}KB")+++if __name__ == "__main__":+ main()