diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-02-11 11:12:07 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-02-12 07:43:59 -0400 |
commit | c45d45759395725128c030ac387bb20b80aada1e (patch) | |
tree | dd71e8354268ca5c48101b0b225144db982cc5cb /src/content/dependencies/generateWikiHomepageAlbumCarouselRow.js | |
parent | 19d9c3a3d16ed08b2d0c9e09259ffb79a27cd3e9 (diff) |
content, data: generateWikiHomepageAlbum{Carousel,Grid}Row
Diffstat (limited to 'src/content/dependencies/generateWikiHomepageAlbumCarouselRow.js')
-rw-r--r-- | src/content/dependencies/generateWikiHomepageAlbumCarouselRow.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/content/dependencies/generateWikiHomepageAlbumCarouselRow.js b/src/content/dependencies/generateWikiHomepageAlbumCarouselRow.js new file mode 100644 index 00000000..3068d951 --- /dev/null +++ b/src/content/dependencies/generateWikiHomepageAlbumCarouselRow.js @@ -0,0 +1,39 @@ +import {stitchArrays} from '#sugar'; + +export default { + contentDependencies: ['generateCoverCarousel', 'image', 'linkAlbum'], + + relations: (relation, row) => ({ + coverCarousel: + relation('generateCoverCarousel'), + + links: + row.albums + .map(album => relation('linkAlbum', album)), + + images: + row.albums + .map(album => relation('image', album.artTags)), + }), + + data: (row) => ({ + paths: + row.albums.map(album => + (album.hasCoverArt + ? ['media.albumCover', album.directory, album.coverArtFileExtension] + : null)), + }), + + generate: (data, relations) => + relations.coverCarousel.slots({ + links: + relations.links, + + images: + stitchArrays({ + image: relations.images, + path: data.paths, + }).map(({image, path}) => + image.slot('path', path)), + }), +}; |