From c45d45759395725128c030ac387bb20b80aada1e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 11 Feb 2025 11:12:07 -0400 Subject: content, data: generateWikiHomepageAlbum{Carousel,Grid}Row --- .../generateWikiHomepageAlbumCarouselRow.js | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/content/dependencies/generateWikiHomepageAlbumCarouselRow.js (limited to 'src/content/dependencies/generateWikiHomepageAlbumCarouselRow.js') 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)), + }), +}; -- cgit 1.3.0-6-gf8a5