add valine comment system

i18n
xaoxuu 6 years ago
parent b5a2f1a8f2
commit 05ba5ec30a
  1. 31
      README.md
  2. 77
      layout/_partial/article.ejs

@ -65,14 +65,43 @@ avatar: "https://xaoxuu.com/assets/img/avatar.jpg"
``` ```
### 评论 ### 评论
如果你使用其他的评论系统,请自己修改主题。 提供3种可选,建议一次只使用一种评论系统。如果你使用其他的评论系统,请自己修改主题。
#### Disqus
官网: [http://disqus.com/](http://disqus.com/)
```yaml ```yaml
# disqus评论 # disqus评论
disqus_shortname: #你的disqus的shortname# disqus_shortname: #你的disqus的shortname#
```
#### Livere 来必力
官网: [http://www.laibili.com.cn/](http://www.laibili.com.cn/)
```yaml
# 来必力评论 # 来必力评论
livere_shortname: #你的disqus的shortname# livere_shortname: #你的disqus的shortname#
``` ```
#### Valine
官网: [https://valine.js.org](https://valine.js.org)
```yaml
# valine
valine:
enable: true # 如果你想用Valine评论系统,请设置enable为true
appId:
appKey:
guest_info: nick,mail #valine comment header info
placeholder: 快来评论吧~ # valine comment input placeholder(like: Please leave your footprints )
avatar: mp # gravatar style https://valine.js.org/avatar
pageSize: 10 # comment list page size
verify: false # valine verify code (true/false)
notify: false # valine mail notify (true/false)
lang: zh-cn
```
### 推荐文章 ### 推荐文章

@ -56,32 +56,65 @@
</article> </article>
<br> <br>
<article class="post white-box article-type-<%= post.layout %>>"> <article class="post white-box article-type-<%= post.layout %>>">
<section class="article typo"> <section class="article typo">
<% if (post.comments && config.livere_shortname){ %> <% if (post.comments) { %>
<section id="comments"> <% if (config.livere_shortname){ %>
<div id="lv-container" data-id="city" data-uid="MTAyMC8yOTU4Ny82MTU1"> <section id="comments">
<script type="text/javascript"> <div id="lv-container" data-id="city" data-uid="MTAyMC8yOTU4Ny82MTU1">
(function(d, s) { <script type="text/javascript">
var j, e = d.getElementsByTagName(s)[0]; (function(d, s) {
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; } if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
j.async = true;
e.parentNode.insertBefore(j, e);
})(document, 'script');
</script>
<noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
</div>
</section>
<% } %>
j = d.createElement(s); <% if (config.disqus_shortname) { %>
j.src = 'https://cdn-city.livere.com/js/embed.dist.js'; <section id="comments">
j.async = true; <div id="disqus_thread">
无法加载评论系统,请确保您的网络能够正常访问 <a href="https://disqus.com">Disqus</a> 。
</div>
</section>
<% } %>
e.parentNode.insertBefore(j, e); <% if (config.valine.enable && config.valine.appId && config.valine.appKey){ %>
})(document, 'script'); <section id="comments">
</script> <div id="valine_container" class="valine_thread"></div>
<noscript> 为正常使用来必力评论功能请激活JavaScript</noscript> <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
</div> <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
</section> <script>
<% } %> var GUEST_INFO = ['nick','mail','link'];
<% if (post.comments && config.disqus_shortname){ %> var guest_info = '<%= config.valine.guest_info %>'.split(',').filter(function(item){
<section id="comments"> return GUEST_INFO.indexOf(item) > -1
<div id="disqus_thread">⚠无法加载评论系统,请确保您的网络能够正常访问 <a href="https://disqus.com">Disqus</a> 。</div> });
</section> var notify = '<%= config.valine.notify %>' == true;
var verify = '<%= config.valine.verify %>' == true;
var valine = new Valine();
valine.init({
el: '#valine_container',
notify: notify,
verify: verify,
guest_info: guest_info,
appId: "<%= config.valine.appId %>",
appKey: "<%= config.valine.appKey %>",
placeholder: "<%= config.valine.placeholder %>",
pageSize:'<%= config.valine.pageSize %>',
avatar:'<%= config.valine.avatar %>',
lang:'<%= config.valine.lang %>'
})
</script>
</section>
<% } %>
<% } %> <% } %>
<% if (post && theme.recommended_posts.enabled) { %> <% if (post && theme.recommended_posts.enabled) { %>
<%- partial('post/recommended_posts', {page: post, site: site}) %> <%- partial('post/recommended_posts', {page: post, site: site}) %>

Loading…
Cancel
Save