Skip to content

Commit a55912f

Browse files
author
reco_luan
committed
fix: add sticky article sort feature
1 parent ebacfe2 commit a55912f

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

example/docs/views/category2/2016/121501.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tags:
55
- tag3
66
categories:
77
- category2
8-
sticky: true
8+
sticky: 1
99
---
1010

1111
first page in category2

example/docs/views/category2/2017/092101.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ categories:
77
- category2
88
keys:
99
- '1232'
10+
sticky: 2
1011
---
1112

1213
second page in category2

mixins/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ export default {
1818
? !(home == true || title == undefined || date === undefined || publish === false)
1919
: !(home == true || title == undefined || publish === false)
2020
})
21+
this._sortstickyArr(stickyArr)
2122
return stickyArr.concat(posts)
2223
},
24+
_sortstickyArr (posts) {
25+
if (posts.length > 0) {
26+
posts.sort((a, b) => {
27+
return b.sticky - a.sticky
28+
})
29+
}
30+
},
2331
_sortPostData (posts) {
2432
posts.sort((a, b) => {
2533
return this._getTimeNum(b) - this._getTimeNum(a)

0 commit comments

Comments
 (0)