Skip to content

Commit 1eb59fa

Browse files
feat(og-image): composite logo and match site branding
Composite logo.png when generating og-image.png, restyle the template to match site colors, and remove unused server-logo.svg. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1775c6a commit 1eb59fa

5 files changed

Lines changed: 27 additions & 31 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pnpm dev
3131
| `pnpm test` | Run tests in watch mode |
3232
| `pnpm test:run` | Run tests once (CI) |
3333
| `pnpm lint` | Lint with ESLint |
34-
| `pnpm generate:og-image` | Regenerate `public/og-image.png` from SVG |
34+
| `pnpm generate:og-image` | Regenerate `public/og-image.png` using `public/logo.png` |
3535

3636
## Environment variables
3737

public/og-image.png

-24.4 KB
Loading

public/og-image.svg

Lines changed: 10 additions & 17 deletions
Loading

public/server-logo.svg

Lines changed: 0 additions & 11 deletions
This file was deleted.

scripts/generate-og-image.mjs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,19 @@ import { fileURLToPath } from 'node:url';
44
import sharp from 'sharp';
55

66
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
7-
const svg = readFileSync(join(root, 'public/og-image.svg'));
8-
await sharp(svg).png().toFile(join(root, 'public/og-image.png'));
7+
const logoPath = join(root, 'public/logo.png');
8+
const svgPath = join(root, 'public/og-image.svg');
9+
const outPath = join(root, 'public/og-image.png');
10+
11+
const CANVAS_WIDTH = 1200;
12+
const LOGO_SIZE = 160;
13+
const LOGO_TOP = 120;
14+
const LOGO_LEFT = Math.floor((CANVAS_WIDTH - LOGO_SIZE) / 2);
15+
16+
const svg = readFileSync(svgPath);
17+
const logo = await sharp(logoPath).resize(LOGO_SIZE, LOGO_SIZE).png().toBuffer();
18+
19+
await sharp(svg)
20+
.composite([{ input: logo, top: LOGO_TOP, left: LOGO_LEFT }])
21+
.png()
22+
.toFile(outPath);

0 commit comments

Comments
 (0)