Hexo个性化设置(持续更新)

把文章置顶并添加置顶标志

首先更换依赖:

1
2
$ npm uninstall hexo-generator-index --save
$ npm install hexo-generator-index-pin-top --save

然后在需要置顶的文章的 Front-matter 中加上 top: true 即可。比如下面这篇文章:

1
2
3
4
5
title: 常见的内部排序算法
date: 2018/10/18 20:46:03
categories: 算法
tags:
top: true

最后添加置顶标志,打开:/blog/themes/next/layout/_macro 目录下的post.swig 文件,定位到 <div class="post-meta"> 标签下,插入如下代码:

1
2
3
4
5
{% if post.top %}
<i class="fa fa-thumb-tack"></i>
<font color=7D26CD>置顶</font>
<span class="post-meta-divider">|</span>
{% endif %}

把 sideBar 设置在左边

需要修改的文件有:

  • sidebar.styl
  • sidebar-toggle.styl
  • back-to-top.styl
  • motion.js

\themes\next\source\css\_common\components\sidebar\
修改如下:

1
2
3
4
5
.sidebar {
position: fixed;
left: 0;
top: 0;
bottom: 0;

\themes\next\source\css\_common\components\sidebar\
修改如下:

1
left: $b2t-position-right;

back-to-top.styl

\themes\next\source\css\_common\components\

1
left: $b2t-position-right;

motion.js

\themes\next\source\js\src\motion.js
利用搜索功能找到改文档中的 paddingRight 字段,将 paddingRight 改为 paddingLeft(共两处)。

调整首页文章间距

打开 \themes\next\source\css\_schemes\Mist\_posts-expanded.styl ,在最后一行添加

1
2
3
4
.posts-expand .post {
margin-top: 50px; //调整到自己合适的数值
margin-bottom: 00px; //调整到自己合适的数值
}