0%

Hexo Next 設定文章置頂

1. 安裝必備套件

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

1-1. 使用方法

在 Post 的資訊的部分添加

1
top: true

看起來會像

1
2
3
4
5
6
7
8
9
10
11
12
---
title:
date:
updated:
categories:
- [公告]
tags:
- [公告]
author: Justin
comments: true
top: true
---

2. 修改主題風格 以 NEXT 8.0 為例

找到 \themes\next\layout\_macro\post.njk 尋找 post-meta-container 並添加程式碼如下

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

之後測試即可,如下圖

image-20200907111704846