Skip to content

Commit 6ac02a6

Browse files
committed
Make social preview use the same pipeline as hero images
1 parent 770d8c9 commit 6ac02a6

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/astro-theme/layouts/BlogPost.astro

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import BlogPostCardSet from "../components/BlogPostCardSet.astro";
1212
import { resolveAuthors } from "../lib/blog";
1313
import LinkButton from "../components/LinkButton.astro";
1414
import { DISCORD_URL } from "../consts";
15-
import { Image } from "astro:assets";
15+
import { Image, getImage } from "astro:assets";
1616
import { productFromUrl } from "../lib/products";
1717
import ProductNav from "../components/nav/product/Nav.astro";
1818
@@ -33,14 +33,25 @@ let titleAndSubtitle = title;
3333
if (subtitle) {
3434
titleAndSubtitle += `: ${subtitle}`;
3535
}
36+
37+
// Generate optimized social preview image using the same optimization as the hero image
38+
const socialImage = heroImage
39+
? await getImage({
40+
src: heroImage,
41+
width: 1232,
42+
height: 480,
43+
quality: "max",
44+
format: "jpg",
45+
})
46+
: undefined;
3647
---
3748

3849
<Shell
3950
title={titleAndSubtitle}
4051
{description}
41-
image={heroImage?.src}
42-
imageWidth={heroImage?.width}
43-
imageHeight={heroImage?.height}
52+
image={socialImage?.src}
53+
imageWidth={socialImage?.attributes.width}
54+
imageHeight={socialImage?.attributes.height}
4455
>
4556
{product && <ProductNav {product} />}
4657
<main class="px-6 py-10 w-full max-w-screen-xl mx-auto">

0 commit comments

Comments
 (0)