Fork me on GitHub

Hexo博客之文章置顶+置顶标签

目录

博文置顶

一种方法是手动对相关文件进行修改,具体可参考这篇文章

另一种方法就是,目前已经有修改后支持置顶的仓库,可以直接用以下命令安装。

1
2
$ npm uninstall hexo-generator-index --save
$ npm install hexo-generator-index-pin-top --save --registry=https://registry.npm.taobao.org

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

1
2
3
4
title: hexo+GitHub博客搭建实战
date: 2020-02-08 12:00:25
categories: 博客搭建系列
top: true

到目前为止,置顶功能已经可以实现了。所有相关博文到这边就结束了。

不过置顶的文章显示在最上面之后,如果没有明确的置顶标志,是不是感觉有点怪怪的呢?

设置置顶标志
打开:/blog/themes/next/layout/_macro 目录下的post.swig文件,定位到

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 %}

效果展示:

http://www.cicoding.cn/

相关文章

微信打赏

赞赏是不耍流氓的鼓励