Files
klz-cables.com/lib/og-helper.tsx
Marc Mintel 877108020b
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Successful in 1m18s
Build & Deploy / 🏗️ Build (push) Successful in 3m55s
Build & Deploy / 🚀 Deploy (push) Successful in 46s
Build & Deploy / 🧪 Smoke Test (push) Failing after 40s
Build & Deploy / 🔔 Notify (push) Successful in 2s
fix(og): verified font and infrastructure fix
- Fixed font corruption: Replaced WOFF2/HTML stubs with valid binary WOFF fonts.
- Verified local rendering: check:og script now passes on local production build.
- Robust infrastructure: Guaranteed Traefik bypass with Host match and priority 2000.
- Middleware bypass: Ensured OG routes are never intercepted by next-intl.
2026-02-12 22:23:21 +01:00

47 lines
1.2 KiB
TypeScript

import { readFileSync } from 'fs';
import { join } from 'path';
/**
* Loads the Inter fonts for use in Satori (Next.js OG Image generation).
* Since we are using runtime = 'nodejs', we can read them from the filesystem.
*/
export async function getOgFonts() {
const boldFontPath = join(process.cwd(), 'public/fonts/Inter-Bold.woff');
const regularFontPath = join(process.cwd(), 'public/fonts/Inter-Regular.woff');
try {
console.log(`[OG] Loading fonts: bold=${boldFontPath}, regular=${regularFontPath}`);
const boldFont = readFileSync(boldFontPath);
const regularFont = readFileSync(regularFontPath);
console.log(
`[OG] Fonts loaded successfully (${boldFont.length} and ${regularFont.length} bytes)`,
);
return [
{
name: 'Inter',
data: boldFont,
weight: 700 as const,
style: 'normal' as const,
},
{
name: 'Inter',
data: regularFont,
weight: 400 as const,
style: 'normal' as const,
},
];
} catch (error) {
console.error(`[OG] Failed to load fonts from ${process.cwd()}:`, error);
return [];
}
}
/**
* Common configuration for OG images
*/
export const OG_IMAGE_SIZE = {
width: 1200,
height: 630,
};