Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable comments on pages/posts #257

Open
kmcyjm opened this issue Nov 27, 2020 · 2 comments
Open

Disable comments on pages/posts #257

kmcyjm opened this issue Nov 27, 2020 · 2 comments

Comments

@kmcyjm
Copy link

kmcyjm commented Nov 27, 2020

Hi,

Today I found an issue where after integrating with Disqus, adding comments: false to the front matter of my "About me" page doesn't let the comment box go away.

After digging for awhile, it is found that adding the following block to the footer.ejs solves the problem,

<% if (page.comments && config.disqus_shortname){ %>
<div id="disqus_thread"></div>
<script>
    /**
    *  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
    *  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables    */
    /*
    var disqus_config = function () {
    this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
    this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
    };
    */
    (function() { // DON'T EDIT BELOW THIS LINE
    var d = document, s = d.createElement('script');
    s.src = 'https://<disqus-short-name.disqus.com/embed.js';
    s.setAttribute('data-timestamp', +new Date());
    (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<% } %>

This is inspired by the post here hexojs/hexo-theme-landscape#178.

I am not a JavaScript developer, hence not sure if this is the best option to solve this issue.

Please help evaluate and make updates as you see fit.

Thanks!

@probberechts
Copy link
Owner

This theme only adds a comment block to blog posts, not to pages. Hence, I do not understand your problem. Is your "about me" page a blog post?

If you create an "about me" page with:

$ hexo new page about

It should not contain a Disqus block.

@probberechts
Copy link
Owner

Apart from that, I think it is a good idea to add an option to disable comments on specific blog posts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants