« 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/generateAlbumNavLinks.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateAlbumNavLinks.js')
-rw-r--r--src/content/dependencies/generateAlbumNavLinks.js59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/content/dependencies/generateAlbumNavLinks.js b/src/content/dependencies/generateAlbumNavLinks.js
index d9645319..4ce94e1c 100644
--- a/src/content/dependencies/generateAlbumNavLinks.js
+++ b/src/content/dependencies/generateAlbumNavLinks.js
@@ -2,6 +2,7 @@ import {empty} from '../../util/sugar.js';
 
 export default {
   contentDependencies: [
+    'generatePreviousNextLinks',
     'linkTrack',
     'linkAlbumCommentary',
     'linkAlbumGallery',
@@ -12,6 +13,12 @@ export default {
   relations(relation, album, track) {
     const relations = {};
 
+    relations.previousNextLinks =
+      relation('generatePreviousNextLinks');
+
+    relations.previousTrackLink = null;
+    relations.nextTrackLink = null;
+
     if (track) {
       const index = album.tracks.indexOf(track);
 
@@ -60,36 +67,28 @@ export default {
       },
 
       content(slots) {
-        const extraLinks =
-          (slots.showExtraLinks
-            ? [
-                relations.albumGalleryLink.slots({
-                  attributes: {class: slots.currentExtra === 'gallery' && 'current'},
-                  content: language.$('albumPage.nav.gallery'),
-                }),
-
-                relations.albumCommentaryLink.slots({
-                  attributes: {class: slots.currentExtra === 'commentary' && 'current'},
-                  content: language.$('albumPage.nav.commentary'),
-                }),
-              ]
-            : []);
-
-        const previousNextLinks =
-          (slots.showTrackNavigation
-            ? [
-                relations.previousTrackLink?.slots({
-                  tooltip: true,
-                  attributes: {id: 'previous-button'},
-                  content: language.$('misc.nav.previous'),
-                }),
-                relations.nextTrackLink?.slots({
-                  tooltip: true,
-                  attributes: {id: 'next-button'},
-                  content: language.$('misc.nav.next'),
-                }),
-              ]
-            : []);
+        const {content: extraLinks = []} =
+          slots.showExtraLinks &&
+            {content: [
+              relations.albumGalleryLink.slots({
+                attributes: {class: slots.currentExtra === 'gallery' && 'current'},
+                content: language.$('albumPage.nav.gallery'),
+              }),
+
+              relations.albumCommentaryLink.slots({
+                attributes: {class: slots.currentExtra === 'commentary' && 'current'},
+                content: language.$('albumPage.nav.commentary'),
+              }),
+            ]};
+
+        const {content: previousNextLinks = []} =
+          slots.showTrackNavigation &&
+          data.isTrackPage &&
+          data.hasMultipleTracks &&
+            relations.previousNextLinks.slots({
+              previousLink: relations.previousTrackLink,
+              nextLink: relations.nextTrackLink,
+            });
 
         const randomLink =
           slots.showTrackNavigation &&