Permalink
Browse files

feat: show comment count on home page

  • Loading branch information...
MOxFIVE committed Jun 26, 2016
1 parent bb68597 commit 865a26bbcce2c173534653e2ee6ea201a22fe6ff
View
@@ -85,6 +85,10 @@ preload_comment: true
## false: 当点击评论条等区域时再加载评论模块
## false: load comment's section until u click/hover on the bar/icon
show_count: false
## 是否在主页文章标题旁显示评论数(多说、Disqus)
## Add comment count after article title
disqus:
#on: true
shortname:
@@ -3,6 +3,7 @@
<% } %>
<script data-main="<%-config.root%>js/main.js" src="<%- theme.CDN.require %>"></script>
<%- partial('_partial/background') %>
<%- partial('comments/count-comment') %>
<%- partial('google-analytics') %>
<% if (theme.mathjax){ %>
<%- partial('mathjax') %>
@@ -0,0 +1,42 @@
<% if (is_home() && theme.show_count) { %>
<% if (theme.duoshuo.on) { %>
<script>
if ($(".left-col").is(":visible")) {
var duoshuoQuery = {short_name:"<%=theme.duoshuo.domain%>"};
(function() {
var d = document, s = d.createElement('script');
s.src = 'http://static.duoshuo.com/embed.js';
s.async = true; s.charset = 'UTF-8';
(d.head || d.body).appendChild(s);
})();
$(document).ready(function(){
var $duoshuoCount = $(".ds-thread-count");
$duoshuoCount.bind("DOMNodeInserted", function(e) {
var num = $(this).text().replace(/[^0-9]/ig,"");
$(this).siblings(".count-comment").text(num);
$(this).remove();
})
})
}
</script>
<% } %>
<% if (theme.disqus.on || config.disqus_shortname) { %>
<script id="dsq-count-scr" src="//<%= config.disqus_shortname || theme.disqus.shortname %>.disqus.com/count.js" async></script>
<script>
if ($(".left-col").is(":visible")) {
var $disqusCount = $(".disqus-comment-count");
$disqusCount.bind("DOMNodeInserted", function(e) {
var num = $(this).text().replace(/[^0-9]/ig,"");
if (num > 0) {
$(this).siblings(".count-comment").text(num);
}
$(this).remove();
})
} else {
$(".disqus-comment-count").remove();
}
</script>
<% } %>
<% } %>
@@ -1,3 +1,16 @@
<a href="<%- url_for(post.path) %>" class="<%= class_name %>">
<time datetime="<%= date_xml(post.date) %>" itemprop="datePublished"><%= date(post.date, date_format) %></time>
</a>
</a>
<% if ((is_home() || (is_post() && !theme.preload_comment)) && theme.show_count && (theme.disqus.on || theme.duoshuo.on || config.disqus_shortname)) { %>
<a href="<%- url_for(post.path) %>#comments" title="<%= __('tooltip.jump2comments') %>">
<i class="fa fa-comments-o" aria-hidden="true"></i>
<span class="count-comment"></span>
<% if (theme.duoshuo.on) { %>
<span class="ds-thread-count" <% if (index) { %> data-thread-key="<%=post.path%>" <% } %>"></span>
<% } %>
<% if (theme.disqus.on || config.disqus_shortname) { %>
<span class="disqus-comment-count" data-disqus-identifier="<%= post.path %>"></span>
<% } %>
</a>
<% } %>
@@ -78,7 +78,8 @@
.article-meta{
position: relative;
float: right;
margin-top: -10px;
margin-top: -(5/18)rem
padding-right 0
color: #555;
background: none;
text-align: right;
@@ -230,25 +230,34 @@
}
}
.article-meta{
position: absolute;
right: 0;
top: 23px;
width: 8rem;
font-size: (14/16)rem;
text-align: center;
z-index: 1;
time {
color: #aaa;
&:before {
margin-top: 0px;
margin-right: 4px;
content: "\f073";
font: 1em FontAwesome;
color: #999;
}
}
}
.article-meta
position absolute
right 0
top 23px
width 9rem
padding-right 1.2rem
font-size 0.875rem
text-align right
z-index 1
time
color #aaa
float right
&:before
margin-top 0px
margin-right 4px
content "\f073"
font 1em FontAwesome
color #999
a:nth-child(2)
&:hover
color #258fb8
font-size 110%
i
vertical-align top
clear right
float right
padding-top .45rem
color #999
.article-more-link {
float: right;

0 comments on commit 865a26b

Please sign in to comment.