hexo+yelee搭建博客2

  |  

接入评论

  1. 我使用的是来必力
    注册好账号 获取你的 uid

在这里插入图片描述 2. 在/themes/yelee/layout/_partial/comments 下创建 livere.ejs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<section class="livere" id="comments">
<!-- 来必力City版安装代码 -->
<div id="lv-container" data-id="city" data-uid="<%= theme.livere.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>
<noscript> 为正常使用来必力评论功能请激活JavaScript</noscript>
</div>
<!-- City版安装代码已完成 -->
</section>
  1. 在 themes\yelee\layout_partial\article.ejs 中添加
1
2
3
else if (theme.livere.on) { %>
<%- partial('comments/livere') %>
<% }

在这里插入图片描述 4. 在配置 themes\yelee_config.yml 文件中添加
livere:
on: true
livere_uid: 你的用户 id

打赏

在 themes/yelee/layout/_partial/目录下新建 donate.ejs 文件,其中内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<div class ="post-donate">
<div id="donate_board" class="donate_bar center">
<a id="btn_donate" class="btn_donate" href="javascript:;" title="打赏"></a>
<span class="donate_txt">
↑<br>
<%=theme.donate_message%>
</span>
<br>
</div>
<div id="donate_guide" class="donate_bar center hidden" >
<!-- 支付宝打赏图案 -->
<img src="<%= theme.Alipay %>" alt="支付宝打赏">
<!-- 微信打赏图案 -->
<img src="<%= theme.weixin %>" alt="微信打赏">
</div>
<script type="text/javascript">
document.getElementById('btn_donate').onclick = function(){
$('#donate_board').addClass('hidden');
$('#donate_guide').removeClass('hidden');
}
</script>
</div>

<!-- 在手机端不显示 -->
<script type="text/javascript">
$(function(){
//判断屏幕宽度
let widith = $(window).width();
if (widith <= 800) {
$('.post-donate').hide();
}
});
</script>

注:打赏的图案直接存在 themes/yelee/source/assets/ 下,没有 assets 文件创建一个

设置打赏模块的样式
在 themes/yelee/source/css/_partial/目录下新建 donate.styl 文件,其中内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
.donate_bar {
text-align: center;
margin-top: 5%
}

.donate_bar a.btn_donate {
display: inline-block;
width: 82px;
height: 82px;
margin-left: auto;
margin-right: auto;
background: url(http://img.t.sinajs.cn/t5/style/images/apps_PRF/e_media/btn_reward.gif)no-repeat;
-webkit-transition: background 0s;
-moz-transition: background 0s;
-o-transition: background 0s;
-ms-transition: background 0s;
transition: background 0s
}

.donate_bar a.btn_donate:hover {
background-position: 0 -82px
}

.donate_bar .donate_txt {
display: block;
color: #9d9d9d;
font: 14px/2 "Microsoft Yahei"
}
.donate_bar.hidden{
display: none
}

.post-donate{
margin-top: 80px;
}

#donate_guide{
height: 210px;
width: 420px;
margin: 0 auto;
}

#donate_guide img{
height: 200px;
height: 200px;
}

在 themes/yelee/source/css/style.styl 中前面部分添加

@import “_partial/donate”

在 themes/yelee/layout/_partial/article.ejs 中的标签后面添加如下内容:

1
2
3
4
5
<% if (page.prev || page.next){ %>
<% if (!index && theme.donate){ %>
<%- partial('donate') %>
<% } %>
<% } %>

在这里插入图片描述
在 themes/yelee/_config.yml 文件中添加如下内容:

1
2
3
4
5
6
Alipay: /assets/Alipay.png # 你的图片
weixin: /assets/weixin.png #你的图片
# 是否开启打赏功能
donate: true
# 打赏文案
donate_message: 此文对你有帮助?求支持!1分也是爱~ 谢谢!

在这里插入图片描述

给主页设置图片

在 themes/yelee/layout/_partial/目录下新建 homeImgUrl.ejs 文件,其中内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<style>
#homeImgUrl{
width: 100%;
height: 460px;
background-image: url('<%- theme.homeImg.url %>');
background-size: cover;
/* background-attachment:fixed; */
}

</style>

<div id="homeImgUrl">

</div>
<!-- <img class="im" src="<%= theme.homeImgUrl %>" alt="图片" style="width: 100%; height: 460px"> -->

在 themes/yelee/layout/_partial/article.ejs 中的最顶部加入:

1
2
3
4
5
<% if (page.prev || page.next){ %>
<% if (index && theme.homeImg.on){ %>
<%- partial('homeImgUrl') %>
<% } %>
<% } %>

在这里插入图片描述
在 themes/yelee/_config.yml 文件中添加如下内容: #主页图片

1
2
3
homeImg:
on: true
url: /assets/cover.jpg

注:自己下载图片放在 themes\yelee\source\assets 下

接入百度统计

百度统计网站
yelee 默认已经配置好百度统计了,只要一个 id 了
自己注册好账号
查看代码,填入 //hm.baidu.com/hm.js? 之后的内容
写在 themes\yelee_config.yml 中的 baidu_tongji
重启就好了

文章目录
  1. 1. 接入评论
  2. 2. 打赏
  3. 3. 给主页设置图片
  4. 4. 接入百度统计