diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-11-29 21:48:05 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-11-29 21:48:05 -0400 |
commit | 628a608833f938d79d10c250fb1bf780ec133276 (patch) | |
tree | 7bda95565c4a80e6d6fdd164007bbbc5b7ad7590 /src/content/dependencies | |
parent | 2c6d88908591a0f9d734d634f3f2ab4aca575be5 (diff) |
content: generateTrackInfoPage: embed year next to other releases
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/generateTrackInfoPage.js | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js index 2848b15c..099b889b 100644 --- a/src/content/dependencies/generateTrackInfoPage.js +++ b/src/content/dependencies/generateTrackInfoPage.js @@ -1,10 +1,11 @@ -import {empty} from '#sugar'; +import {empty, stitchArrays} from '#sugar'; import {sortAlbumsTracksChronologically, sortFlashesChronologically} from '#wiki-data'; import getChronologyRelations from '../util/getChronologyRelations.js'; export default { contentDependencies: [ + 'generateAbsoluteDatetimestamp', 'generateAdditionalFilesShortcut', 'generateAdditionalNamesBox', 'generateAlbumAdditionalFilesList', @@ -16,6 +17,7 @@ export default { 'generateContentHeading', 'generateContributionList', 'generatePageLayout', + 'generateRelativeDatetimestamp', 'generateTrackCoverArtwork', 'generateTrackList', 'generateTrackListDividedByGroups', @@ -140,6 +142,25 @@ export default { otherReleases.heading = relation('generateContentHeading'); + otherReleases.trackLinks = + track.otherReleases + .map(track => relation('linkTrack', track)); + + otherReleases.albumLinks = + track.otherReleases + .map(track => relation('linkAlbum', track.album)); + + otherReleases.datetimestamps = + track.otherReleases.map(track2 => + (track2.date + ? (track.date + ? relation('generateRelativeDatetimestamp', + track2.date, + track.date) + : relation('generateAbsoluteDatetimestamp', + track2.date)) + : null)); + otherReleases.items = track.otherReleases.map(track => ({ trackLink: relation('linkTrack', track), @@ -356,12 +377,27 @@ export default { }), html.tag('ul', - sec.otherReleases.items.map(({trackLink, albumLink}) => - html.tag('li', - language.$('releaseInfo.alsoReleasedAs.item', { - track: trackLink, - album: albumLink, - })))), + stitchArrays({ + trackLink: sec.otherReleases.trackLinks, + albumLink: sec.otherReleases.albumLinks, + datetimestamp: sec.otherReleases.datetimestamps, + }).map(({trackLink, albumLink, datetimestamp}) => { + const parts = ['releaseInfo.alsoReleasedAs.item']; + const options = {track: trackLink, album: albumLink}; + + if (datetimestamp) { + parts.push('withYear'); + options.year = + datetimestamp.slots({ + style: 'year', + tooltip: true, + }); + } + + return ( + html.tag('li', + language.$(...parts, options))); + })), ], sec.contributors && [ |