diff --git a/src/components/Layout/Layout.js b/src/components/Layout/Layout.js index eef7295..94ebb88 100644 --- a/src/components/Layout/Layout.js +++ b/src/components/Layout/Layout.js @@ -9,7 +9,7 @@ type Props = { children: ReactNode, title: string, description?: string, - socialImage? :string + socialImage?: string }; const Layout = ({ @@ -19,7 +19,7 @@ const Layout = ({ socialImage }: Props) => { const { author, url } = useSiteMetadata(); - const metaImage = socialImage.length > 0 ? socialImage : author.photo; + const metaImage = typeof socialImage !== 'undefined' ? socialImage : author.photo; const metaImageUrl = url + metaImage; return ( diff --git a/src/templates/page-template.js b/src/templates/page-template.js index 1511d97..f26076f 100644 --- a/src/templates/page-template.js +++ b/src/templates/page-template.js @@ -19,7 +19,7 @@ const PageTemplate = ({ data }: Props) => { const { frontmatter } = data.markdownRemark; const { title: pageTitle, description: pageDescription, socialImage } = frontmatter; const metaDescription = pageDescription !== null ? pageDescription : siteSubtitle; - const socialImageUrl = socialImage ? socialImage['publicURL'] : ''; + const socialImageUrl = typeof socialImage !== 'undefined' ? socialImage['publicURL'] : undefined; return ( diff --git a/src/templates/post-template.js b/src/templates/post-template.js index d7c4b63..c6c5b01 100644 --- a/src/templates/post-template.js +++ b/src/templates/post-template.js @@ -17,7 +17,7 @@ const PostTemplate = ({ data }: Props) => { const { frontmatter } = data.markdownRemark; const { title: postTitle, description: postDescription, socialImage } = frontmatter; const metaDescription = postDescription !== null ? postDescription : siteSubtitle; - const socialImageUrl = socialImage ? socialImage['publicURL'] : ''; + const socialImageUrl = typeof socialImage !== 'undefined' ? socialImage['publicURL'] : undefined; return (