Search multiple keywords as 'AND' instead of 'OR'
This commit is contained in:
parent
5749093818
commit
ef889cf928
@ -16,14 +16,19 @@ export const IconList = function () {
|
||||
const keywords = query.toLowerCase().split(' ').filter(word => (word))
|
||||
let filtered = [];
|
||||
for (const filename in iconData) {
|
||||
const matched = iconData[filename].filter(tag => {
|
||||
for (const keyword of keywords) {
|
||||
const matched = keywords.filter(keyword => {
|
||||
for (const tag of iconData[filename]) {
|
||||
if (tag.indexOf(keyword.toLowerCase()) != -1) return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
// const matched = iconData[filename].filter(tag => {
|
||||
// for (const keyword of keywords) {
|
||||
// if (tag.indexOf(keyword.toLowerCase()) != -1) return true
|
||||
// }
|
||||
// return false
|
||||
// })
|
||||
|
||||
if (matched.length) filtered.push(filename)
|
||||
if (matched.length == keywords.length) filtered.push(filename)
|
||||
}
|
||||
console.log(filtered)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user