From 7cb88275fd3c813114271c0a136b12c72c5a172a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 19 Nov 2024 13:25:22 -0400 Subject: content: decompose generateCoverArtwork No visual/site changes yet. This involves introducing an unfortunate mega-hack in generateStickyHeadingContainer, which sets slots on cover artworks. Very scary. Oooooo Otherwise, all cover artwork code is much more compositional. Pass-through slots (`image`) are removed in generateCoverArtwork and a partially-formed `image` slot is accepted instead. --- .../dependencies/generateAlbumCoverArtwork.js | 47 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'src/content/dependencies/generateAlbumCoverArtwork.js') diff --git a/src/content/dependencies/generateAlbumCoverArtwork.js b/src/content/dependencies/generateAlbumCoverArtwork.js index 99003034..f6583882 100644 --- a/src/content/dependencies/generateAlbumCoverArtwork.js +++ b/src/content/dependencies/generateAlbumCoverArtwork.js @@ -1,10 +1,25 @@ export default { - contentDependencies: ['generateCoverArtwork'], - extraDependencies: ['language'], + contentDependencies: [ + 'generateCoverArtwork', + 'generateCoverArtworkArtTagDetails', + 'generateCoverArtworkArtistDetails', + 'image', + ], + + extraDependencies: ['html', 'language'], relations: (relation, album) => ({ coverArtwork: - relation('generateCoverArtwork', album.artTags, album.coverArtistContribs), + relation('generateCoverArtwork'), + + image: + relation('image'), + + artTagDetails: + relation('generateCoverArtworkArtTagDetails', album.artTags), + + artistDetails: + relation('generateCoverArtworkArtistDetails', album.coverArtistContribs), }), data: (album) => ({ @@ -18,11 +33,29 @@ export default { album.coverArtDimensions, }), - generate: (data, relations, {language}) => + slots: { + details: { + validate: v => v.is('tags', 'artists'), + default: 'tags', + }, + }, + + generate: (data, relations, slots, {language}) => relations.coverArtwork.slots({ - path: data.path, - color: data.color, + image: + relations.image.slots({ + path: data.path, + color: data.color, + alt: language.$('misc.alt.albumCover'), + }), + dimensions: data.dimensions, - alt: language.$('misc.alt.albumCover'), + + details: + (slots.details === 'tags' + ? relations.artTagDetails + : slots.details === 'artists' + ? relations.artistDetails + : null), }), }; -- cgit 1.3.0-6-gf8a5