diff options
-rw-r--r-- | src/content/dependencies/generateAlbumCommentaryPage.js | 26 | ||||
-rw-r--r-- | src/content/dependencies/generateAlbumCommentarySidebar.js | 62 | ||||
-rw-r--r-- | src/page/album.js | 4 | ||||
-rw-r--r-- | src/strings-default.yaml | 10 |
4 files changed, 72 insertions, 30 deletions
diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js index 61d9ca95..e323ed39 100644 --- a/src/content/dependencies/generateAlbumCommentaryPage.js +++ b/src/content/dependencies/generateAlbumCommentaryPage.js @@ -146,14 +146,24 @@ export default { mainClasses: ['long-content'], mainContent: [ html.tag('p', - language.$(pageCapsule, 'infoLine', { - words: - html.tag('b', - language.formatWordCount(data.wordCount, {unit: true})), - - entries: - html.tag('b', - language.countCommentaryEntries(data.entryCount, {unit: true})), + language.encapsulate(pageCapsule, 'infoLine', workingCapsule => { + const workingOptions = {}; + + if (data.entryCount >= 1) { + workingOptions.words = + html.tag('b', + language.formatWordCount(data.wordCount, {unit: true})); + + workingOptions.entries = + html.tag('b', + language.countCommentaryEntries(data.entryCount, {unit: true})); + } + + if (data.entryCount === 0) { + workingCapsule += '.withoutCommentary'; + } + + return language.$(workingCapsule, workingOptions); })), relations.albumCommentaryEntries && 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', + })), + ], + }), + ] + })), } diff --git a/src/page/album.js b/src/page/album.js index be551ca7..46b1446b 100644 --- a/src/page/album.js +++ b/src/page/album.js @@ -7,8 +7,6 @@ export function targets({wikiData}) { } export function pathsForTarget(album) { - const hasCommentaryPage = !!album.commentary || album.tracks.some(t => t.commentary); - return [ { type: 'page', @@ -30,7 +28,7 @@ export function pathsForTarget(album) { }, }, - hasCommentaryPage && { + { type: 'page', path: ['albumCommentary', album.directory], diff --git a/src/strings-default.yaml b/src/strings-default.yaml index af9f5895..a3388472 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -1064,9 +1064,19 @@ albumCommentaryPage: nav: album: "Album: {ALBUM}" + sidebar: + noTrackCommentary: >- + No track commentary. + + noCommentary: >- + No album or track commentary. + infoLine: >- {WORDS} across {ENTRIES}. + infoLine.withoutCommentary: >- + This album does not have any commentary. + entry: title: albumCommentary: |