fix: use default-og for twitter card

This commit is contained in:
satnaing
2022-12-30 16:14:12 +06:30
parent af517cd486
commit 9434d850e1
+10 -2
View File
@@ -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>
@@ -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" />