Skip to content

Commit cea28d9

Browse files
KyleAMathewsclaude
andcommitted
Add Netlify Image CDN processing for blog social media images
Process blog header images through Netlify Image CDN to optimize them for social media sharing. Images are automatically resized to 1200x630px (the standard og:image dimensions), converted to JPG format, and quality-optimized to ensure fast loading and proper display across all social platforms. Benefits: - Consistent 1200x630 dimensions for all platforms (Facebook, Twitter, LinkedIn) - Optimized file size with 80% quality JPG output - Proper aspect ratio with cover fit mode - Faster page preview generation on social media 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1f0cf08 commit cea28d9

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/routes/_libraries/blog.$.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,22 @@ export const Route = createFileRoute('/_libraries/blog/$')({
6969
staleTime: Infinity,
7070
loader: ({ params }) => fetchBlogPost({ data: params._splat }),
7171
head: ({ loaderData }) => {
72+
// Generate optimized social media image URL using Netlify Image CDN
73+
const getSocialImageUrl = (headerImage?: string) => {
74+
if (!headerImage) return undefined
75+
76+
// Use Netlify Image CDN to optimize for social media (1200x630 is the standard for og:image)
77+
const netlifyImageUrl = `https://tanstack.com/.netlify/images?url=${encodeURIComponent(headerImage)}&w=1200&h=630&fit=cover&fm=jpg&q=80`
78+
return netlifyImageUrl
79+
}
80+
7281
return {
7382
meta: loaderData
7483
? [
7584
...seo({
7685
title: `${loaderData?.title ?? 'Docs'} | TanStack Blog`,
7786
description: loaderData?.description,
78-
image: loaderData?.headerImage
79-
? `https://tanstack.com${loaderData.headerImage}`
80-
: undefined,
87+
image: getSocialImageUrl(loaderData?.headerImage),
8188
}),
8289
{
8390
name: 'author',

0 commit comments

Comments
 (0)