« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page
diff options
context:
space:
mode:
Diffstat (limited to 'src/page')
-rw-r--r--src/page/album.js26
-rw-r--r--src/page/artist.js10
-rw-r--r--src/page/group.js39
-rw-r--r--src/page/track.js10
4 files changed, 52 insertions, 33 deletions
diff --git a/src/page/album.js b/src/page/album.js
index 46b1446b..8c08b960 100644
--- a/src/page/album.js
+++ b/src/page/album.js
@@ -38,20 +38,26 @@ export function pathsForTarget(album) {
       },
     },
 
-    !empty(album.referencedArtworks) && {
+    {
       type: 'page',
       path: ['albumReferencedArtworks', album.directory],
 
+      condition: () =>
+        !empty(album.referencedArtworks),
+
       contentFunction: {
         name: 'generateAlbumReferencedArtworksPage',
         args: [album],
       },
     },
 
-    !empty(album.referencedByArtworks) && {
+    {
       type: 'page',
       path: ['albumReferencingArtworks', album.directory],
 
+      condition: () =>
+        !empty(album.referencedByArtworks),
+
       contentFunction: {
         name: 'generateAlbumReferencingArtworksPage',
         args: [album],
@@ -80,13 +86,15 @@ export function pathsTargetless({wikiData: {wikiInfo}}) {
       contentFunction: {name: 'generateCommentaryIndexPage'},
     },
 
-    wikiInfo.canonicalBase === 'https://hsmusic.wiki/' &&
-      {
-        type: 'redirect',
-        fromPath: ['page', 'list/all-commentary'],
-        toPath: ['commentaryIndex'],
-        title: 'Album Commentary',
-      },
+    {
+      type: 'redirect',
+      fromPath: ['page', 'list/all-commentary'],
+      toPath: ['commentaryIndex'],
+      title: 'Album Commentary',
+
+      condition: () =>
+        wikiInfo.canonicalBase === 'https://hsmusic.wiki/',
+    },
   ];
 }
 
diff --git a/src/page/artist.js b/src/page/artist.js
index b68cf05c..257e060d 100644
--- a/src/page/artist.js
+++ b/src/page/artist.js
@@ -8,10 +8,6 @@ export function targets({wikiData}) {
 }
 
 export function pathsForTarget(artist) {
-  const hasGalleryPage =
-    !empty(artist.albumCoverArtistContributions) ||
-    !empty(artist.trackCoverArtistContributions);
-
   return [
     {
       type: 'page',
@@ -23,10 +19,14 @@ export function pathsForTarget(artist) {
       },
     },
 
-    hasGalleryPage && {
+    {
       type: 'page',
       path: ['artistGallery', artist.directory],
 
+      condition: () =>
+        !empty(artist.albumCoverArtistContributions) ||
+        !empty(artist.trackCoverArtistContributions),
+
       contentFunction: {
         name: 'generateArtistGalleryPage',
         args: [artist],
diff --git a/src/page/group.js b/src/page/group.js
index b0ed5baf..87590eaf 100644
--- a/src/page/group.js
+++ b/src/page/group.js
@@ -7,8 +7,6 @@ export function targets({wikiData}) {
 }
 
 export function pathsForTarget(group) {
-  const hasGalleryPage = !empty(group.albums);
-
   return [
     {
       type: 'page',
@@ -20,10 +18,13 @@ export function pathsForTarget(group) {
       },
     },
 
-    hasGalleryPage && {
+    {
       type: 'page',
       path: ['groupGallery', group.directory],
 
+      condition: () =>
+        !empty(group.albums),
+
       contentFunction: {
         name: 'generateGroupGalleryPage',
         args: [group],
@@ -34,20 +35,24 @@ export function pathsForTarget(group) {
 
 export function pathsTargetless({wikiData: {wikiInfo}}) {
   return [
-    wikiInfo.canonicalBase === 'https://hsmusic.wiki/' &&
-      {
-        type: 'redirect',
-        fromPath: ['page', 'albums/fandom'],
-        toPath: ['groupGallery', 'fandom'],
-        title: 'Fandom - Gallery',
-      },
+    {
+      type: 'redirect',
+      fromPath: ['page', 'albums/fandom'],
+      toPath: ['groupGallery', 'fandom'],
+      title: 'Fandom - Gallery',
 
-    wikiInfo.canonicalBase === 'https://hsmusic.wiki/' &&
-      {
-        type: 'redirect',
-        fromPath: ['page', 'albums/official'],
-        toPath: ['groupGallery', 'official'],
-        title: 'Official - Gallery',
-      },
+      condition: () =>
+        wikiInfo.canonicalBase === 'https://hsmusic.wiki/',
+    },
+
+    {
+      type: 'redirect',
+      fromPath: ['page', 'albums/official'],
+      toPath: ['groupGallery', 'official'],
+      title: 'Official - Gallery',
+
+      condition: () =>
+        wikiInfo.canonicalBase === 'https://hsmusic.wiki/',
+    },
   ];
 }
diff --git a/src/page/track.js b/src/page/track.js
index 94a1e48d..301af991 100644
--- a/src/page/track.js
+++ b/src/page/track.js
@@ -20,20 +20,26 @@ export function pathsForTarget(track) {
       },
     },
 
-    !empty(track.referencedArtworks) && {
+    {
       type: 'page',
       path: ['trackReferencedArtworks', track.directory],
 
+      condition: () =>
+        !empty(track.referencedArtworks),
+
       contentFunction: {
         name: 'generateTrackReferencedArtworksPage',
         args: [track],
       },
     },
 
-    !empty(track.referencedByArtworks) && {
+    {
       type: 'page',
       path: ['trackReferencingArtworks', track.directory],
 
+      condition: () =>
+        !empty(track.referencedByArtworks),
+
       contentFunction: {
         name: 'generateTrackReferencingArtworksPage',
         args: [track],