Improve category filtering to be more precise
This commit is contained in:
parent
9e2e844e8f
commit
d3b6de4a4d
@ -41,7 +41,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
if (cat === 'all') {
|
if (cat === 'all') {
|
||||||
card.style.display = '';
|
card.style.display = '';
|
||||||
} else {
|
} 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';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<div class="card">
|
<div class="card" data-category="{{ .Params.category }}">
|
||||||
{{ with .Params.image }}
|
{{ with .Params.image }}
|
||||||
<img src="{{ . }}" alt="{{ $.Title }} cover">
|
<img src="{{ . }}" alt="{{ $.Title }} cover">
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user