Skip to content

Commit ff4fa13

Browse files
MaxDatenclaude
andcommitted
fix(og): use generated OG card instead of raw Sanity CDN image for social sharing
The og:image and twitter:image meta tags were pointing to the raw Sanity cover photo URL, bypassing the branded OG card endpoint. Now always uses the generated /{slug}/og.jpg card with title, excerpt, tags, and branding. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent cd0f0b8 commit ff4fa13

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

src/routes/[slug]/+page.ts

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,23 @@ export const load: PageLoad = async ({ data, url }): Promise<PageData> => {
5050
description: post.excerpt ?? '',
5151
url: new URL(url.pathname, url.origin).href,
5252
type: 'article',
53-
images: post.coverImage?.url
54-
? [
55-
{
56-
url: post.coverImage.url,
57-
width: post.coverImage.dimensions?.width ?? 1200,
58-
height: post.coverImage.dimensions?.height ?? 630,
59-
secureUrl: post.coverImage.url,
60-
alt: post.coverImage.alt ?? post.title,
61-
type: 'image/jpeg',
62-
},
63-
]
64-
: [
65-
{
66-
url: ogImageUrl,
67-
width: 1200,
68-
height: 630,
69-
secureUrl: ogImageUrl,
70-
alt: post.title,
71-
type: 'image/jpeg',
72-
},
73-
],
53+
images: [
54+
{
55+
url: ogImageUrl,
56+
width: 1200,
57+
height: 630,
58+
secureUrl: ogImageUrl,
59+
alt: post.title,
60+
type: 'image/jpeg',
61+
},
62+
],
7463
},
7564
twitter: {
7665
title: post.title,
7766
description: post.excerpt ?? '',
7867
cardType: 'summary_large_image',
79-
image: post.coverImage?.url ?? ogImageUrl,
80-
imageAlt: post.coverImage?.alt ?? post.title,
68+
image: ogImageUrl,
69+
imageAlt: post.title,
8170
} as Twitter,
8271
}) satisfies MetaTagsProps;
8372

0 commit comments

Comments
 (0)