From d34f97061f03367aa24d98f10e309384a970347b Mon Sep 17 00:00:00 2001 From: Ewan Croft Date: Sun, 21 Sep 2025 15:57:19 +0100 Subject: [PATCH] fix(og-image): default SSR dates to UK locale (Europe/London) --- src/lib/server/ogImage.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/lib/server/ogImage.ts b/src/lib/server/ogImage.ts index 58c8a64..a4d7679 100644 --- a/src/lib/server/ogImage.ts +++ b/src/lib/server/ogImage.ts @@ -180,8 +180,26 @@ export async function generateOgImage(options: OgImageOptions, baseUrl?: string) metaMarginBottom = Math.max(8, Math.floor(metaMarginBottom * compressionRatio)); } - // Extract date from extraMeta if available - const dateString = options.extraMeta && options.extraMeta.length > 0 ? options.extraMeta[0] : null; + // Extract and format date for UK timezone + let dateString: string | null = null; + if (options.extraMeta && options.extraMeta.length > 0) { + try { + const utcDate = new Date(options.extraMeta[0]); // parse UTC string + // Format in UK timezone + dateString = new Intl.DateTimeFormat('en-GB', { + day: '2-digit', + month: 'short', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + timeZone: 'Europe/London', + hour12: false + }).format(utcDate); + } catch (err) { + console.warn('Failed to parse date for OG image:', err); + dateString = options.extraMeta[0]; // fallback + } + } // Layout children let children: any[] = []; -- 2.51.2