« 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/generateAlbumNavAccent.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateAlbumNavAccent.js')
-rw-r--r--src/content/dependencies/generateAlbumNavAccent.js120
1 files changed, 57 insertions, 63 deletions
diff --git a/src/content/dependencies/generateAlbumNavAccent.js b/src/content/dependencies/generateAlbumNavAccent.js
index 9d1d87c3..0237fdec 100644
--- a/src/content/dependencies/generateAlbumNavAccent.js
+++ b/src/content/dependencies/generateAlbumNavAccent.js
@@ -53,68 +53,62 @@ export default {
     };
   },
 
-  generate(data, relations, {html, language}) {
-    return html.template({
-      annotation: `generateAlbumNavAccent`,
-
-      slots: {
-        showTrackNavigation: {type: 'boolean', default: false},
-        showExtraLinks: {type: 'boolean', default: false},
-
-        currentExtra: {
-          validate: v => v.is('gallery', 'commentary'),
-        },
-      },
-
-      content(slots) {
-        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 &&
-          data.hasMultipleTracks &&
-            html.tag('a',
-              {
-                href: '#',
-                'data-random': 'track-in-album',
-                id: 'random-button',
-              },
-              (data.isTrackPage
-                ? language.$('trackPage.nav.random')
-                : language.$('albumPage.nav.randomTrack')));
-
-        const allLinks = [
-          ...previousNextLinks,
-          ...extraLinks,
-          randomLink,
-        ].filter(Boolean);
-
-        if (empty(allLinks)) {
-          return html.blank();
-        }
-
-        return `(${language.formatUnitList(allLinks)})`
-      },
-    });
+  slots: {
+    showTrackNavigation: {type: 'boolean', default: false},
+    showExtraLinks: {type: 'boolean', default: false},
+
+    currentExtra: {
+      validate: v => v.is('gallery', 'commentary'),
+    },
+  },
+
+  generate(data, relations, slots, {html, language}) {
+    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 &&
+      data.hasMultipleTracks &&
+        html.tag('a',
+          {
+            href: '#',
+            'data-random': 'track-in-album',
+            id: 'random-button',
+          },
+          (data.isTrackPage
+            ? language.$('trackPage.nav.random')
+            : language.$('albumPage.nav.randomTrack')));
+
+    const allLinks = [
+      ...previousNextLinks,
+      ...extraLinks,
+      randomLink,
+    ].filter(Boolean);
+
+    if (empty(allLinks)) {
+      return html.blank();
+    }
+
+    return `(${language.formatUnitList(allLinks)})`;
   },
 };