Skip to content

Commit

Permalink
refactor(comments): simplify code
Browse files Browse the repository at this point in the history
update #288
  • Loading branch information
talha131 committed Aug 12, 2019
1 parent 9367d95 commit b382ccc
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions templates/_includes/comments.html
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
{% macro comments_disqus(article) %}
{% if article.status != 'draft' and article.comments != 'False' %}

{% from '_includes/_defaults.html' import DISQUS_FILTER with context %}
{% from '_includes/_defaults.html' import DISQUS_FILTER with context %}
{% set use_disqus = (not DISQUS_FILTER or article.disqus_filter == "off") and DISQUS_SITENAME and article.disqus_filter != "on" %}

{%if (not DISQUS_FILTER or article.disqus_filter == "off") and DISQUS_SITENAME and article.disqus_filter != "on" %}
{% set identifier = SITEURL+ '/' + article.url %}
{% if article.comment_id %}
{% set identifier = article.comment_id %}
{% elif article.disqus_identifier %}
{% set identifier = article.disqus_identifier %}
{% endif %}

<section>
{% from '_includes/_defaults.html' import COMMENTS_INTRO with context %}
{% set intro = COMMENTS_INTRO %}
{% if article.comments_intro %}
<p id="comment-message">{{ article.comments_intro }} </p>
{% else %}
{% from '_includes/_defaults.html' import COMMENTS_INTRO with context %}
{%if COMMENTS_INTRO %}
<p id="comment-message">{{ COMMENTS_INTRO }} </p>
{% endif %}
{% set intro = article.comments_intro %}
{% endif %}

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


<section>
<p id="comment-message">{{ intro }} </p>

<div class="accordion" id="accordion2">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle disqus-comment-count comment-count" data-toggle="collapse" data-parent="#accordion2"
{% if article.comment_id %}
data-disqus-identifier="{{ article.comment_id }}"
{% elif article.disqus_identifier %}
data-disqus-identifier="{{ article.disqus_identifier }}"
{% endif %}
href="{{ SITEURL }}/{{ article.url }}#comment_thread",
id="comment-accordion-toggle">
<a class="accordion-toggle disqus-comment-count comment-count"
data-toggle="collapse"
data-parent="#accordion2"
{%if use_disqus %}
data-disqus-identifier="{{ identifier }}"
{% endif %}
href="{{ SITEURL }}/{{ article.url }}#comment_thread",
id="comment-accordion-toggle">
Comments
</a>
</div>
<div id="comment_thread" class="accordion-body collapse">
<div class="accordion-inner">
<div class="comments">
{% if use_disqus %}
{% from '_includes/disqus_scripts.html' import disqus_comments_script with context %}
{{ disqus_comments_script(article) }}
{% endif %}
</div>
</div>
</div>
</div>
</div>
</section>
{% endif %}
{% endif %}
{% endif %}
{% endmacro %}

{% macro comments_script_disqus(article) %}
Expand Down

0 comments on commit b382ccc

Please sign in to comment.