File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -603,9 +603,15 @@ export default {
603603 search (query , tree ) {
604604 return Object .values (tree .index .bookmark )
605605 .filter (item => {
606- const matchTitle = item .title ? query .split (' ' ).every (term => item .title .toLowerCase ().split (' ' ).some (word => word === term)) : false
606+ const matchTitleFully = item .title ? query .split (' ' ).every (term => item .title .toLowerCase ().split (' ' ).some (word => word === term)) : false
607+ const matchTitlePartially = item .title ? query .split (' ' ).every (term => item .title .toLowerCase ().includes (term)) : false
607608 const matchUrl = query .split (' ' ).every (term => item .url .toLowerCase ().includes (term))
608- return matchUrl || matchTitle
609+ return matchUrl || matchTitleFully || matchTitlePartially
610+ })
611+ .sort ((a , b ) => {
612+ const matchTitlePartiallyA = a .title ? query .split (' ' ).every (term => a .title .toLowerCase ().includes (term)) : false
613+ const matchTitlePartiallyB = b .title ? query .split (' ' ).every (term => b .title .toLowerCase ().includes (term)) : false
614+ return matchTitlePartiallyA ? (matchTitlePartiallyB ? 0 : - 1 ) : 1
609615 })
610616 .sort ((a , b ) => {
611617 const matchTitleA = a .title ? query .split (' ' ).every (term => a .title .toLowerCase ().split (' ' ).some (word => word === term)) : false
You can’t perform that action at this time.
0 commit comments