Skip to content

Commit

Permalink
fix: use default-og for twitter card
Browse files Browse the repository at this point in the history
  • Loading branch information
satnaing committed Dec 30, 2022
1 parent af517cd commit 9434d85
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ const {
} = Astro.props;
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
const socialImageURL = new URL(
ogImage ? ogImage : SITE.ogImage,
Astro.url.origin
);
).href;
const fallbackImageURL = new URL(SITE.ogImage, Astro.url.origin).href;
---

<!DOCTYPE html>
Expand Down Expand Up @@ -51,7 +54,12 @@ const socialImageURL = new URL(
<meta property="twitter:url" content={canonicalURL} />
<meta property="twitter:title" content={title} />
<meta property="twitter:description" content={description} />
<meta property="twitter:image" content={socialImageURL} />
<meta
property="twitter:image"
content={socialImageURL.endsWith(".svg")
? fallbackImageURL
: socialImageURL}
/>

<!-- Google Font -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
Expand Down

0 comments on commit 9434d85

Please sign in to comment.