mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-01-14 07:41:50 +01:00
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:
commit
ccc8c48085
@ -1,6 +1,5 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import ReactDisqusComments from 'react-disqus-comments';
|
import ReactDisqusComments from 'react-disqus-comments';
|
||||||
import config from '../../../gatsby-config';
|
|
||||||
|
|
||||||
class Disqus extends Component {
|
class Disqus extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -20,15 +19,15 @@ class Disqus extends Component {
|
|||||||
this.setState({ toasts });
|
this.setState({ toasts });
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const { postNode } = this.props;
|
const { postNode, siteMetadata } = this.props;
|
||||||
if (!config.siteMetadata.disqusShortname) {
|
if (!siteMetadata.disqusShortname) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const post = postNode.frontmatter;
|
const post = postNode.frontmatter;
|
||||||
const url = config.siteMetadata.url + postNode.fields.slug;
|
const url = siteMetadata.url + postNode.fields.slug;
|
||||||
return (
|
return (
|
||||||
<ReactDisqusComments
|
<ReactDisqusComments
|
||||||
shortname={config.siteMetadata.disqusShortname}
|
shortname={siteMetadata.disqusShortname}
|
||||||
identifier={post.title}
|
identifier={post.title}
|
||||||
title={post.title}
|
title={post.title}
|
||||||
url={url}
|
url={url}
|
||||||
|
@ -32,7 +32,7 @@ class PostTemplateDetails extends React.Component {
|
|||||||
|
|
||||||
const commentsBlock = (
|
const commentsBlock = (
|
||||||
<div>
|
<div>
|
||||||
<Disqus postNode={post} />
|
<Disqus postNode={post} siteMetadata={this.props.data.site.siteMetadata} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ export const pageQuery = graphql`
|
|||||||
name
|
name
|
||||||
twitter
|
twitter
|
||||||
}
|
}
|
||||||
|
disqusShortname
|
||||||
|
url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
markdownRemark(fields: { slug: { eq: $slug } }) {
|
markdownRemark(fields: { slug: { eq: $slug } }) {
|
||||||
|
Loading…
Reference in New Issue
Block a user