remove shys from Search

This commit is contained in:
Alexander Bocken 2024-01-10 10:55:59 +01:00
parent c616c9d798
commit 95ae0f814c
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

View File

@ -2,7 +2,6 @@
import {onMount} from "svelte"; import {onMount} from "svelte";
import "$lib/css/nordtheme.css"; import "$lib/css/nordtheme.css";
onMount(() => { onMount(() => {
const recipes = document.querySelectorAll(".search_me"); const recipes = document.querySelectorAll(".search_me");
const search = document.getElementById("search"); const search = document.getElementById("search");
@ -18,7 +17,7 @@ onMount(() => {
let scrollers = []; let scrollers = [];
// for each recipe hide all but matched // for each recipe hide all but matched
recipes.forEach(recipe => { recipes.forEach(recipe => {
const searchString = `${recipe.textContent} ${recipe.dataset.tags}`.toLowerCase().normalize('NFD').replace(/\p{Diacritic}/gu, ""); const searchString = `${recipe.textContent} ${recipe.dataset.tags}`.toLowerCase().normalize('NFD').replace(/\p{Diacritic}/gu, "").replace(/­|­/g, '');
const isMatch = searchTerms.every(term => searchString.includes(term)); const isMatch = searchTerms.every(term => searchString.includes(term));
recipe.style.display = (isMatch ? 'flex' : 'none'); recipe.style.display = (isMatch ? 'flex' : 'none');