fix: improved search result sorting
This commit is contained in:
@@ -168,10 +168,22 @@ const generateSearchResults = () => {
|
||||
searchResults.value.push(item)
|
||||
})
|
||||
})
|
||||
//searchResults.value.sort((a, b) => b.score - a.score)
|
||||
sortResults()
|
||||
}
|
||||
}
|
||||
|
||||
const sortResults = () => {
|
||||
searchResults.value.sort((a, b) => {
|
||||
const dateA = new Date(
|
||||
a.published_on || a.start_date || a.creation || a.modified
|
||||
).getTime()
|
||||
const dateB = new Date(
|
||||
b.published_on || b.start_date || b.creation || b.modified
|
||||
).getTime()
|
||||
return dateB - dateA
|
||||
})
|
||||
}
|
||||
|
||||
const navigate = (result: any) => {
|
||||
if (result.doctype == 'LMS Course') {
|
||||
router.push({
|
||||
|
||||
Reference in New Issue
Block a user