Fix generating meta image URLs

This commit is contained in:
Maciej Pędzich 2023-09-07 12:51:53 +02:00
parent efeabfa168
commit 809a0497a9

View File

@ -18,7 +18,6 @@ const {
} = Astro.props; } = Astro.props;
const title = `${titleProp ? `${titleProp} - ` : ''}Cats Of Tech`; const title = `${titleProp ? `${titleProp} - ` : ''}Cats Of Tech`;
const imageUrl = image ? new URL(image, Astro.url) : null;
--- ---
<html lang="en"> <html lang="en">
@ -35,10 +34,13 @@ const imageUrl = image ? new URL(image, Astro.url) : null;
<meta property="og:description" content={description} /> <meta property="og:description" content={description} />
<meta property="twitter:description" content={description} /> <meta property="twitter:description" content={description} />
{ {
imageUrl && ( image && (
<> <>
<meta property="og:image" content={imageUrl} /> <meta property="og:image" content={new URL(image, Astro.url)} />
<meta property="twitter:description" content={imageUrl} /> <meta
property="twitter:description"
content={new URL(image, Astro.url)}
/>
</> </>
) )
} }