From 5c7fa1046018c6ceb1ce11fa70c67486874b9d6a Mon Sep 17 00:00:00 2001 From: alxshelepenok Date: Thu, 10 Sep 2020 01:09:00 +0300 Subject: [PATCH] bugfix/#741 - fix type of socialImage, fix condition --- src/components/Layout/Layout.js | 4 ++-- src/templates/page-template.js | 2 +- src/templates/post-template.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 (