给hexo博客添加LiveRe评论模块

多说评论框是一款WordPress社会化评论插件,随着多说服务在6月1号的关闭,我们不得不寻找新的评论插件,发现一款韩国的LiveRe插件还不错,尝试配置一下。

LiveRe注册

到LiveRe官网注册,我们用免费的City版本就好。注册完成后安装,添加你想要服务的博客地址。我们需要一个Uid,Uid在管理页面→代码管理→一般网站→data-uid。这个网站很坑,我打开N遍才打开到这个页面。

配置主题文件

在_config.xml找到LiveRe,去掉注释,将上一步的data-uid填入

 
     
1
2
3
 
     
# Support for LiveRe comments system.
# You can get your uid from https://livere.com/insight/myCode (General web site)
livere_uid: MTAy************

配置livere.swig文件

首先查看目录下有没有这个文件,没有这个文件的话手动创建目录及文件,我的文件在/home/blog/themes/next/layout/_scripts/third-party/comments/livere.swig,自己手动创建的话需要添加如下代码

 
     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
     
{% if not (theme.duoshuo and theme.duoshuo.shortname) and not theme.duoshuo_shortname and not theme.disqus_shortname and not theme.hypercomments_id and not theme.gentie_productKey %}
{% if theme.livere_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>
{% endif %}
{% endif %}

大体内容是优先启用其他的评论插件:例如多说、disqus等,如果没有的话再启用LiveRe插件。以上代码也是在之前获取Uid的页面中获得。

配置comments.swig文件

此文件在路径/home/blog/themes/next/layout/_scripts/third-party下,打开后看看有没有如下代码,没有的话追加。

 
     
1
 
     
{% include './comments/livere.swig' %}

LiveRe插件至此配置完成。

猜你喜欢

转载自blog.csdn.net/Battle_Mage/article/details/80038639