mirror of
https://github.com/LukeSmithxyz/based.cooking.git
synced 2024-11-27 07:55:43 +00:00
remove accents from search input and search string (#810)
This commit is contained in:
parent
44745037c4
commit
ab89221a8e
@ -28,7 +28,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
search.addEventListener("input", () => {
|
||||
// grab search input value
|
||||
const searchText = search.value.toLowerCase().trim();
|
||||
const searchText = search.value.toLowerCase().trim().normalize('NFD').replace(/\p{Diacritic}/gu, "");
|
||||
const searchTerms = searchText.split(" ");
|
||||
const hasFilter = searchText.length > 0;
|
||||
|
||||
@ -37,7 +37,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
// for each recipe hide all but matched
|
||||
recipes.forEach(recipe => {
|
||||
const searchString = `${recipe.textContent} ${recipe.dataset.tags}`.toLowerCase();
|
||||
const searchString = `${recipe.textContent} ${recipe.dataset.tags}`.toLowerCase().normalize('NFD').replace(/\p{Diacritic}/gu, "");
|
||||
const isMatch = searchTerms.every(term => searchString.includes(term));
|
||||
|
||||
recipe.hidden = !isMatch;
|
||||
|
Loading…
Reference in New Issue
Block a user