« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/content/dependencies/generateAlbumNavAccent.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/content/dependencies/generateAlbumNavAccent.js b/src/content/dependencies/generateAlbumNavAccent.js
index e5b3a23d..3adb01be 100644
--- a/src/content/dependencies/generateAlbumNavAccent.js
+++ b/src/content/dependencies/generateAlbumNavAccent.js
@@ -30,10 +30,6 @@ export default {
         ? atOffset(album.tracks, index, +1)
         : null);
 
-    query.albumHasAnyCommentary =
-      !!(album.commentary ||
-         album.tracks.some(t => t.commentary));
-
     return query;
   },
 
@@ -61,15 +57,17 @@ export default {
       relation('linkAlbumGallery', album),
 
     albumCommentaryLink:
-      (query.albumHasAnyCommentary
-        ? relation('linkAlbumCommentary', album)
-        : null),
+      relation('linkAlbumCommentary', album),
   }),
 
   data: (query, album, track) => ({
     hasMultipleTracks:
       album.tracks.length > 1,
 
+    commentaryPageIsStub:
+      !album.commentary &&
+      album.tracks.every(t => !t.commentary),
+
     galleryIsStub:
       album.tracks.every(t => !t.hasUniqueCoverArt),
 
@@ -106,10 +104,11 @@ export default {
         });
 
     const commentaryLink =
-      relations.albumCommentaryLink?.slots({
-        attributes: {class: slots.currentExtra === 'commentary' && 'current'},
-        content: language.$(albumNavCapsule, 'commentary'),
-      });
+      (!data.commentaryPageIsStub || slots.currentExtra === 'commentary') &&
+        relations.albumCommentaryLink.slots({
+          attributes: {class: slots.currentExtra === 'commentary' && 'current'},
+          content: language.$(albumNavCapsule, 'commentary'),
+        });
 
     const randomLink =
       data.hasMultipleTracks &&