diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-07-30 21:05:30 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-07-30 21:05:30 -0300 |
commit | ac00cb19d57f79b784461ef924f9858260a48333 (patch) | |
tree | fe84d4bfb8e5040b27a4a90d76f3c5525c36f1a9 /src/content/dependencies/listTracksInFlashesByFlash.js | |
parent | 12531f8e178e0ae34ee66d441966fdc9a33dba5b (diff) | |
parent | 4cbde0e670e5812254509f1f5da39241304dacc0 (diff) |
Merge branch 'data-steps' of github.com:hsmusic/hsmusic-wiki into data-steps
Diffstat (limited to 'src/content/dependencies/listTracksInFlashesByFlash.js')
-rw-r--r-- | src/content/dependencies/listTracksInFlashesByFlash.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/content/dependencies/listTracksInFlashesByFlash.js b/src/content/dependencies/listTracksInFlashesByFlash.js new file mode 100644 index 00000000..70edcd32 --- /dev/null +++ b/src/content/dependencies/listTracksInFlashesByFlash.js @@ -0,0 +1,69 @@ +import {empty, stitchArrays} from '../../util/sugar.js'; +import {sortFlashesChronologically} from '../../util/wiki-data.js'; + +export default { + contentDependencies: ['generateListingPage', 'linkAlbum', 'linkFlash', 'linkTrack'], + extraDependencies: ['wikiData'], + + sprawl({flashData}) { + return {flashData}; + }, + + query({flashData}, spec) { + const flashes = sortFlashesChronologically( + flashData + .filter(flash => !empty(flash.featuredTracks))); + + const tracks = + flashes.map(album => album.featuredTracks); + + const albums = + tracks.map(tracks => + tracks.map(track => track.album)); + + return {spec, flashes, tracks, albums}; + }, + + relations(relation, query) { + return { + page: relation('generateListingPage', query.spec), + + flashLinks: + query.flashes + .map(flash => relation('linkFlash', flash)), + + trackLinks: + query.tracks + .map(tracks => tracks + .map(track => relation('linkTrack', track))), + + albumLinks: + query.albums + .map(albums => albums + .map(album => relation('linkAlbum', album))), + }; + }, + + generate(relations) { + return relations.page.slots({ + type: 'chunks', + + chunkTitles: + relations.flashLinks + .map(flashLink => ({flash: flashLink})), + + chunkRows: + stitchArrays({ + trackLinks: relations.trackLinks, + albumLinks: relations.albumLinks, + }).map(({trackLinks, albumLinks}) => + stitchArrays({ + trackLink: trackLinks, + albumLink: albumLinks, + }).map(({trackLink, albumLink}) => ({ + track: trackLink, + album: albumLink, + }))), + }); + }, +}; |