Skip to content

Commit 5ba155a

Browse files
authored
Attempt fixing social previews on WhatsApp (#334)
1 parent 0721e1b commit 5ba155a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/astro-theme/layouts/BlogPost.astro

Lines changed: 13 additions & 2 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,9 +33,20 @@ 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

38-
<Shell title={titleAndSubtitle} {description} image={heroImage?.src}>
49+
<Shell title={titleAndSubtitle} {description} image={socialImage?.src}>
3950
{product && <ProductNav {product} />}
4051
<main class="px-6 py-10 w-full max-w-screen-xl mx-auto">
4152
<a

0 commit comments

Comments
 (0)