Merge pull request #99 from vuepress-reco/feature/reco
fix: add sticky article sort feature
This commit is contained in:
commit
df4c63cd3e
@ -5,7 +5,7 @@ tags:
|
|||||||
- tag3
|
- tag3
|
||||||
categories:
|
categories:
|
||||||
- category2
|
- category2
|
||||||
sticky: true
|
sticky: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
first page in category2
|
first page in category2
|
@ -7,6 +7,7 @@ categories:
|
|||||||
- category2
|
- category2
|
||||||
keys:
|
keys:
|
||||||
- '1232'
|
- '1232'
|
||||||
|
sticky: 2
|
||||||
---
|
---
|
||||||
|
|
||||||
second page in category2
|
second page in category2
|
@ -18,8 +18,16 @@ export default {
|
|||||||
? !(home == true || title == undefined || date === undefined || publish === false)
|
? !(home == true || title == undefined || date === undefined || publish === false)
|
||||||
: !(home == true || title == undefined || publish === false)
|
: !(home == true || title == undefined || publish === false)
|
||||||
})
|
})
|
||||||
|
this._sortstickyArr(stickyArr)
|
||||||
return stickyArr.concat(posts)
|
return stickyArr.concat(posts)
|
||||||
},
|
},
|
||||||
|
_sortstickyArr (posts) {
|
||||||
|
if (posts.length > 0) {
|
||||||
|
posts.sort((a, b) => {
|
||||||
|
return b.sticky - a.sticky
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
_sortPostData (posts) {
|
_sortPostData (posts) {
|
||||||
posts.sort((a, b) => {
|
posts.sort((a, b) => {
|
||||||
return this._getTimeNum(b) - this._getTimeNum(a)
|
return this._getTimeNum(b) - this._getTimeNum(a)
|
||||||
|
Loading…
Reference in New Issue
Block a user