« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js')
-rw-r--r--src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js b/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
index af5a923f..2892152e 100644
--- a/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
+++ b/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
@@ -18,23 +18,32 @@ export default {
   extraDependencies: ['html', 'language'],
 
   query(artist) {
-    const entries = [
-      ...artist.albumsAsCommentator.map(album => ({
-        thing: album,
-        entry: {
+    const processEntries = (things, details) =>
+      things.map(thing => ({
+        thing,
+        entry: details(thing),
+      }));
+
+    const albumEntries =
+      processEntries(
+        artist.albumsAsCommentator,
+        album => ({
           type: 'album',
           album,
-        },
-      })),
+        }));
 
-      ...artist.tracksAsCommentator.map(track => ({
-        thing: track,
-        entry: {
+    const trackEntries =
+      processEntries(
+        artist.tracksAsCommentator,
+        track => ({
           type: 'track',
           album: track.album,
           track,
-        },
-      })),
+        }));
+
+    const entries = [
+      ...albumEntries,
+      ...trackEntries,
     ];
 
     sortEntryThingPairs(entries, sortAlbumsTracksChronologically);