« get me outta code hell

content: generateAlbumChronologyLinks - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-06-12 14:50:11 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-12 17:32:58 -0300
commita7260373aea3ad95ba21e6aba979db0f53e2fe3f (patch)
tree127def116198b87ef314af47bddba4965a6b3c61 /src/content
parent31429e48f7f4ce41556dee91165d0729791652e8 (diff)
content: generateAlbumChronologyLinks
Diffstat (limited to 'src/content')
-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