Skip to content

Commit

Permalink
gatsby-config.js를 웹에서 접근하지 못하도록 변경
Browse files Browse the repository at this point in the history
Disqus에서 해당 파일을 로드하는 것 때문에, dotenv를 웹에서 로드해서 fs
패키지를 찾지 못한다는 에러가 발생하였다.

항상 siteMetadata는 graphql을 통해서 하도록 한다
  • Loading branch information
ybbarng committed Feb 6, 2018
1 parent 5903d60 commit 3ba9236
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"author": "Bang Yongbae <ybbarng@gmail.com>",
"license": "MIT",
"dependencies": {
"dotenv": "4.0.0",
"gatsby": "^1.9.82",
"gatsby-link": "^1.6.22",
"gatsby-plugin-catch-links": "^1.0.5",
Expand Down Expand Up @@ -52,6 +51,7 @@
},
"devDependencies": {
"babel-eslint": "^7.2.3",
"dotenv": "4.0.0",
"eslint": "^3.x",
"eslint-config-airbnb": "^13.0.0",
"eslint-plugin-import": "^2.2.x",
Expand Down
9 changes: 4 additions & 5 deletions src/components/Disqus/Disqus.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactDisqusComments from 'react-disqus-comments';
import config from '../../../gatsby-config';
import { getPath } from '../../utils';
import Post from '../../models/post';

Expand All @@ -25,14 +24,14 @@ class Disqus extends Component {
this.setState({ toasts });
}
render() {
const { post } = this.props;
if (!config.siteMetadata.disqusShortname) {
const { post, siteMetadata } = this.props;
if (!siteMetadata.disqusShortname) {
return null;
}
const url = config.siteMetadata.url + encodeURI(getPath(Post, post.slug));
const url = siteMetadata.url + encodeURI(getPath(Post, post.slug));
return (
<ReactDisqusComments
shortname={config.siteMetadata.disqusShortname}
shortname={siteMetadata.disqusShortname}
identifier={post.datetime}
title={post.title}
url={url}
Expand Down
2 changes: 1 addition & 1 deletion src/components/PostTemplateDetails/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PostTemplateDetails extends React.Component {

const commentsBlock = (
<div>
<Disqus post={post} />
<Disqus post={post} siteMetadata={this.props.data.site.siteMetadata} />
</div>
);

Expand Down
2 changes: 2 additions & 0 deletions src/templates/post-template.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const pageQuery = graphql`
name
about
}
disqusShortname
url
}
}
contentfulPost (id: { eq: $id }) {
Expand Down

0 comments on commit 3ba9236

Please sign in to comment.