From 7c6ba261f856babbce20c2617c9421e66c3dc38f Mon Sep 17 00:00:00 2001 From: Jakob Moser Date: Thu, 13 Nov 2025 19:47:51 +0100 Subject: [PATCH] Add SongList --- karaokatalog/ui/static/components/pieces/SongList.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 karaokatalog/ui/static/components/pieces/SongList.js diff --git a/karaokatalog/ui/static/components/pieces/SongList.js b/karaokatalog/ui/static/components/pieces/SongList.js new file mode 100644 index 0000000..5cab73d --- /dev/null +++ b/karaokatalog/ui/static/components/pieces/SongList.js @@ -0,0 +1,11 @@ +import Artist from "./Artist.js" +import Pagination from "./Pagination.js" + +export default { + view: function (vnode) { + const sortedSongs = vnode.attrs.songs.toSorted((a, b) => a.artist.localeCompare(b.artist) || a.title.localeCompare(b.title)) + const songsByArtist = Map.groupBy(sortedSongs, song => song.artist) + + return m(Pagination, { elements: songsByArtist.entries().map(([artist, songs]) => m(Artist, { artist, songs })) }) + }, +}