Merge pull request #755 from alxshelepenok/bugfix/#741

bugfix/#741 - upgrade gatsby-remark-relative-images
This commit is contained in:
Alexander Shelepenok 2020-09-10 01:19:25 +03:00 committed by GitHub
commit a79523a5da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 15 deletions

View File

@ -18,8 +18,8 @@ module.exports = {
{ {
resolve: 'gatsby-source-filesystem', resolve: 'gatsby-source-filesystem',
options: { options: {
path: `${__dirname}/content`, path: `${__dirname}/static`,
name: 'pages' name: 'assets'
} }
}, },
{ {
@ -32,15 +32,15 @@ module.exports = {
{ {
resolve: 'gatsby-source-filesystem', resolve: 'gatsby-source-filesystem',
options: { options: {
name: 'css', path: `${__dirname}/content`,
path: `${__dirname}/static/css` name: 'pages'
} }
}, },
{ {
resolve: 'gatsby-source-filesystem', resolve: 'gatsby-source-filesystem',
options: { options: {
name: 'assets', name: 'css',
path: `${__dirname}/static` path: `${__dirname}/static/css`
} }
}, },
{ {

View File

@ -1,7 +1,6 @@
// @flow strict // @flow strict
import React from 'react'; import React from 'react';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import { withPrefix } from 'gatsby';
import type { Node as ReactNode } from 'react'; import type { Node as ReactNode } from 'react';
import { useSiteMetadata } from '../../hooks'; import { useSiteMetadata } from '../../hooks';
import styles from './Layout.module.scss'; import styles from './Layout.module.scss';
@ -10,7 +9,7 @@ type Props = {
children: ReactNode, children: ReactNode,
title: string, title: string,
description?: string, description?: string,
socialImage? :string socialImage?: string
}; };
const Layout = ({ const Layout = ({
@ -20,8 +19,8 @@ const Layout = ({
socialImage socialImage
}: Props) => { }: Props) => {
const { author, url } = useSiteMetadata(); const { author, url } = useSiteMetadata();
const metaImage = socialImage != null ? socialImage : author.photo; const metaImage = typeof socialImage !== 'undefined' ? socialImage : author.photo;
const metaImageUrl = url + withPrefix(metaImage); const metaImageUrl = url + metaImage;
return ( return (
<div className={styles.layout}> <div className={styles.layout}>

View File

@ -19,9 +19,10 @@ const PageTemplate = ({ data }: Props) => {
const { frontmatter } = data.markdownRemark; const { frontmatter } = data.markdownRemark;
const { title: pageTitle, description: pageDescription, socialImage } = frontmatter; const { title: pageTitle, description: pageDescription, socialImage } = frontmatter;
const metaDescription = pageDescription !== null ? pageDescription : siteSubtitle; const metaDescription = pageDescription !== null ? pageDescription : siteSubtitle;
const socialImageUrl = typeof socialImage !== 'undefined' ? socialImage['publicURL'] : undefined;
return ( return (
<Layout title={`${pageTitle} - ${siteTitle}`} description={metaDescription} socialImage={socialImage} > <Layout title={`${pageTitle} - ${siteTitle}`} description={metaDescription} socialImage={socialImageUrl} >
<Sidebar /> <Sidebar />
<Page title={pageTitle}> <Page title={pageTitle}>
<div dangerouslySetInnerHTML={{ __html: pageBody }} /> <div dangerouslySetInnerHTML={{ __html: pageBody }} />
@ -39,7 +40,9 @@ export const query = graphql`
title title
date date
description description
socialImage socialImage {
publicURL
}
} }
} }
} }

View File

@ -17,9 +17,10 @@ const PostTemplate = ({ data }: Props) => {
const { frontmatter } = data.markdownRemark; const { frontmatter } = data.markdownRemark;
const { title: postTitle, description: postDescription, socialImage } = frontmatter; const { title: postTitle, description: postDescription, socialImage } = frontmatter;
const metaDescription = postDescription !== null ? postDescription : siteSubtitle; const metaDescription = postDescription !== null ? postDescription : siteSubtitle;
const socialImageUrl = typeof socialImage !== 'undefined' ? socialImage['publicURL'] : undefined;
return ( return (
<Layout title={`${postTitle} - ${siteTitle}`} description={metaDescription} socialImage={socialImage} > <Layout title={`${postTitle} - ${siteTitle}`} description={metaDescription} socialImage={socialImageUrl} >
<Post post={data.markdownRemark} /> <Post post={data.markdownRemark} />
</Layout> </Layout>
); );
@ -39,7 +40,9 @@ export const query = graphql`
description description
tags tags
title title
socialImage socialImage {
publicURL
}
} }
} }
} }

View File

@ -34,7 +34,9 @@ export type Node = {
category?: string, category?: string,
tags?: string[], tags?: string[],
title: string, title: string,
socialImage?: string socialImage?: {
publicURL: string
}
}, },
html: string, html: string,
id: string id: string