rstudio / distill

Distill for R Markdown
https://rstudio.github.io/distill/
Apache License 2.0
422 stars 57 forks source link

Can there be alternatives to Disqus for article comments? #155

Open taraskaduk opened 4 years ago

taraskaduk commented 4 years ago

Distill supports an easy addition of Disqus comments, as listed in the documentation:

Readers will likely want to comment on and share articles they read on your blog. You can enable support for Disqus comments and sharing links for Twitter, LinkedIn, and other services by adding options to the collection:posts section of _site.yml.

This is the only mention of any comment engine in the documentation.

There exists an opinion (as voiced by Bob Rudis @hrbrmstr on Twitter, and later repeated by @maelle here) against Disqus.

Can more lightweight commenting engines (such as GitHub Utterances) be easily added to a Distill blog, and should this be reflected in the documentation?

taraskaduk commented 4 years ago

Found a solution, per @milesmcbain: https://milesmcbain.micro.blog/2020/09/04/how-i-got.html

taraskaduk commented 4 years ago

An additional comment to this is that Miles' HTML script adds Utterances in between the post and the appendix. If one wanted to have the comments after the appendix, this would have to be reflected in HTML.

More specifically, in this line: var article = document.querySelector("d-appendix");

<script>
  document.addEventListener("DOMContentLoaded", function () {
    if (!/posts/.test(location.pathname)) {
      return;
    }
    var script = document.createElement("script");
    script.src = "https://utteranc.es/client.js";
    script.setAttribute("repo", "your-github/your-repo");
    script.setAttribute("issue-term", "og:title");
    script.setAttribute("crossorigin", "anonymous");
    script.setAttribute("label", "comment_thread");

    /* wait for article to load, append script to article element */
    var observer = new MutationObserver(function (mutations, observer) {
      var article = document.querySelector("d-appendix");
      if (article) {
        observer.disconnect();
        /* HACK: article scroll */
        article.setAttribute("style", "overflow-y: hidden");
        article.appendChild(script);
      }
    });
    observer.observe(document.body, { childList: true });
  });
</script>
taraskaduk commented 4 years ago

@apreshill, I see your name in many of the issues recently, thought I'd tag you here. I closed this issue, but perhaps Utterances can be added to the documentation along with Disqus in the future. I provided all crucial info above.

Just a thought. I know that not everyone is hot on Disqus and their data collection.

apreshill commented 4 years ago

Thank you @taraskaduk! Reopening to add to docs.

taraskaduk commented 4 years ago

@apreshill thanks! I only closed it as I felt like there is already too many opened issues (that perhaps should be closed), and technically speaking, I was able to solve my issue in a roundabout way.

LMK if I can help here in any way that is productive.

joelnitta commented 2 years ago

Small update: there is now another option very similar to utterances for commenting on articles, giscus. It uses GitHub Discussions instead of Issues for storing comments. FYI, I wrote a blog post about how to use giscus with Distill.