« get me outta code hell

content: generateAlbumSecondaryNav: group-disconnected series - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-11-02 23:07:55 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-11-02 23:07:55 -0300
commitbf0d82c405396471c0b606a7c4401b2109967ee6 (patch)
tree6e5771829521beb3a209e0c7abe0d57e3e3bd834 /src/content/dependencies
parent5513b87defed864da87509a3fa18fda063f4973f (diff)
content: generateAlbumSecondaryNav: group-disconnected series
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateAlbumSecondaryNav.js32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/content/dependencies/generateAlbumSecondaryNav.js b/src/content/dependencies/generateAlbumSecondaryNav.js
index ed43e51f..5a5ebbda 100644
--- a/src/content/dependencies/generateAlbumSecondaryNav.js
+++ b/src/content/dependencies/generateAlbumSecondaryNav.js
@@ -8,9 +8,15 @@ export default {
     'generateSecondaryNav',
   ],
 
-  extraDependencies: ['html'],
+  extraDependencies: ['html', 'wikiData'],
 
-  query(album) {
+  sprawl: ({groupData}) => ({
+    // TODO: Series aren't their own things, so we access them weirdly.
+    seriesData:
+      groupData.flatMap(group => group.serieses),
+  }),
+
+  query(sprawl, album) {
     const query = {};
 
     query.groups =
@@ -22,10 +28,16 @@ export default {
           group.serieses
             .filter(series => series.albums.includes(album)));
 
+    query.disconnectedSerieses =
+      sprawl.seriesData
+        .filter(series =>
+          series.albums.includes(album) &&
+          !query.groups.includes(series.group));
+
     return query;
   },
 
-  relations: (relation, query, album) => ({
+  relations: (relation, query, _sprawl, album) => ({
     secondaryNav:
       relation('generateSecondaryNav'),
 
@@ -49,6 +61,13 @@ export default {
             relation('generateAlbumSecondaryNavSeriesPart',
               series,
               album))),
+
+    disconnectedSeriesParts:
+      query.disconnectedSerieses
+        .map(series =>
+          relation('generateAlbumSecondaryNavSeriesPart',
+            series,
+            album)),
   }),
 
   slots: {
@@ -59,7 +78,7 @@ export default {
   },
 
   generate(relations, slots, {html}) {
-    const allParts =
+    const groupConnectedParts =
       stitchArrays({
         groupPart: relations.groupParts,
         seriesParts: relations.seriesParts,
@@ -77,6 +96,11 @@ export default {
           }
         });
 
+    const allParts = [
+      ...relations.disconnectedSeriesParts,
+      ...groupConnectedParts,
+    ];
+
     return relations.secondaryNav.slots({
       class: [
         'album-secondary-nav',