From d4318084d64209c26bda6464b25dcd53f7479086 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 19 Dec 2024 12:49:08 -0400 Subject: content: generateAlbumCommentaryPage: stub commentary pages --- .../dependencies/generateAlbumCommentarySidebar.js | 62 +++++++++++++++------- 1 file changed, 43 insertions(+), 19 deletions(-) (limited to 'src/content/dependencies/generateAlbumCommentarySidebar.js') diff --git a/src/content/dependencies/generateAlbumCommentarySidebar.js b/src/content/dependencies/generateAlbumCommentarySidebar.js index 435860cb..8313e6de 100644 --- a/src/content/dependencies/generateAlbumCommentarySidebar.js +++ b/src/content/dependencies/generateAlbumCommentarySidebar.js @@ -6,7 +6,7 @@ export default { 'linkAlbum', ], - extraDependencies: ['html'], + extraDependencies: ['html', 'language'], relations: (relation, album) => ({ sidebar: @@ -26,22 +26,46 @@ export default { trackSection)), }), - generate: (relations, {html}) => - relations.sidebar.slots({ - stickyMode: 'column', - boxes: [ - relations.sidebarBox.slots({ - attributes: {class: 'commentary-track-list-sidebar-box'}, - content: [ - html.tag('h1', relations.albumLink), - relations.trackSections.map(section => - section.slots({ - anchor: true, - open: true, - mode: 'commentary', - })), - ], - }), - ] - }), + data: (album) => ({ + albumHasCommentary: + !!album.commentary, + + anyTrackHasCommentary: + album.tracks.some(track => track.commentary), + }), + + generate: (data, relations, {html, language}) => + language.encapsulate('albumCommentaryPage', pageCapsule => + relations.sidebar.slots({ + stickyMode: 'column', + boxes: [ + relations.sidebarBox.slots({ + attributes: {class: 'commentary-track-list-sidebar-box'}, + content: [ + html.tag('h1', relations.albumLink), + + html.tag('p', {[html.onlyIfContent]: true}, + language.encapsulate(pageCapsule, 'sidebar', workingCapsule => { + if (data.anyTrackHasCommentary) return html.blank(); + + if (data.albumHasCommentary) { + workingCapsule += '.noTrackCommentary'; + } else { + workingCapsule += '.noCommentary'; + } + + return language.$(workingCapsule); + })), + + data.anyTrackHasCommentary && + relations.trackSections.map(section => + section.slots({ + anchor: true, + open: true, + mode: 'commentary', + })), + ], + }), + ] + })), } -- cgit 1.3.0-6-gf8a5