之前我们升级了 Waline 到 1.3.4,已经获得了统计文章浏览量和评论数的能力。本文将该数据显示在文章标题处。
修改 themes -> fluid -> layout -> _partial -> post-meta.ejs
<% if (theme.post.meta.views.source === 'leancloud') { %>
<!-- LeanCloud 统计文章PV -->
<span id="leancloud-page-views-container" class="post-meta" style="display: none">
<i class="iconfont icon-eye" aria-hidden="true"></i>
<%- views_texts[0] %><span id="leancloud-page-views"></span><%- views_texts[1] %>
<span id="waline-comment-count-container" style="display: none">
 
<i class="iconfont icon-comment" aria-hidden="true"></i>
<span id="test_id_visitor"></span>
</span>
<script>
path = window.location.pathname
console.log(path)
video_html_res = "<span id='" + path + "' class='waline-comment-count'></span> 评论"
console.log(video_html_res)
document.getElementById("test_id_visitor").innerHTML = video_html_res;
</script>
</span>
themes -> fluid -> layout -> _partial -> comments -> waline.ejs
new Waline(options);
wa_ccc = "waline-comment-count-container"
var i=document.getElementById(wa_ccc)
i.style.display = 'inline'
new Waline(options);
之后不得已改了源码,有些丑陋,之后努力优雅实现一下