From 88d9343ab53ce4f4241e2a73139e00f0263cabb1 Mon Sep 17 00:00:00 2001 From: tanishqmanuja Date: Wed, 20 Sep 2023 15:55:32 +0530 Subject: [PATCH] feat: use new og images in layout --- src/layouts/Layout.astro | 2 +- src/layouts/PostDetails.astro | 5 ++++- src/types.ts | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 83239c1..5fa9c27 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -22,7 +22,7 @@ const { } = Astro.props; const socialImageURL = new URL( - ogImage ? ogImage : SITE.ogImage, + ogImage ?? SITE.ogImage ?? "og.png", Astro.url.origin ).href; --- diff --git a/src/layouts/PostDetails.astro b/src/layouts/PostDetails.astro index 6862b16..3140468 100644 --- a/src/layouts/PostDetails.astro +++ b/src/layouts/PostDetails.astro @@ -19,7 +19,10 @@ const { title, author, description, ogImage, canonicalURL, pubDatetime, tags } = const { Content } = await post.render(); const ogImageUrl = typeof ogImage === "string" ? ogImage : ogImage?.src; -const ogUrl = new URL(ogImageUrl ?? `${post.slug}.png`, Astro.url.origin).href; +const ogUrl = new URL( + ogImageUrl ?? `/posts/${slugifyStr(title)}.png`, + Astro.url.origin +).href; ---