HyunSeob / hexo-theme-overdose

⚠ Caution: you could be overdosed with this theme.
MIT License
135 stars 29 forks source link

Google anaytics&disqus are no longer availabe #58

Open BenedictNgHK opened 2 months ago

BenedictNgHK commented 2 months ago

Google analytics and disqus are no longer available in for the original theme because the source code embedded in the theme is outdated. Let's assume the root directory is your overdose directory.

For google analytics: modify the code in /layout/includes/head.pug, and find the snippet of code of google analytics, replace it to:

if theme.google_analytics
  script(async src='https://www.googletagmanager.com/gtag/js?id=' + theme.google_analytics)
  script. 
    <!-- Google tag (gtag.js) -->
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', '#{theme.google_analytics}');

For disqus: modifiy the code in /layout/includes/article.pug. The url should be different, you can find it on your disqus account. In my case, it is:

  if config.disqus_shortname
    #disqus_thread
    script.
      (function() { // DON'T EDIT BELOW THIS LINE
      var d = document, s = d.createElement('script');
      s.src = 'https://https-benedictnghk-github-io.disqus.com/embed.js';
      s.setAttribute('data-timestamp', +new Date());
      (d.head || d.body).appendChild(s);
      })();
    noscript Enable JavaScript to see comments.