diff --git a/app/[locale]/opengraph-image.tsx b/app/[locale]/opengraph-image.tsx index a2f5a0df3..68183bea6 100644 --- a/app/[locale]/opengraph-image.tsx +++ b/app/[locale]/opengraph-image.tsx @@ -1,7 +1,7 @@ import { ImageResponse } from 'next/og'; import { getTranslations } from 'next-intl/server'; import { OGImageTemplate } from '@/components/OGImageTemplate'; -import { getOgFonts, OG_IMAGE_SIZE } from '@/lib/og-helper'; +import { getOgFonts, getOgBackground, getOgLogo, OG_IMAGE_SIZE } from '@/lib/og-helper'; export const size = OG_IMAGE_SIZE; export const contentType = 'image/png'; @@ -11,12 +11,16 @@ export default async function Image({ params }: { params: Promise<{ locale: stri const { locale } = await params; const t = await getTranslations({ locale, namespace: 'Index.meta' }); const fonts = await getOgFonts(); + const bg = getOgBackground(); + const logo = getOgLogo(); return new ImageResponse( , { ...OG_IMAGE_SIZE, diff --git a/components/OGImageTemplate.tsx b/components/OGImageTemplate.tsx index 1c112f4ac..31037ffa6 100644 --- a/components/OGImageTemplate.tsx +++ b/components/OGImageTemplate.tsx @@ -13,6 +13,7 @@ export function OGImageTemplate({ description, label, image, + logo, mode = 'dark', }: OGImageTemplateProps) { const backgroundDark = '#1a1a1a'; @@ -64,7 +65,7 @@ export function OGImageTemplate({ left: 0, right: 0, bottom: 0, - background: 'linear-gradient(to right, rgba(26,26,26,0.95), rgba(26,26,26,0.6))', + background: 'linear-gradient(135deg, rgba(26,26,26,0.98) 0%, rgba(26,26,26,0.85) 40%, rgba(14,122,92,0.4) 100%)', }} /> @@ -74,12 +75,12 @@ export function OGImageTemplate({
@@ -145,27 +146,39 @@ export function OGImageTemplate({ alignItems: 'center', }} > -
-
- E-TIB GmbH -
+ {logo ? ( + // eslint-disable-next-line @next/next/no-img-element + E-TIB GmbH + ) : ( +
+ )} + {!logo && ( +
+ E-TIB GmbH +
+ )}
{/* Primary Green Brand Strip */} diff --git a/lib/og-helper.tsx b/lib/og-helper.tsx index 678d3e20a..09c2103e1 100644 --- a/lib/og-helper.tsx +++ b/lib/og-helper.tsx @@ -48,6 +48,28 @@ export async function getOgFonts() { } } +export function getOgBackground() { + try { + const bgPath = join(process.cwd(), 'public/assets/photos/Etib_E-tib_Tiefbau_Guben_Netzanbindung_Energie-100.jpg'); + const bgBase64 = readFileSync(bgPath, 'base64'); + return `data:image/jpeg;base64,${bgBase64}`; + } catch (err) { + console.error('[OG] Failed to load background', err); + return undefined; + } +} + +export function getOgLogo() { + try { + const logoPath = join(process.cwd(), 'public/assets/logo-white.png'); + const logoBase64 = readFileSync(logoPath, 'base64'); + return `data:image/png;base64,${logoBase64}`; + } catch (err) { + console.error('[OG] Failed to load logo', err); + return undefined; + } +} + /** * Common configuration for OG images */