« 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/generateFlashInfoPage.js124
1 files changed, 45 insertions, 79 deletions
diff --git a/src/content/dependencies/generateFlashInfoPage.js b/src/content/dependencies/generateFlashInfoPage.js
index eec32157..d6066a95 100644
--- a/src/content/dependencies/generateFlashInfoPage.js
+++ b/src/content/dependencies/generateFlashInfoPage.js
@@ -32,85 +32,52 @@ export default {
     return query;
   },
 
-  relations(relation, query, flash) {
-    const relations = {};
-    const sections = relations.sections = {};
+  relations: (relation, query, flash) => ({
+    layout:
+      relation('generatePageLayout'),
 
-    relations.layout =
-      relation('generatePageLayout');
+    sidebar:
+      relation('generateFlashActSidebar', flash.act, flash),
 
-    relations.sidebar =
-      relation('generateFlashActSidebar', flash.act, flash);
-
-    relations.externalLinks =
+    externalLinks:
       query.urls
-        .map(url => relation('linkExternal', url));
-
-    // TODO: Flashes always have cover art (#175)
-    /* eslint-disable-next-line no-constant-condition */
-    if (true) {
-      relations.cover =
-        relation('generateFlashCoverArtwork', flash);
-    }
-
-    // Section: navigation bar
-
-    const nav = sections.nav = {};
-
-    nav.flashActLink =
-      relation('linkFlashAct', flash.act);
-
-    nav.flashNavAccent =
-      relation('generateFlashNavAccent', flash);
-
-    // Section: Featured tracks
-
-    if (!empty(flash.featuredTracks)) {
-      const featuredTracks = sections.featuredTracks = {};
+        .map(url => relation('linkExternal', url)),
 
-      featuredTracks.heading =
-        relation('generateContentHeading');
+    cover:
+      relation('generateFlashCoverArtwork', flash),
 
-      featuredTracks.list =
-        relation('generateTrackList', flash.featuredTracks);
-    }
+    contentHeading:
+      relation('generateContentHeading'),
 
-    // Section: Contributors
+    flashActLink:
+      relation('linkFlashAct', flash.act),
 
-    if (!empty(flash.contributorContribs)) {
-      const contributors = sections.contributors = {};
+    flashNavAccent:
+      relation('generateFlashNavAccent', flash),
 
-      contributors.heading =
-        relation('generateContentHeading');
+    featuredTracksList:
+      relation('generateTrackList', flash.featuredTracks),
 
-      contributors.list =
-        relation('generateContributionList', flash.contributorContribs);
-    }
+    contributorContributionList:
+      relation('generateContributionList', flash.contributorContribs),
 
-    // Section: Artist commentary
+    artistCommentarySection:
+      relation('generateCommentarySection', flash.commentary),
+  }),
 
-    if (flash.commentary) {
-      sections.artistCommentary =
-        relation('generateCommentarySection', flash.commentary);
-    }
-
-    return relations;
-  },
+  data: (_query, flash) => ({
+    name:
+      flash.name,
 
-  data(query, flash) {
-    const data = {};
+    color:
+      flash.color,
 
-    data.name = flash.name;
-    data.color = flash.color;
-    data.date = flash.date;
+    date:
+      flash.date,
+  }),
 
-    return data;
-  },
-
-  generate(data, relations, {html, language}) {
-    const {sections: sec} = relations;
-
-    return relations.layout.slots({
+  generate: (data, relations, {html, language}) =>
+    relations.layout.slots({
       title:
         language.$('flashPage.title', {
           flash: data.name,
@@ -147,7 +114,7 @@ export default {
           {[html.joinChildren]: html.tag('br')},
 
           [
-            sec.artistCommentary &&
+            !html.isBlank(relations.artistCommentarySection) &&
               language.$('releaseInfo.readCommentary', {
                 link: html.tag('a',
                   {href: '#artist-commentary'},
@@ -155,8 +122,8 @@ export default {
               }),
           ]),
 
-        sec.featuredTracks && [
-          sec.featuredTracks.heading
+        html.tags([
+          relations.contentHeading.clone()
             .slots({
               attributes: {id: 'features'},
               title:
@@ -165,32 +132,31 @@ export default {
                 }),
             }),
 
-          sec.featuredTracks.list,
-        ],
+          relations.featuredTracksList,
+        ]),
 
-        sec.contributors && [
-          sec.contributors.heading
+        html.tags([
+          relations.contentHeading.clone()
             .slots({
               attributes: {id: 'contributors'},
               title: language.$('releaseInfo.contributors'),
             }),
 
-          sec.contributors.list,
-        ],
+          relations.contributorContributionList,
+        ]),
 
-        sec.artistCommentary,
+        relations.artistCommentarySection,
       ],
 
       navLinkStyle: 'hierarchical',
       navLinks: [
         {auto: 'home'},
-        {html: sec.nav.flashActLink.slot('color', false)},
+        {html: relations.flashActLink.slot('color', false)},
         {auto: 'current'},
       ],
 
-      navBottomRowContent: sec.nav.flashNavAccent,
+      navBottomRowContent: relations.flashNavAccent,
 
       leftSidebar: relations.sidebar,
-    });
-  },
+    }),
 };