« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateAlbumCommentaryPage.js1
-rw-r--r--src/content/dependencies/linkAlbumDynamically.js20
2 files changed, 19 insertions, 2 deletions
diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js
index c14640af..61d9ca95 100644
--- a/src/content/dependencies/generateAlbumCommentaryPage.js
+++ b/src/content/dependencies/generateAlbumCommentaryPage.js
@@ -161,6 +161,7 @@ export default {
               language.encapsulate(entryCapsule, 'title.albumCommentary', titleCapsule =>
                 relations.albumCommentaryHeading.slots({
                   tag: 'h3',
+                  attributes: {id: 'album-commentary'},
                   color: data.color,
 
                   title:
diff --git a/src/content/dependencies/linkAlbumDynamically.js b/src/content/dependencies/linkAlbumDynamically.js
index 3adc64df..ca295b41 100644
--- a/src/content/dependencies/linkAlbumDynamically.js
+++ b/src/content/dependencies/linkAlbumDynamically.js
@@ -7,8 +7,24 @@ export default {
     infoLink: relation('linkAlbum', album),
   }),
 
-  generate: (relations, {pagePath}) =>
-    (pagePath[0] === 'albumGallery'
+  data: (album) => ({
+    albumDirectory:
+      album.directory,
+
+    albumHasCommentary:
+      !!album.commentary,
+  }),
+
+  generate: (data, relations, {pagePath}) =>
+    (pagePath[0] === 'albumCommentary' &&
+     pagePath[1] === data.albumDirectory &&
+     data.albumHasCommentary
+      ? relations.infoLink.slots({
+          anchor: true,
+          hash: 'album-commentary',
+        })
+
+   : pagePath[0] === 'albumGallery'
       ? relations.galleryLink
       : relations.infoLink),
 };