Merge pull request #51 from ybbarng/decoupling-gatsby-config-and-web

Decouple the node side code and the browser side code
This commit is contained in:
Alexander Shelepenok 2018-02-07 13:13:38 +03:00 committed by GitHub
commit ccc8c48085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View File

@ -1,6 +1,5 @@
import React, { Component } from 'react';
import ReactDisqusComments from 'react-disqus-comments';
import config from '../../../gatsby-config';
class Disqus extends Component {
constructor(props) {
@ -20,15 +19,15 @@ class Disqus extends Component {
this.setState({ toasts });
}
render() {
const { postNode } = this.props;
if (!config.siteMetadata.disqusShortname) {
const { postNode, siteMetadata } = this.props;
if (!siteMetadata.disqusShortname) {
return null;
}
const post = postNode.frontmatter;
const url = config.siteMetadata.url + postNode.fields.slug;
const url = siteMetadata.url + postNode.fields.slug;
return (
<ReactDisqusComments
shortname={config.siteMetadata.disqusShortname}
shortname={siteMetadata.disqusShortname}
identifier={post.title}
title={post.title}
url={url}

View File

@ -32,7 +32,7 @@ class PostTemplateDetails extends React.Component {
const commentsBlock = (
<div>
<Disqus postNode={post} />
<Disqus postNode={post} siteMetadata={this.props.data.site.siteMetadata} />
</div>
);

View File

@ -34,6 +34,8 @@ export const pageQuery = graphql`
name
twitter
}
disqusShortname
url
}
}
markdownRemark(fields: { slug: { eq: $slug } }) {