自从多说挂了之后,网站的评论系统一直缺席中,今天自己部署个LiveRe吧,现在用的hueman主题,就以此主题为例,自己动手丰衣足食了。

  1. 在主题的配置文件中增加一项,livere
    ...\themes\hueman\_config.yml
1
2
comment:
livere: your data id

2.在...\themes\hueman\layout\comment增加livere.ejs评论模块代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!-- LiveRe City install code -->
<div id="lv-container" data-id="city" data-uid="********">
<script type="text/javascript">
(function(d, s) {
var j, e = d.getElementsByTagName(s)[0];

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>Please activate JavaScript for write a comment in LiveRe</noscript>
</div>
<!-- completed City install code -->

3.相关文件增加判断

...\themes\hueman\layout\comment\index.ejs

1
2
<% } else if (theme.comment.livere) { %>
<%- partial('comment/livere') %>

...\themes\hueman\layout\comment\scripts.ejs

1
2
<% } else if (theme.comment.livere) { %>
<%- partial('comment/livere', { script: true }) %>

可是现在有个奇怪的问题,为什么评论框会出现两次? 求高手解救!