« 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/album.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/page/album.js')
-rw-r--r--src/page/album.js50
1 files changed, 40 insertions, 10 deletions
diff --git a/src/page/album.js b/src/page/album.js
index c7327cc8..696e2854 100644
--- a/src/page/album.js
+++ b/src/page/album.js
@@ -1,3 +1,5 @@
+import {empty} from '#sugar';
+
 export const description = `per-album info, artwork gallery & commentary pages`;
 
 export function targets({wikiData}) {
@@ -5,8 +7,6 @@ export function targets({wikiData}) {
 }
 
 export function pathsForTarget(album) {
-  const hasCommentaryPage = !!album.commentary || album.tracks.some(t => t.commentary);
-
   return [
     {
       type: 'page',
@@ -28,7 +28,7 @@ export function pathsForTarget(album) {
       },
     },
 
-    hasCommentaryPage && {
+    {
       type: 'page',
       path: ['albumCommentary', album.directory],
 
@@ -38,6 +38,34 @@ export function pathsForTarget(album) {
       },
     },
 
+    {
+      type: 'page',
+      path: ['albumReferencedArtworks', album.directory],
+
+      condition: () =>
+        album.hasCoverArt &&
+        !empty(album.coverArtworks[0].referencedArtworks),
+
+      contentFunction: {
+        name: 'generateAlbumReferencedArtworksPage',
+        args: [album],
+      },
+    },
+
+    {
+      type: 'page',
+      path: ['albumReferencingArtworks', album.directory],
+
+      condition: () =>
+        album.hasCoverArt &&
+        !empty(album.coverArtworks[0].referencedByArtworks),
+
+      contentFunction: {
+        name: 'generateAlbumReferencingArtworksPage',
+        args: [album],
+      },
+    },
+
     /*
     {
       type: 'data',
@@ -60,13 +88,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/',
+    },
   ];
 }