tterb / gatsby-plugin-disqus

:speech_balloon: A plugin for adding Disqus comments to GatsbyJS
https://brettstevenson.io/gatsby-plugin-disqus
MIT License
45 stars 5 forks source link

Unable to show comments due to "config not defined" in blog-post.js #31

Closed erikmartinessanches closed 4 years ago

erikmartinessanches commented 4 years ago

Describe the bug
Following the instructions here and later running npm run deploy results in this error:

success Building production JavaScript and CSS bundles - 3.974s
failed Building static HTML for pages - 1.425s

 ERROR #95313

Building static HTML failed for path "/hello-world/"

See our docs page for more info on this error: https://gatsby.dev/debug-html

  15 |
  16 |   let disqusConfig = {
> 17 |     url: `${config.siteUrl + location.pathname}`,
     |             ^
  18 |     identifier: post.id,
  19 |     title: post.title,
  20 |   }

  WebpackError: ReferenceError: config is not defined

  - blog-post.js:17
    src/templates/blog-post.js:17:13

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-starter-blog@0.1.0 deploy: `gatsby build && gh-pages -d public -b master`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-starter-blog@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Erik\AppData\Roaming\npm-cache\_logs\2020-08-07T15_25_10_004Z-debug.log

If I changed
url: `${config.siteUrl + location.pathname}`, to url: `${data.site.siteMetadata.siteUrl + location.pathname}`, ` it deploys but the comments don't load, saying:

We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

My repo. I have already set up a site in Disqus admin setting and set a trusted domain to erikmartinessanches.github.io.

Specifications:

tterb commented 4 years ago

@erikmartinessanches The config.siteUrl in the example is dependant on how you've configured your site, so any way of providing the url should work. If data.site.siteMetadata.siteUrl + location.pathname isn't working, then I would recommend adding a console.log to make sure that it is creating a valid URL. Additionally, are you able to get the Disqus component to load when you run your site locally?

tterb commented 4 years ago

@erikmartinessanches I'm going to assume this issue was resolved and close it out since it appears to have gone silent, but let me know if you're still experiencing this issue and we can reopen it.