« 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.js69
1 files changed, 53 insertions, 16 deletions
diff --git a/src/page/album.js b/src/page/album.js
index c7327cc8..e585618c 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,35 +7,68 @@ export function targets({wikiData}) {
 }
 
 export function pathsForTarget(album) {
-  const hasCommentaryPage = !!album.commentary || album.tracks.some(t => t.commentary);
-
   return [
+    (album.style === 'single'
+      ? {
+          type: 'redirect',
+          fromPath: ['album', album.directory],
+          toPath: ['track', album.tracks[0].directory],
+          title: album.name,
+        }
+      : {
+          type: 'page',
+          path: ['album', album.directory],
+
+          contentFunction: {
+            name: 'generateAlbumInfoPage',
+            args: [album],
+          },
+        }),
+
     {
       type: 'page',
-      path: ['album', album.directory],
+      path: ['albumGallery', album.directory],
 
       contentFunction: {
-        name: 'generateAlbumInfoPage',
+        name: 'generateAlbumGalleryPage',
         args: [album],
       },
     },
 
     {
       type: 'page',
-      path: ['albumGallery', album.directory],
+      path: ['albumCommentary', album.directory],
 
       contentFunction: {
-        name: 'generateAlbumGalleryPage',
+        name: 'generateAlbumCommentaryPage',
         args: [album],
       },
     },
 
-    hasCommentaryPage && {
+    {
       type: 'page',
-      path: ['albumCommentary', album.directory],
+      path: ['albumReferencedArtworks', album.directory],
+
+      condition: () =>
+        album.hasCoverArt &&
+        !empty(album.coverArtworks[0].referencedArtworks),
 
       contentFunction: {
-        name: 'generateAlbumCommentaryPage',
+        name: 'generateAlbumReferencedArtworksPage',
+        args: [album],
+      },
+    },
+
+    {
+      type: 'page',
+      path: ['albumReferencingArtworks', album.directory],
+
+      condition: () =>
+        album.hasCoverArt &&
+        !empty(album.coverArtworks[0].referencedByArtworks),
+
+      contentFunction: {
+        name: 'generateAlbumReferencingArtworksPage',
         args: [album],
       },
     },
@@ -60,13 +95,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/',
+    },
   ];
 }