« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common-util/wiki-data.js6
-rw-r--r--src/content/dependencies/generateAlbumInfoPage.js4
-rw-r--r--src/content/dependencies/generateAlbumNavAccent.js5
3 files changed, 11 insertions, 4 deletions
diff --git a/src/common-util/wiki-data.js b/src/common-util/wiki-data.js
index c9c63db7..42ff677e 100644
--- a/src/common-util/wiki-data.js
+++ b/src/common-util/wiki-data.js
@@ -610,3 +610,9 @@ export function* matchInlineLinks(source) {
     yield {href, length, index};
   }
 }
+
+export const albumHasSubstantialCommentaryPage = album =>
+  !empty(
+    album.tracks
+      .flatMap(track => track.commentary)
+      .filter(entry => !entry.isWikiEditorCommentary));
diff --git a/src/content/dependencies/generateAlbumInfoPage.js b/src/content/dependencies/generateAlbumInfoPage.js
index d60e6c50..f7115ef8 100644
--- a/src/content/dependencies/generateAlbumInfoPage.js
+++ b/src/content/dependencies/generateAlbumInfoPage.js
@@ -1,4 +1,4 @@
-import {empty} from '#sugar';
+import {albumHasSubstantialCommentaryPage} from '#wiki-data';
 
 export default {
   relations: (relation, album) => ({
@@ -43,7 +43,7 @@ export default {
         : null),
 
     commentaryLink:
-      (album.tracks.some(track => !empty(track.commentary))
+      (albumHasSubstantialCommentaryPage(album)
         ? relation('linkAlbumCommentary', album)
         : null),
 
diff --git a/src/content/dependencies/generateAlbumNavAccent.js b/src/content/dependencies/generateAlbumNavAccent.js
index 237120f3..24a562f4 100644
--- a/src/content/dependencies/generateAlbumNavAccent.js
+++ b/src/content/dependencies/generateAlbumNavAccent.js
@@ -1,4 +1,5 @@
-import {atOffset, empty} from '#sugar';
+import {atOffset} from '#sugar';
+import {albumHasSubstantialCommentaryPage} from '#wiki-data';
 
 export default {
   query(album, track) {
@@ -54,7 +55,7 @@ export default {
       album.tracks.length > 1,
 
     hasSubstantialCommentaryPage:
-      album.tracks.some(track => !empty(track.commentary)),
+      albumHasSubstantialCommentaryPage(album),
 
     galleryIsStub:
       album.tracks.every(t => !t.hasUniqueCoverArt),