Decouple the node side code and the browser side code #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is important decoupling between the node side code and the browser side code, because it allows to use the rich features of the node side. For example, I wanted to use 'dotenv' to keep my secret keys, but it have to be not exposed to browser side. If it is exposed, the web console complains that there is no module 'fs'. To accomplish this, the 'gatsby-config.js' file (and maybe gatsby-node.js..?) must be kept in node code.
However, it exposed into browser code because the Disqus module imports it directly.
To decouple this, all of the siteMetadata information is served via GraphQL.
This commit has this change.
I am sorry to say that, I couldn't test this PR is working on your repository code because my development environment fails to build this repository.
Anyway, the changes of this PR is similar to my blog's commit and the changes are very straightforward, I think it will work well.
Please test this PR before merge it because of the lack of test.
References:
gatsbyjs/gatsby#2107 (comment)
https://www.gatsbyjs.org/tutorial/part-four/#our-first-graphql-query