mirror of
https://github.com/LukeSmithxyz/based.cooking.git
synced 2024-11-27 07:55:43 +00:00
add support for multiterm search
This commit is contained in:
parent
c194763386
commit
6519daeaef
@ -34,7 +34,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
let matchCount = 0;
|
||||
rec.forEach(el => {
|
||||
const recipeName = el.textContent.toLowerCase()
|
||||
const isMatch = recipeName.includes(searchText)
|
||||
const isMatch = searchText.split(' ').every(term => recipeName.includes(term))
|
||||
|
||||
el.hidden = !isMatch
|
||||
el.classList.toggle('matched-recipe', isMatch && searchText.length !== 0);
|
||||
|
Loading…
Reference in New Issue
Block a user