Skip to content

Commit

Permalink
fix(web): sort search results in descending order by date
Browse files Browse the repository at this point in the history
Ensure new posts appear first in search results by sorting them in descending order by date.
  • Loading branch information
Chilfish committed Jul 6, 2024
1 parent 7e1ceba commit 0bb605a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ export class IDB {
.map(t => searchToken.some(s => t.startsWith(s)) ? t : `'${t}`)
.join(' ')

return fuse.search(query).map(r => r.item.time).sort()
return fuse.search(query)
.map(r => r.item.time)
.sort((a, b) => b - a) // 新帖子在前
},
}
}
Expand Down

0 comments on commit 0bb605a

Please sign in to comment.