feat(og): adapt premium industrial style for OG images
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🏗️ Build (push) Successful in 5m20s
Build & Deploy / 🧪 QA (push) Successful in 5m38s
Build & Deploy / 🚀 Deploy (push) Successful in 19s
Build & Deploy / 🩺 Health Check (push) Failing after 11s
Build & Deploy / 🔔 Notify (push) Successful in 2s
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🏗️ Build (push) Successful in 5m20s
Build & Deploy / 🧪 QA (push) Successful in 5m38s
Build & Deploy / 🚀 Deploy (push) Successful in 19s
Build & Deploy / 🩺 Health Check (push) Failing after 11s
Build & Deploy / 🔔 Notify (push) Successful in 2s
This commit is contained in:
54
apps/web/src/lib/og-helper.tsx
Normal file
54
apps/web/src/lib/og-helper.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
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(),
|
||||
"apps/web/public/fonts/Inter-Bold.woff",
|
||||
);
|
||||
const regularFontPath = join(
|
||||
process.cwd(),
|
||||
"apps/web/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,
|
||||
};
|
||||
Reference in New Issue
Block a user