Hexo安装NexT主题

参考:

hexo的next主题个性化配置 - 知乎 (zhihu.com)

Hexo+Next主题的一些实用插件和美化升级_next 单行代码 美观优化_小王同学w的博客-CSDN博客

1.配置修改

(1)取消目录章节自动编号

修改配置文件 ./themes/next/_config.yml

1
2
3
4
5
6
toc:
enable: true
number: true # 改为false
wrap: false
expand_all: false
max_depth: 6

(2)网站图标

修改配置文件 ./themes/next/_config.yml

1
2
3
4
5
favicon:
small: /images/favicon-16x16-next.png # 浏览器标签处显示图标
medium: /images/favicon-32x32-next.png # 收藏时网页图标
 apple_touch_icon: /images/apple-touch-icon-next.png
 safari_pinned_tab: /images/logo.svg

favicon-nxn-next.png 均位于 ./themes/next/source/images目录

(3)代码块复制功能

修改配置文件 ./themes/next/_config.yml

1
2
3
4
5
6
7
codeblock:
...
# Add copy button on codeblock
copy_button:
enable: false # 改为true
# Available values: default | flat | mac
style:

(4)侧边栏社交链

修改配置文件 ./themes/next/_config.yml

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
social:
GitHub: https://github.com/WilsonGoGo || fab fa-github
E-Mail: mailto:[email protected] || fa fa-envelope
#Weibo: https://weibo.com/yourname || fab fa-weibo
#Google: https://plus.google.com/yourname || fab fa-google
#Twitter: https://twitter.com/yourname || fab fa-twitter
#FB Page: https://www.facebook.com/yourname || fab fa-facebook
#StackOverflow: https://stackoverflow.com/yourname || fab fa-stack-overflow
#YouTube: https://youtube.com/yourname || fab fa-youtube
#Instagram: https://instagram.com/yourname || fab fa-instagram
#Skype: skype:yourname?call|chat || fab fa-skype

social_icons:
enable: true
icons_only: false
transition: false
#图标
GitHub: github
E-Mail: envelope


#设置侧边栏社交链
social:
GitHub: https://github.com/zzwwqq || github
E-Mail: mailto:[email protected] || envelope
Weibo: https://weibo.com/u/5564810309/home?wvr=5 || weibo
知乎: https://www.zhihu.com/people/shen-qiu-wu-hen-66/activities || snapchat

#这里键的值必须和上面social中的 "||" 后面指定的名称一致,在fontawesome官网找喜欢的小图标,将名字复制在如下位置,如E-Mail:对应的图标名称为envelope。

social_icons:
enable: true # `enable` 选项用于控制是否显示图标
icons_only: false
transition: false
#图标
GitHub: github
E-Mail: envelope
Weibo: weibo
知乎: snapchat

(4)站点浏览次数(未生效,插件未安装)

修改主题配置文件 ./themes/next/_config.yml

1
2
3
4
5
6
7
8
9
10
# Show Views / Visitors of the website / page with busuanzi.
# For more information: http://ibruce.info/2015/04/04/busuanzi/
busuanzi_count:
enable: false # 改为true
total_visitors: true
total_visitors_icon: fa fa-user
total_views: true
total_views_icon: fa fa-eye
post_views: true
post_views_icon: far fa-eye

注:该模块具体html代码设置已在./themes/next/layout/_partials/footer.njk文件中,但是可以通过主题配置文件中配置开选择是否启用相关代码

(5)评论系统+文章阅读次数(未实现,需要leancloud账号)

2.布局修改

(1)Fork me on github标签

在./themes/next/layout/_layout.njk文件中进行配置

1
2
3
4
5
6
7
<body itemscope itemtype="http://schema.org/WebPage"{% if theme.motion.enable %} class="use-motion"{% endif %}>
<div class="headband"></div>

<!-- 需要插入的代码 -->
<a href="https://github.com/WilsonGoGo" ... > <!-- href后为github的地址 -->

...

需要插入的该行代码可由以下网址生成

GitHub Ribbons | The GitHub Blog

GitHub Corners (tholman.com)

(2)站点运行时长

在 ./themes/next/layout/_partials/footer.njk文件底部添加下面的代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!-- 添加显示本站已安全运行时长功能 -->
<div>
<span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span>
<script>
var now = new Date();
function createtime() {
var start_time_string = '2022-09-14 14:43:26'; //此处修改你的建站时间或者网站上线时间
var grt = new Date(start_time_string.replace(/-/g, "/"));
now.setTime(now.getTime()+1000);
days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days);
hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours);
if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;}
seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;}
document.getElementById("timeDate").innerHTML = "本站已安全运行 "+dnum+" 天 ";
document.getElementById("times").innerHTML = hnum + " 小时 " + mnum + " 分 " + snum + " 秒";
}
setInterval("createtime()",1000); // 刷新时间
</script>
</div>

3.网站特效

(1)鼠标点击特效(未实现)

(2)博客宠物(未实现)

(3)作者头像动画(未实现)

打开.\themes\next\source\css\_common\components\sidebar\sidebar-author.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
.site-author-image {
display: block;
margin: 0 auto;
padding: $site-author-image-padding;
max-width: $site-author-image-width;
height: $site-author-image-height;
border: $site-author-image-border-width solid $site-author-image-border-color;

/* 头像圆形 */
border-radius: 80px;
-webkit-border-radius: 80px;
-moz-border-radius: 80px;
box-shadow: inset 0 -1px 0 #333sf;

/* 设置循环动画 */
/* [animation: (play)动画名称 (2s)动画播放时长单位秒或微秒 (ase-out)动画播放的速度曲线为以低速结束(1s)等待1秒然后开始动画 (1)动画播放次数(infinite为循环播放) ] */


/* 鼠标经过头像旋转360度 */
-webkit-transition: -webkit-transform 1.0s ease-out;
-moz-transition: -moz-transform 1.0s ease-out;
transition: transform 1.0s ease-out;
}

img:hover {
/* 鼠标经过停止头像旋转
-webkit-animation-play-state:paused;
animation-play-state:paused;*/

/* 鼠标经过头像旋转360度 */
-webkit-transform: rotateZ(360deg);
-moz-transform: rotateZ(360deg);
transform: rotateZ(360deg);
}

/* Z 轴旋转动画 */
@-webkit-keyframes play {
0% {
-webkit-transform: rotateZ(0deg);
}
100% {
-webkit-transform: rotateZ(-360deg);
}
}
@-moz-keyframes play {
0% {
-moz-transform: rotateZ(0deg);
}
100% {
-moz-transform: rotateZ(-360deg);
}
}
@keyframes play {
0% {
transform: rotateZ(0deg);
}
100% {
transform: rotateZ(-360deg);
}
}

(4)背景动画(未实现)