Filter artist names as well
All checks were successful
Build / build (push) Successful in 2m37s

This commit is contained in:
Emil Miler 2024-12-30 13:59:42 +01:00
parent 842b66def0
commit ff8d9c80e6
2 changed files with 11 additions and 2 deletions

View File

@ -23,7 +23,10 @@ function filterSongs() {
const searchTerm = sanitizeString(search.value);
const songs = Array.from(songList.children);
songs.forEach(song => {
const matching = song.dataset.title.includes(searchTerm) && (!selectedCategory || song.dataset.category === selectedCategory);
const matching = (
(song.dataset.title.includes(searchTerm) || (song.dataset.artist && song.dataset.artist.includes(searchTerm))) &&
(!selectedCategory || song.dataset.category === selectedCategory)
);
song.classList.toggle("hidden", !matching);
});
}

View File

@ -21,7 +21,13 @@
</section>
<section class="song-list">
{% for song in section.pages %}
<div class="{{ macros::primary_category(song=song) }}" data-title="{{ song.title }}" data-category="{{ macros::primary_category(song=song) }}">
<div class="{{ macros::primary_category(song=song) }}"
data-title="{{ song.title }}"
data-category="{{ macros::primary_category(song=song) }}"
{% if song.taxonomies["artist"] %}
data-artist="{{ song.taxonomies["artist"][0] }}"
{% endif %}
>
<div class="meta">
<div class="title">{{ song.title }}</div>
{% if song.taxonomies["artist"] %}