Skip to content
Permalink
Browse files

feat(comments): add support for utterances comment system

Fix #288
  • Loading branch information...
talha131 committed Aug 17, 2019
1 parent 8c69c41 commit a2151cc25c5a49b7ef6dd7f86e7ebc5bac03465f
@@ -183,3 +183,4 @@
},
}
DISQUS_FILTER = True
UTTERANCES_FILTER = True
@@ -37,6 +37,8 @@
SITEURL = ""

MAILCHIMP_FORM_ACTION = os.environ.get("MAILCHIMP_FORM_ACTION")
UTTERANCES_REPO = "Pelican-Elegant/elegant"
UTTERANCES_LABEL = "💬documentation-comments"

RELATIVE_URLS = False
# filetime_from_git is very slow. Use it in production only
@@ -67,6 +67,24 @@
{% set DISQUS_FILTER = DISQUS_FILTER %}
{% endif %}

{% if not UTTERANCES_FILTER %}
{% set UTTERANCES_FILTER = False %}
{% else %}
{% set UTTERANCES_FILTER = UTTERANCES_FILTER %}
{% endif %}

{% if not UTTERANCES_THEME %}
{% set UTTERANCES_THEME = 'github-light' %}
{% else %}
{% set UTTERANCES_THEME = UTTERANCES_THEME %}
{% endif %}

{% if not UTTERANCES_LABEL %}
{% set UTTERANCES_LABEL = '' %}
{% else %}
{% set UTTERANCES_LABEL = UTTERANCES_LABEL %}
{% endif %}

{# Author's twitter handle. Used in Twitter card meta data #}
{% if not TWITTER_USERNAME %}
{% set TWITTER_USERNAME = '' %}
@@ -1,8 +1,11 @@
{% macro comments_section(article) %}

{% from '_includes/_defaults.html' import DISQUS_FILTER with context %}
{% from '_includes/_defaults.html' import DISQUS_FILTER, UTTERANCES_FILTER with context %}

{% set use_disqus = (not DISQUS_FILTER or article.disqus_filter == "off") and DISQUS_SITENAME and article.disqus_filter != "on" %}

{% set use_utterances = (not UTTERANCES_FILTER or article.utterances_filter == "off") and UTTERANCES_REPO and article.utterances_filter != "on" %}

{% set identifier = SITEURL+ '/' + article.url %}
{% if article.comment_id %}
{% set identifier = article.comment_id %}
@@ -16,7 +19,7 @@
{% set intro = article.comments_intro %}
{% endif %}

{% if article.status != 'draft' and article.comments != 'False' and (use_disqus) %}
{% if article.status != 'draft' and article.comments != 'False' and (use_disqus or use_utterances) %}

<section>
<h6 style="display:none;">Comments</h6>
@@ -42,6 +45,11 @@ <h6 style="display:none;">Comments</h6>
{% if use_disqus %}
<div id="disqus_thread"></div>
{% endif %}

{% if use_utterances %}
{% from '_includes/utterances_scripts.html' import comments_script_utterances with context %}
{{ comments_script_utterances(UTTERANCES_REPO, identifier, UTTERANCES_LABEL, UTTERANCES_THEME) }}
{% endif %}
</div>
</div>
</div>
@@ -0,0 +1,10 @@
{% macro comments_script_utterances(repo, id, label, theme) %}
<script src="https://utteranc.es/client.js"
repo="{{ repo }}"
issue-term="{{ id }}"
label="{{ label }}"
theme="{{ theme }}"
crossorigin="anonymous"
async>
</script>
{% endmacro %}

0 comments on commit a2151cc

Please sign in to comment.
You can’t perform that action at this time.