From 6b9c8cb3615b7ba7b49d1c21b2748d2e75e7ee82 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 23 Oct 2025 19:23:18 -0300 Subject: content, data: Track.previousProductionTracks --- .../generateTrackInfoPagePreviousProductionLine.js | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/content/dependencies/generateTrackInfoPagePreviousProductionLine.js (limited to 'src/content/dependencies/generateTrackInfoPagePreviousProductionLine.js') diff --git a/src/content/dependencies/generateTrackInfoPagePreviousProductionLine.js b/src/content/dependencies/generateTrackInfoPagePreviousProductionLine.js new file mode 100644 index 00000000..b2f50cf3 --- /dev/null +++ b/src/content/dependencies/generateTrackInfoPagePreviousProductionLine.js @@ -0,0 +1,37 @@ +import {stitchArrays} from '#sugar'; +import {getKebabCase} from '#wiki-data'; + +export default { + relations: (relation, track) => ({ + trackLinks: + track.followingProductionTracks + .map(track => relation('linkTrack', track)), + + albumLinks: + track.followingProductionTracks + .map(following => + (following.album !== track.album && + getKebabCase(following.name) === getKebabCase(track.name) + + ? relation('linkAlbum', following.album) + : null)), + }), + + generate: (relations, {language}) => + language.encapsulate('releaseInfo.previousProduction', capsule => + language.$(capsule, { + [language.onlyIfOptions]: ['tracks'], + + tracks: + stitchArrays({ + trackLink: relations.trackLinks, + albumLink: relations.albumLinks, + }).map(({trackLink, albumLink}) => + (albumLink + ? language.$(capsule, 'trackOnAlbum', { + track: trackLink, + album: albumLink, + }) + : trackLink)), + })), +}; -- cgit 1.3.0-6-gf8a5