« 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/generateAlbumSecondaryNav.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateAlbumSecondaryNav.js')
-rw-r--r--src/content/dependencies/generateAlbumSecondaryNav.js41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/content/dependencies/generateAlbumSecondaryNav.js b/src/content/dependencies/generateAlbumSecondaryNav.js
index 4a3d18be..a5dc0ba8 100644
--- a/src/content/dependencies/generateAlbumSecondaryNav.js
+++ b/src/content/dependencies/generateAlbumSecondaryNav.js
@@ -1,21 +1,47 @@
+import {stitchArrays} from '#sugar';
+
 export default {
   contentDependencies: [
     'generateAlbumSecondaryNavGroupPart',
+    'generateAlbumSecondaryNavSeriesPart',
     'generateSecondaryNav',
   ],
 
   extraDependencies: ['html'],
 
-  relations: (relation, album) => ({
+  query(album) {
+    const query = {};
+
+    query.groups =
+      album.groups;
+
+    query.groupSerieses =
+      query.groups
+        .map(group =>
+          group.serieses
+            .filter(series => series.albums.includes(album)));
+
+    return query;
+  },
+
+  relations: (relation, query, album) => ({
     secondaryNav:
       relation('generateSecondaryNav'),
 
     groupParts:
-      album.groups
+      query.groups
         .map(group =>
           relation('generateAlbumSecondaryNavGroupPart',
             group,
             album)),
+
+    seriesParts:
+      query.groupSerieses
+        .map(serieses => serieses
+          .map(series =>
+            relation('generateAlbumSecondaryNavSeriesPart',
+              series,
+              album))),
   }),
 
   slots: {
@@ -29,7 +55,14 @@ export default {
     relations.secondaryNav.slots({
       class: 'nav-links-groups',
       content:
-        relations.groupParts
-          .map(part => part.slot('mode', slots.mode)),
+        stitchArrays({
+          groupPart: relations.groupParts,
+          seriesParts: relations.seriesParts,
+        }).map(({groupPart, seriesParts}) => [
+            groupPart.slot('mode', slots.mode),
+
+            seriesParts
+              .map(part => part.slot('mode', slots.mode)),
+          ]),
     }),
 };