« get me outta code hell

content, external-links, test: provide album track count as context - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-02-14 13:07:09 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-02-14 13:44:36 -0400
commitd31c889df346b7579ce1afe0746fb4aa0ed8227d (patch)
tree8c98fb6c8d4c7d89e25968c99c0295aeac3880b5 /src/content
parent08114ae53a4053b45577860f0a127ee2e6b3e3a6 (diff)
content, external-links, test: provide album track count as context
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateAlbumReleaseInfo.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/content/dependencies/generateAlbumReleaseInfo.js b/src/content/dependencies/generateAlbumReleaseInfo.js
index cb3aaa75..5128fbac 100644
--- a/src/content/dependencies/generateAlbumReleaseInfo.js
+++ b/src/content/dependencies/generateAlbumReleaseInfo.js
@@ -46,6 +46,8 @@ export default {
     data.duration = accumulateSum(album.tracks, track => track.duration);
     data.durationApproximate = album.tracks.length > 1;
 
+    data.numTracks = album.tracks.length;
+
     return data;
   },
 
@@ -95,7 +97,14 @@ export default {
                 relations.externalLinks
                   .map(link =>
                     link.slots({
-                      context: 'album',
+                      context: [
+                        'album',
+                        (data.numTracks === 0
+                          ? 'albumNoTracks'
+                       : data.numTracks === 1
+                          ? 'albumOneTrack'
+                          : 'albumMultipleTracks'),
+                      ],
                       style: 'normal',
                     }))),
           })),