bugfix/#741 - fix type of socialImage, fix condition

This commit is contained in:
alxshelepenok 2020-09-10 01:09:00 +03:00
parent 4a9648b189
commit 5c7fa10460
3 changed files with 4 additions and 4 deletions

View File

@ -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 (

View File

@ -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 (
<Layout title={`${pageTitle} - ${siteTitle}`} description={metaDescription} socialImage={socialImageUrl} >

View File

@ -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 (
<Layout title={`${postTitle} - ${siteTitle}`} description={metaDescription} socialImage={socialImageUrl} >