给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插件至此配置完成。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要为 Hexo 添加搜索功能,你可以使用第三方搜索引擎,如 Algolia 或 Google Custom Search。这里我们介绍如何使用 Algolia。 Algolia 是一个强大的搜索引擎,提供了易于使用的 API,可以轻松地将搜索功能添加到你的 Hexo 中。以下是如何为 Hexo 添加 Algolia 搜索的步骤: 1. 注册 Algolia 账户并创建一个应用程序。 2. 安装 Hexo Algolia 插件。 ``` npm install hexo-algolia --save ``` 3. 在根目录下创建一个名为 `algolia.json` 的配置文件,并填写以下内容: ``` { "applicationID": "YOUR_APP_ID", "apiKey": "YOUR_API_KEY", "indexName": "YOUR_INDEX_NAME" } ``` 将 `YOUR_APP_ID`、`YOUR_API_KEY` 和 `YOUR_INDEX_NAME` 替换为你在 Algolia 上创建的应用程序的信息。 4. 在你的 Hexo 主题中添加搜索框和搜索结果页面。 在主题的相应文件中添加以下代码: 搜索框: ```html <form class="search-form" method="get" action="/search/"> <input class="search-input" type="text" placeholder="Search" name="query"> <button class="search-submit" type="submit">Search</button> </form> ``` 搜索结果页面: ```html --- title: "Search Results" layout: "search" --- <section class="search-results"> {% for page in page.posts %} <article class="search-result"> <h2 class="search-result-title"><a href="{{ page.url }}">{{ page.title }}</a></h2> <p class="search-result-excerpt">{{ page.excerpt }}</p> </article> {% endfor %} </section> ``` 5. 重新生成站点并上传到你的服务器。 ``` hexo generate ``` 6. 同步你的数据到 Algolia 上。 ``` hexo algolia ``` 完成以上步骤后,你的 Hexo 就可以使用 Algolia 进行搜索了。当用户在搜索框中输入关键字并提交时,将会跳转到搜索结果页面,显示与关键字匹配的文章列表。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值