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

Add option for comment_count show or hide #1493

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ comments:
storage: true
# Lazyload all comment systems.
lazyload: false
# Show on home page
display: true
# Modify texts or order for any navs, here are some examples.
nav:
#disqus:
Expand Down
18 changes: 10 additions & 8 deletions scripts/filters/comment/changyan.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ hexo.extend.filter.register('theme_inject', injects => {
{% if post.comments %}
<span class="post-meta-item">
${iconText('far fa-comment', 'changyan')}
{% if is_post() %}
<a title="changyan" href="{{ url_for(post.path) }}#SOHUCS" itemprop="discussionUrl">
<span id="changyan_count_unit" class="post-comments-count hc-comment-count" data-xid="{{ post.path }}" itemprop="commentCount"></span>
</a>
{% else %}
<a title="changyan" href="{{ url_for(post.path) }}#SOHUCS" itemprop="discussionUrl">
<span id="url::{{ post.permalink }}" class="cy_cmt_count" data-xid="{{ post.path }}" itemprop="commentCount"></span>
</a>
{% if theme.comments.display %}
{% if is_post() %}
<a title="changyan" href="{{ url_for(post.path) }}#SOHUCS" itemprop="discussionUrl">
<span id="changyan_count_unit" class="post-comments-count hc-comment-count" data-xid="{{ post.path }}" itemprop="commentCount"></span>
</a>
{% else %}
<a title="changyan" href="{{ url_for(post.path) }}#SOHUCS" itemprop="discussionUrl">
<span id="url::{{ post.permalink }}" class="cy_cmt_count" data-xid="{{ post.path }}" itemprop="commentCount"></span>
</a>
{% endif %}
{% endif %}
</span>
{% endif %}
Expand Down
16 changes: 9 additions & 7 deletions scripts/filters/comment/disqus.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ hexo.extend.filter.register('theme_inject', injects => {
if (!theme.disqus.enable || !theme.disqus.shortname || !theme.disqus.count) return;

injects.postMeta.raw('disqus', `
{% if post.comments %}
<span class="post-meta-item">
${iconText('far fa-comment', 'disqus')}
<a title="disqus" href="{{ url_for(post.path) }}#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="{{ post.path }}" itemprop="commentCount"></span>
</a>
</span>
{% if theme.comments.display %}
{% if post.comments %}
<span class="post-meta-item">
${iconText('far fa-comment', 'disqus')}
<a title="disqus" href="{{ url_for(post.path) }}#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="{{ post.path }}" itemprop="commentCount"></span>
</a>
</span>
{% endif %}
{% endif %}
`, {}, {}, theme.disqus.post_meta_order);

Expand Down
16 changes: 9 additions & 7 deletions scripts/filters/comment/valine.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ hexo.extend.filter.register('theme_inject', injects => {
if (!theme.valine.enable || !theme.valine.appid || !theme.valine.appkey) return;

injects.postMeta.raw('valine', `
{% if post.comments and (is_post() or theme.valine.comment_count) %}
<span class="post-meta-item">
${iconText('far fa-comment', 'valine')}
<a title="valine" href="{{ url_for(post.path) }}#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="{{ url_for(post.path) }}" itemprop="commentCount"></span>
</a>
</span>
{% if theme.comments.display %}
{% if post.comments and (is_post() or theme.valine.comment_count) %}
<span class="post-meta-item">
${iconText('far fa-comment', 'valine')}
<a title="valine" href="{{ url_for(post.path) }}#valine-comments" itemprop="discussionUrl">
<span class="post-comments-count valine-comment-count" data-xid="{{ url_for(post.path) }}" itemprop="commentCount"></span>
</a>
</span>
{% endif %}
{% endif %}
`, {}, {}, theme.valine.post_meta_order);

Expand Down