Skip to content

Commit bec63f4

Browse files
authored
Fix icon rendering in OpenGraph images by using hex colors for server-side rendering. (#61)
CSS variables don't resolve in Satori (server-side image renderer), breaking OG image generation. Added catppuccinColorsMocha export with Mocha hex values for server-side use while keeping CSS variables for client components to maintain automatic light/dark switching.
1 parent 1641dd5 commit bec63f4

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

site/app/kernel/[name]/opengraph-image.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ImageResponse } from 'next/og';
22
import { getAllKernelNames, getKernelReport } from '@/lib/data';
33
import { getPassedCount, getTotalCount, hasStartupError } from '@/types/report';
4-
import { iconPaths, catppuccinColors, getIconKey, type ColorKey } from '@/lib/icon-paths';
4+
import { iconPaths, catppuccinColorsMocha, getIconKey, type ColorKey } from '@/lib/icon-paths';
55

66
export const runtime = 'nodejs';
77
export const dynamic = 'force-static';
@@ -21,7 +21,7 @@ function getLanguageIconSvg(language: string, kernelName: string) {
2121
<path
2222
key={i}
2323
d={path.d}
24-
stroke={catppuccinColors[path.color as ColorKey]}
24+
stroke={catppuccinColorsMocha[path.color as ColorKey]}
2525
/>
2626
))}
2727
</g>

site/src/lib/icon-paths.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ export const catppuccinColors = {
1919
overlay: 'var(--catppuccin-color-overlay1)',
2020
} as const;
2121

22+
// Mocha hex values for server-side rendering (OG images)
23+
// CSS variables don't work in Satori, so we need hardcoded values
24+
export const catppuccinColorsMocha = {
25+
blue: '#89b4fa',
26+
yellow: '#f9e2af',
27+
peach: '#fab387',
28+
red: '#f38ba8',
29+
mauve: '#cba6f7',
30+
green: '#a6e3a1',
31+
teal: '#94e2d5',
32+
text: '#cdd6f4',
33+
overlay: '#7f849c',
34+
} as const;
35+
2236
export type ColorKey = keyof typeof catppuccinColors;
2337

2438
interface PathData {

0 commit comments

Comments
 (0)