« get me outta code hell

content: generateAlbumSidebarTrackSection: be mildly more versatile - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateAlbumSidebarTrackSection.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-06 20:17:22 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-06 08:26:55 -0300
commit93bb97d18bfd016f74e3c9facbc7a2c33aab3bbe (patch)
tree672e4176a2306b6644f3d00dd9884b207ba13fcf /src/content/dependencies/generateAlbumSidebarTrackSection.js
parent461f651847270898d568c4d1666158389076db82 (diff)
content: generateAlbumSidebarTrackSection: be mildly more versatile
Diffstat (limited to 'src/content/dependencies/generateAlbumSidebarTrackSection.js')
-rw-r--r--src/content/dependencies/generateAlbumSidebarTrackSection.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/content/dependencies/generateAlbumSidebarTrackSection.js b/src/content/dependencies/generateAlbumSidebarTrackSection.js
index d71b0bdb..e8c0377d 100644
--- a/src/content/dependencies/generateAlbumSidebarTrackSection.js
+++ b/src/content/dependencies/generateAlbumSidebarTrackSection.js
@@ -33,10 +33,19 @@ export default {
       }
     }
 
+    data.trackDirectories =
+      trackSection.tracks
+        .map(track => track.directory);
+
     return data;
   },
 
-  generate(data, relations, {getColors, html, language}) {
+  slots: {
+    anchor: {type: 'boolean'},
+    open: {type: 'boolean'},
+  },
+
+  generate(slots, data, relations, {getColors, html, language}) {
     const sectionName =
       html.tag('span', {class: 'group-name'},
         (data.isDefaultTrackSection
@@ -59,7 +68,13 @@ export default {
               'current',
           },
           language.$('albumSidebar.trackList.item', {
-            track: trackLink,
+            track:
+              (slots.anchor
+                ? trackLink.slots({
+                    anchor: true,
+                    hash: data.trackDirectories[index],
+                  })
+                : trackLink),
           })));
 
     return html.tag('details',
@@ -67,6 +82,11 @@ export default {
         class: data.includesCurrentTrack && 'current',
 
         open: (
+          // Allow forcing open via a template slot.
+          // This isn't exactly janky, but the rest of this function
+          // kind of is when you contextualize it in a template...
+          slots.open ||
+
           // Leave sidebar track sections collapsed on album info page,
           // since there's already a view of the full track listing
           // in the main content area.