Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 1084af7

Browse files
committed
Fix meta image handling
1 parent 56f41eb commit 1084af7

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

components/common/Layout.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ import {seoPropTypes} from '@/functions/getPagePropTypes'
1717
*/
1818
export default function Layout({children, seo, hasJsonLd}) {
1919
// Define SEO image prop.
20-
const seoImages = [
21-
{
22-
url: seo?.opengraphImage?.sourceUrl,
23-
alt: seo?.opengraphImage?.altText,
24-
height: 150,
25-
width: 150
26-
}
27-
]
20+
const seoImages = !seo?.opengraphImage?.sourceUrl
21+
? null
22+
: [
23+
{
24+
url: seo.opengraphImage.sourceUrl,
25+
alt: seo?.opengraphImage?.altText,
26+
height: 150,
27+
width: 150
28+
}
29+
]
2830

2931
return (
3032
<>
@@ -34,7 +36,7 @@ export default function Layout({children, seo, hasJsonLd}) {
3436
openGraph={{
3537
title: seo?.title,
3638
description: seo?.metaDesc,
37-
images: [...seoImages],
39+
images: seoImages ? [...seoImages] : null,
3840
url: seo?.canonical
3941
}}
4042
nofollow={'follow' !== seo?.metaRobotsNofollow}
@@ -44,7 +46,7 @@ export default function Layout({children, seo, hasJsonLd}) {
4446
<BlogJsonLd
4547
url={seo?.canonical}
4648
title={seo?.title}
47-
images={[...seoImages]}
49+
images={seoImages ? [...seoImages] : null}
4850
datePublished={seo?.opengraphPublishedTime}
4951
dateModified={seo?.opengraphModifiedTime}
5052
authorName={seo?.opengraphAuthor}

0 commit comments

Comments
 (0)