virtual sample : add dynamic comments count attribute on track buttons

This commit is contained in:
isUnknown 2025-02-11 17:49:34 +01:00
parent 7153da14eb
commit db7b6171f7

View file

@ -9,6 +9,7 @@
:aria-controls="track.slug"
:style="`--btn-image: url(${getFrontViewUrl(track)});`"
@click="selectTrack(track)"
:data-comments="getCommentsCount(track)"
>
<span>{{ track.title }}</span>
</button>
@ -136,6 +137,14 @@ function removeTrack(track) {
(activeTrack) => activeTrack.title !== track.title
);
}
function getCommentsCount(track) {
let count = 0;
for (const file of track.files) {
count += file?.comments?.length || 0;
}
return count > 0 ? count : undefined;
}
</script>
<style>