« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateTrackChronologyLinks.js75
-rw-r--r--src/content/dependencies/generateTrackInfoPage.js70
2 files changed, 80 insertions, 65 deletions
diff --git a/src/content/dependencies/generateTrackChronologyLinks.js b/src/content/dependencies/generateTrackChronologyLinks.js
new file mode 100644
index 00000000..814e9a6a
--- /dev/null
+++ b/src/content/dependencies/generateTrackChronologyLinks.js
@@ -0,0 +1,75 @@
+import {sortAlbumsTracksChronologically} from '#sort';
+
+import getChronologyRelations from '../util/getChronologyRelations.js';
+
+export default {
+  contentDependencies: [
+    'generateChronologyLinks',
+    'linkArtist',
+    'linkTrack',
+  ],
+
+  relations: (relation, track) => ({
+    chronologyLinks:
+      relation('generateChronologyLinks'),
+
+    artistChronologyContributions:
+      getChronologyRelations(track, {
+        contributions: [
+          ...track.artistContribs ?? [],
+          ...track.contributorContribs ?? [],
+        ],
+
+        linkArtist: artist => relation('linkArtist', artist),
+        linkThing: track => relation('linkTrack', track),
+
+        getThings(artist) {
+          const getDate = thing => thing.date;
+
+          const things = [
+            ...artist.tracksAsArtist,
+            ...artist.tracksAsContributor,
+          ].filter(getDate);
+
+          return sortAlbumsTracksChronologically(things, {getDate});
+        },
+      }),
+
+    coverArtistChronologyContributions:
+      getChronologyRelations(track, {
+        contributions: track.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.albumsAsCoverArtist,
+            ...artist.tracksAsCoverArtist,
+          ].filter(getDate);
+
+          return sortAlbumsTracksChronologically(things, {getDate});
+        },
+      }),
+  }),
+
+  generate: (relations) =>
+    relations.chronologyLinks.slots({
+      chronologyInfoSets: [
+        {
+          headingString: 'misc.chronology.heading.track',
+          contributions: relations.artistChronologyContributions,
+        },
+        {
+          headingString: 'misc.chronology.heading.coverArt',
+          contributions: relations.coverArtistChronologyContributions,
+        },
+      ],
+    }),
+};
diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js
index f5324519..ae4ca621 100644
--- a/src/content/dependencies/generateTrackInfoPage.js
+++ b/src/content/dependencies/generateTrackInfoPage.js
@@ -1,9 +1,6 @@
-import {sortAlbumsTracksChronologically, sortFlashesChronologically}
-  from '#sort';
+import {sortFlashesChronologically} from '#sort';
 import {empty, stitchArrays} from '#sugar';
 
-import getChronologyRelations from '../util/getChronologyRelations.js';
-
 export default {
   contentDependencies: [
     'generateAbsoluteDatetimestamp',
@@ -12,7 +9,6 @@ export default {
     'generateAlbumSecondaryNav',
     'generateAlbumSidebar',
     'generateAlbumStyleRules',
-    'generateChronologyLinks',
     'generateColorStyleAttribute',
     'generateCommentarySection',
     'generateContentHeading',
@@ -20,13 +16,13 @@ export default {
     'generatePageLayout',
     'generateRelativeDatetimestamp',
     'generateTrackAdditionalNamesBox',
+    'generateTrackChronologyLinks',
     'generateTrackCoverArtwork',
     'generateTrackList',
     'generateTrackListDividedByGroups',
     'generateTrackReleaseInfo',
     'generateTrackSocialEmbed',
     'linkAlbum',
-    'linkArtist',
     'linkFlash',
     'linkTrack',
     'transformContent',
@@ -55,51 +51,6 @@ export default {
     relations.socialEmbed =
       relation('generateTrackSocialEmbed', track);
 
-    relations.artistChronologyContributions =
-      getChronologyRelations(track, {
-        contributions: [
-          ...track.artistContribs ?? [],
-          ...track.contributorContribs ?? [],
-        ],
-
-        linkArtist: artist => relation('linkArtist', artist),
-        linkThing: track => relation('linkTrack', track),
-
-        getThings(artist) {
-          const getDate = thing => thing.date;
-
-          const things = [
-            ...artist.tracksAsArtist,
-            ...artist.tracksAsContributor,
-          ].filter(getDate);
-
-          return sortAlbumsTracksChronologically(things, {getDate});
-        },
-      });
-
-    relations.coverArtistChronologyContributions =
-      getChronologyRelations(track, {
-        contributions: track.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.albumsAsCoverArtist,
-            ...artist.tracksAsCoverArtist,
-          ].filter(getDate);
-
-          return sortAlbumsTracksChronologically(things, {getDate});
-        },
-      }),
-
     relations.albumLink =
       relation('linkAlbum', track.album);
 
@@ -109,8 +60,8 @@ export default {
     relations.albumNavAccent =
       relation('generateAlbumNavAccent', track.album, track);
 
-    relations.chronologyLinks =
-      relation('generateChronologyLinks');
+    relations.trackChronologyLinks =
+      relation('generateTrackChronologyLinks', track);
 
     relations.secondaryNav =
       relation('generateAlbumSecondaryNav', track.album);
@@ -580,18 +531,7 @@ export default {
           }),
 
         navContent:
-          relations.chronologyLinks.slots({
-            chronologyInfoSets: [
-              {
-                headingString: 'misc.chronology.heading.track',
-                contributions: relations.artistChronologyContributions,
-              },
-              {
-                headingString: 'misc.chronology.heading.coverArt',
-                contributions: relations.coverArtistChronologyContributions,
-              },
-            ],
-          }),
+          relations.trackChronologyLinks,
 
         secondaryNav:
           relations.secondaryNav