diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-07-02 12:38:55 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-07-02 12:38:55 -0300 |
commit | 1d670edff0cdb6ff696cedac08ecbdf39aa7c085 (patch) | |
tree | 483afae9603441c823bab57ab243304b4a19c4fa /src/content/dependencies/listAlbumsByDate.js | |
parent | 467bad1a645d77fc8b421ef9aeb9bbea6d2465ea (diff) |
content: listAlbumsBy{Tracks,Duration,Date}
Diffstat (limited to 'src/content/dependencies/listAlbumsByDate.js')
-rw-r--r-- | src/content/dependencies/listAlbumsByDate.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/content/dependencies/listAlbumsByDate.js b/src/content/dependencies/listAlbumsByDate.js new file mode 100644 index 00000000..1c584282 --- /dev/null +++ b/src/content/dependencies/listAlbumsByDate.js @@ -0,0 +1,52 @@ +import {stitchArrays} from '../../util/sugar.js'; +import {sortChronologically} from '../../util/wiki-data.js'; + +export default { + contentDependencies: ['generateListingPage', 'linkAlbum'], + extraDependencies: ['language', 'wikiData'], + + sprawl({albumData}) { + return {albumData}; + }, + + query({albumData}, spec) { + return { + spec, + + albums: + sortChronologically(albumData.filter(album => album.date)), + }; + }, + + relations(relation, query) { + return { + page: relation('generateListingPage', query.spec), + + albumLinks: + query.albums + .map(album => relation('linkAlbum', album)), + }; + }, + + data(query) { + return { + dates: + query.albums + .map(album => album.date), + }; + }, + + generate(data, relations, {language}) { + return relations.page.slots({ + type: 'rows', + rows: + stitchArrays({ + link: relations.albumLinks, + date: data.dates, + }).map(({link, date}) => ({ + album: link, + date: language.formatDate(date), + })), + }); + }, +}; |