« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateAlbumChronologyLinks.js53
-rw-r--r--src/content/dependencies/generateAlbumInfoPage.js43
-rw-r--r--src/content/dependencies/generateTrackInfoPage.js4
3 files changed, 58 insertions, 42 deletions
diff --git a/src/content/dependencies/generateAlbumChronologyLinks.js b/src/content/dependencies/generateAlbumChronologyLinks.js
new file mode 100644
index 00000000..3dd7a18e
--- /dev/null
+++ b/src/content/dependencies/generateAlbumChronologyLinks.js
@@ -0,0 +1,53 @@
+import {sortAlbumsTracksChronologically} from '#sort';
+
+import getChronologyRelations from '../util/getChronologyRelations.js';
+
+export default {
+  contentDependencies: [
+    'generateChronologyLinks',
+    'linkAlbum',
+    'linkArtist',
+    'linkTrack',
+  ],
+
+  relations: (relation, album) => ({
+    chronologyLinks:
+      relation('generateChronologyLinks'),
+
+    coverArtistChronologyContributions:
+      getChronologyRelations(album, {
+        contributions: album.coverArtistContribs ?? [],
+
+        linkArtist: artist => relation('linkArtist', artist),
+
+        linkThing: trackOrAlbum =>
+          (trackOrAlbum.album
+            ? relation('linkTrack', trackOrAlbum)
+            : relation('linkAlbum', trackOrAlbum)),
+
+        getThings(artist) {
+          const getDate = thing => thing.coverArtDate ?? thing.date;
+
+          const things =
+            ([
+              artist.albumCoverArtistContributions,
+              artist.trackCoverArtistContributions,
+            ]).flat()
+              .map(({thing}) => thing)
+              .filter(getDate);
+
+          return sortAlbumsTracksChronologically(things, {getDate});
+        },
+      }),
+  }),
+
+  generate: (relations) =>
+    relations.chronologyLinks.slots({
+      chronologyInfoSets: [
+        {
+          headingString: 'misc.chronology.heading.coverArt',
+          contributions: relations.coverArtistChronologyContributions,
+        },
+      ],
+    }),
+}
diff --git a/src/content/dependencies/generateAlbumInfoPage.js b/src/content/dependencies/generateAlbumInfoPage.js
index 02854a16..1d0f6549 100644
--- a/src/content/dependencies/generateAlbumInfoPage.js
+++ b/src/content/dependencies/generateAlbumInfoPage.js
@@ -1,8 +1,5 @@
-import {sortAlbumsTracksChronologically} from '#sort';
 import {empty} from '#sugar';
 
-import getChronologyRelations from '../util/getChronologyRelations.js';
-
 export default {
   contentDependencies: [
     'generateAlbumAdditionalFilesList',
@@ -15,14 +12,13 @@ export default {
     'generateAlbumSocialEmbed',
     'generateAlbumStyleRules',
     'generateAlbumTrackList',
-    'generateChronologyLinks',
+    'generateAlbumChronologyLinks',
     'generateCommentarySection',
     'generateContentHeading',
     'generatePageLayout',
     'linkAlbum',
     'linkAlbumCommentary',
     'linkAlbumGallery',
-    'linkArtist',
     'linkTrack',
     'transformContent',
   ],
@@ -42,37 +38,11 @@ export default {
     relations.socialEmbed =
       relation('generateAlbumSocialEmbed', album);
 
-    relations.coverArtistChronologyContributions =
-      getChronologyRelations(album, {
-        contributions: album.coverArtistContribs ?? [],
-
-        linkArtist: artist => relation('linkArtist', artist),
-
-        linkThing: trackOrAlbum =>
-          (trackOrAlbum.album
-            ? relation('linkTrack', trackOrAlbum)
-            : relation('linkAlbum', trackOrAlbum)),
-
-        getThings(artist) {
-          const getDate = thing => thing.coverArtDate ?? thing.date;
-
-          const things =
-            ([
-              artist.albumCoverArtistContributions,
-              artist.trackCoverArtistContributions,
-            ]).flat()
-              .map(({thing}) => thing)
-              .filter(getDate);
-
-          return sortAlbumsTracksChronologically(things, {getDate});
-        },
-      });
-
     relations.albumNavAccent =
       relation('generateAlbumNavAccent', album, null);
 
     relations.chronologyLinks =
-      relation('generateChronologyLinks');
+      relation('generateAlbumChronologyLinks', album);
 
     relations.secondaryNav =
       relation('generateAlbumSecondaryNav', album);
@@ -249,14 +219,7 @@ export default {
         ],
 
         navContent:
-          relations.chronologyLinks.slots({
-            chronologyInfoSets: [
-              {
-                headingString: 'misc.chronology.heading.coverArt',
-                contributions: relations.coverArtistChronologyContributions,
-              },
-            ],
-          }),
+          relations.chronologyLinks,
 
         banner: relations.banner ?? null,
         bannerPosition: 'top',
diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js
index bffebe07..1cbbc8a8 100644
--- a/src/content/dependencies/generateTrackInfoPage.js
+++ b/src/content/dependencies/generateTrackInfoPage.js
@@ -49,7 +49,7 @@ export default {
     albumNavAccent:
       relation('generateAlbumNavAccent', track.album, track),
 
-    trackChronologyLinks:
+    chronologyLinks:
       relation('generateTrackChronologyLinks', track),
 
     secondaryNav:
@@ -369,7 +369,7 @@ export default {
         }),
 
       navContent:
-        relations.trackChronologyLinks,
+        relations.chronologyLinks,
 
       secondaryNav:
         relations.secondaryNav