From 4f17b3d9015ca4292086e21ff028ef457cdc71f6 Mon Sep 17 00:00:00 2001 From: dosisod <39638017+dosisod@users.noreply.github.com> Date: Fri, 1 Jul 2022 19:15:30 -0700 Subject: [PATCH] Replace "style=display:none" with HTML data tags: When storing metadata in an HTML node, you can use data attributes, which is more declarative, and doesn't require rendering an invisible node. See: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes --- content/_index.md | 4 ++-- layouts/shortcodes/artlist.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/_index.md b/content/_index.md index 1b3cd09..107959c 100644 --- a/content/_index.md +++ b/content/_index.md @@ -35,8 +35,8 @@ document.addEventListener("DOMContentLoaded", () => { // for each recipe hide all but matched recipes.forEach(recipe => { - const recipeName = recipe.textContent.toLowerCase(); - const isMatch = searchTerms.every(term => recipeName.includes(term)); + const searchString = `${recipe.textContent} ${recipe.dataset.tags}`.toLowerCase(); + const isMatch = searchTerms.every(term => searchString.includes(term)); recipe.hidden = !isMatch; recipe.classList.toggle("matched-recipe", hasFilter && isMatch); diff --git a/layouts/shortcodes/artlist.html b/layouts/shortcodes/artlist.html index fa7a62e..d1e3206 100644 --- a/layouts/shortcodes/artlist.html +++ b/layouts/shortcodes/artlist.html @@ -1,5 +1,5 @@