« get me outta code hell

content: generateAlbumSidebarGroupBox: isAlbumPage -> mode - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-14 12:51:51 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-14 12:51:51 -0300
commit4fd479469d0b6463e5dd51ce62c227482aa813c6 (patch)
tree00dd7204e9ff373f1b0e3f87eb9c4fbd466a9a4c
parent13c449ccbee3b8cf87ffd8ab546565d5b2f970b7 (diff)
content: generateAlbumSidebarGroupBox: isAlbumPage -> mode
-rw-r--r--src/content/dependencies/generateAlbumSidebar.js5
-rw-r--r--src/content/dependencies/generateAlbumSidebarGroupBox.js11
2 files changed, 9 insertions, 7 deletions
diff --git a/src/content/dependencies/generateAlbumSidebar.js b/src/content/dependencies/generateAlbumSidebar.js
index bf6b091a..a84f4357 100644
--- a/src/content/dependencies/generateAlbumSidebar.js
+++ b/src/content/dependencies/generateAlbumSidebar.js
@@ -7,7 +7,6 @@ export default {
 
   extraDependencies: ['html'],
 
-
   relations(relation, album, track) {
     const relations = {};
 
@@ -41,7 +40,7 @@ export default {
     if (data.isAlbumPage) {
       const groupBoxes =
         relations.groupBoxes
-          .map(content => content.slot('isAlbumPage', true))
+          .map(content => content.slot('mode', 'album'))
           .map(content => ({content}));
 
       return {
@@ -56,7 +55,7 @@ export default {
       content:
         relations.groupBoxes
           .flatMap((content, i, {length}) => [
-            content,
+            content.slot('mode', 'track'),
             i < length - 1 &&
               html.tag('hr', {
                 style: `border-color: var(--primary-color); border-style: none none dotted none`
diff --git a/src/content/dependencies/generateAlbumSidebarGroupBox.js b/src/content/dependencies/generateAlbumSidebarGroupBox.js
index e124acd9..874dcc20 100644
--- a/src/content/dependencies/generateAlbumSidebarGroupBox.js
+++ b/src/content/dependencies/generateAlbumSidebarGroupBox.js
@@ -46,7 +46,10 @@ export default {
   },
 
   slots: {
-    isAlbumPage: {type: 'boolean', default: false},
+    mode: {
+      validate: v => v.is('album', 'track'),
+      default: 'track',
+    },
   },
 
   generate(relations, slots, {html, language}) {
@@ -56,7 +59,7 @@ export default {
           group: relations.groupLink,
         })),
 
-      slots.isAlbumPage &&
+      slots.mode === 'album' &&
         relations.description
           ?.slot('mode', 'multiline'),
 
@@ -66,14 +69,14 @@ export default {
             links: language.formatDisjunctionList(relations.externalLinks),
           })),
 
-      slots.isAlbumPage &&
+      slots.mode === 'album' &&
       relations.nextAlbumLink &&
         html.tag('p', {class: 'group-chronology-link'},
           language.$('albumSidebar.groupBox.next', {
             album: relations.nextAlbumLink,
           })),
 
-      slots.isAlbumPage &&
+      slots.mode === 'album' &&
       relations.previousAlbumLink &&
         html.tag('p', {class: 'group-chronology-link'},
           language.$('albumSidebar.groupBox.previous', {