From ab89221a8e425a8485508aa8d9feda320c6ecc6f Mon Sep 17 00:00:00 2001 From: James Wilcock Date: Sat, 2 Jul 2022 13:08:17 -0700 Subject: [PATCH] remove accents from search input and search string (#810) --- content/_index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/_index.md b/content/_index.md index 5783cef..95d0241 100644 --- a/content/_index.md +++ b/content/_index.md @@ -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;