Merge pull request #99 from vuepress-reco/feature/reco

fix: add sticky article sort feature
This commit is contained in:
reco_luan 2019-11-26 16:05:53 +08:00 committed by GitHub
commit df4c63cd3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -5,7 +5,7 @@ tags:
- tag3
categories:
- category2
sticky: true
sticky: 1
---
first page in category2

View File

@ -7,6 +7,7 @@ categories:
- category2
keys:
- '1232'
sticky: 2
---
second page in category2

View File

@ -18,8 +18,16 @@ export default {
? !(home == true || title == undefined || date === undefined || publish === false)
: !(home == true || title == undefined || publish === false)
})
this._sortstickyArr(stickyArr)
return stickyArr.concat(posts)
},
_sortstickyArr (posts) {
if (posts.length > 0) {
posts.sort((a, b) => {
return b.sticky - a.sticky
})
}
},
_sortPostData (posts) {
posts.sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)