From fe4249743126e07fa83cd0738dba55da6c367cf0 Mon Sep 17 00:00:00 2001 From: alxshelepenok Date: Thu, 10 Sep 2020 00:42:30 +0300 Subject: [PATCH 1/6] bugfix/#741 - upgrade gatsby-remark-relative-images --- gatsby-config.js | 12 ++++++------ src/components/Layout/Layout.js | 3 +-- src/templates/page-template.js | 7 +++++-- src/templates/post-template.js | 7 +++++-- src/types/index.js | 3 ++- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index e872449..dc5abfb 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -18,8 +18,8 @@ module.exports = { { resolve: 'gatsby-source-filesystem', options: { - path: `${__dirname}/content`, - name: 'pages' + path: `${__dirname}/static`, + name: 'assets' } }, { @@ -32,15 +32,15 @@ module.exports = { { resolve: 'gatsby-source-filesystem', options: { - name: 'css', - path: `${__dirname}/static/css` + path: `${__dirname}/content`, + name: 'pages' } }, { resolve: 'gatsby-source-filesystem', options: { - name: 'assets', - path: `${__dirname}/static` + name: 'css', + path: `${__dirname}/static/css` } }, { diff --git a/src/components/Layout/Layout.js b/src/components/Layout/Layout.js index eab3d9d..e1cf2a8 100644 --- a/src/components/Layout/Layout.js +++ b/src/components/Layout/Layout.js @@ -1,7 +1,6 @@ // @flow strict import React from 'react'; import Helmet from 'react-helmet'; -import { withPrefix } from 'gatsby'; import type { Node as ReactNode } from 'react'; import { useSiteMetadata } from '../../hooks'; import styles from './Layout.module.scss'; @@ -21,7 +20,7 @@ const Layout = ({ }: Props) => { const { author, url } = useSiteMetadata(); const metaImage = socialImage != null ? socialImage : author.photo; - const metaImageUrl = url + withPrefix(metaImage); + const metaImageUrl = url + metaImage; return (
diff --git a/src/templates/page-template.js b/src/templates/page-template.js index ce6f2ce..1511d97 100644 --- a/src/templates/page-template.js +++ b/src/templates/page-template.js @@ -19,9 +19,10 @@ 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'] : ''; return ( - +
@@ -39,7 +40,9 @@ export const query = graphql` title date description - socialImage + socialImage { + publicURL + } } } } diff --git a/src/templates/post-template.js b/src/templates/post-template.js index 801bc1f..d7c4b63 100644 --- a/src/templates/post-template.js +++ b/src/templates/post-template.js @@ -17,9 +17,10 @@ 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'] : ''; return ( - + ); @@ -39,7 +40,9 @@ export const query = graphql` description tags title - socialImage + socialImage { + publicURL + } } } } diff --git a/src/types/index.js b/src/types/index.js index d5a2836..ce07c24 100644 --- a/src/types/index.js +++ b/src/types/index.js @@ -26,7 +26,8 @@ export type Node = { fields: { slug: string, categorySlug?: string, - tagSlugs?: string[] + tagSlugs?: string[], + socialImageUrl?: string, }, frontmatter: { date: string, From 9dbf9fb059669c4fb95283c783b8cb32d5a1c1c9 Mon Sep 17 00:00:00 2001 From: alxshelepenok Date: Thu, 10 Sep 2020 00:44:05 +0300 Subject: [PATCH 2/6] bugfix/#741 - remove socialImageUrl from Node type --- src/types/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/types/index.js b/src/types/index.js index ce07c24..d5a2836 100644 --- a/src/types/index.js +++ b/src/types/index.js @@ -26,8 +26,7 @@ export type Node = { fields: { slug: string, categorySlug?: string, - tagSlugs?: string[], - socialImageUrl?: string, + tagSlugs?: string[] }, frontmatter: { date: string, From c785820b0d4451ca8a6bd6c93905bef6c21106ac Mon Sep 17 00:00:00 2001 From: alxshelepenok Date: Thu, 10 Sep 2020 00:48:41 +0300 Subject: [PATCH 3/6] bugfix/#741 - update Node type --- src/types/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types/index.js b/src/types/index.js index d5a2836..9dadceb 100644 --- a/src/types/index.js +++ b/src/types/index.js @@ -34,7 +34,9 @@ export type Node = { category?: string, tags?: string[], title: string, - socialImage?: string + socialImage?: { + publicURL: string + } }, html: string, id: string From f0c22e3583d56e3890e569646467f151c4410b76 Mon Sep 17 00:00:00 2001 From: alxshelepenok Date: Thu, 10 Sep 2020 00:53:50 +0300 Subject: [PATCH 4/6] bugfix/#741 - fix socialImageUrl --- src/components/Layout/Layout.js | 2 +- src/templates/page-template.js | 2 +- src/templates/post-template.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Layout/Layout.js b/src/components/Layout/Layout.js index e1cf2a8..d54528f 100644 --- a/src/components/Layout/Layout.js +++ b/src/components/Layout/Layout.js @@ -19,7 +19,7 @@ const Layout = ({ socialImage }: Props) => { const { author, url } = useSiteMetadata(); - const metaImage = socialImage != null ? socialImage : author.photo; + const metaImage = socialImage !== null ? socialImage : author.photo; const metaImageUrl = url + metaImage; return ( diff --git a/src/templates/page-template.js b/src/templates/page-template.js index 1511d97..335ec03 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 = socialImage ? socialImage['publicURL'] : null; return ( diff --git a/src/templates/post-template.js b/src/templates/post-template.js index d7c4b63..e81a77b 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 = socialImage ? socialImage['publicURL'] : null; return ( From 4a9648b189a7f126d011b7c79ac89e260406769d Mon Sep 17 00:00:00 2001 From: alxshelepenok Date: Thu, 10 Sep 2020 01:01:35 +0300 Subject: [PATCH 5/6] bugfix/#741 - fix type of socialImage, fix condition --- src/components/Layout/Layout.js | 2 +- src/templates/page-template.js | 2 +- src/templates/post-template.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Layout/Layout.js b/src/components/Layout/Layout.js index d54528f..eef7295 100644 --- a/src/components/Layout/Layout.js +++ b/src/components/Layout/Layout.js @@ -19,7 +19,7 @@ const Layout = ({ socialImage }: Props) => { const { author, url } = useSiteMetadata(); - const metaImage = socialImage !== null ? socialImage : author.photo; + const metaImage = socialImage.length > 0 ? socialImage : author.photo; const metaImageUrl = url + metaImage; return ( diff --git a/src/templates/page-template.js b/src/templates/page-template.js index 335ec03..1511d97 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'] : null; + const socialImageUrl = socialImage ? socialImage['publicURL'] : ''; return ( diff --git a/src/templates/post-template.js b/src/templates/post-template.js index e81a77b..d7c4b63 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'] : null; + const socialImageUrl = socialImage ? socialImage['publicURL'] : ''; return ( From 5c7fa1046018c6ceb1ce11fa70c67486874b9d6a Mon Sep 17 00:00:00 2001 From: alxshelepenok Date: Thu, 10 Sep 2020 01:09:00 +0300 Subject: [PATCH 6/6] 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 (