Improve category filtering to be more precise

This commit is contained in:
Greg 2025-05-25 17:43:06 +02:00
parent 9e2e844e8f
commit d3b6de4a4d
2 changed files with 4 additions and 2 deletions

View File

@ -41,7 +41,9 @@ document.addEventListener('DOMContentLoaded', function() {
if (cat === 'all') {
card.style.display = '';
} else {
card.style.display = card.innerHTML.includes(`category=\"${cat}\"`) ? '' : 'none';
// Add a data-category attribute to make filtering more reliable
const category = card.getAttribute('data-category');
card.style.display = (category === cat) ? '' : 'none';
}
});
});

View File

@ -1,4 +1,4 @@
<div class="card">
<div class="card" data-category="{{ .Params.category }}">
{{ with .Params.image }}
<img src="{{ . }}" alt="{{ $.Title }} cover">
{{ else }}