From 113157085c7bd6f23bd7c08ad6cd2d94673d7033 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 12 Sep 2023 14:47:15 -0300 Subject: content: artist..{TracksChunkedList,ChunkItem}: avoid double sanitize No further changes needed for artwork and flash chunked lists, where contributions consist of only one item (which might be null). --- .../generateArtistInfoPageChunkItem.js | 4 ++-- .../generateArtistInfoPageTracksChunkedList.js | 25 ++++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src/content/dependencies') diff --git a/src/content/dependencies/generateArtistInfoPageChunkItem.js b/src/content/dependencies/generateArtistInfoPageChunkItem.js index 36f0ebcc..9f99513d 100644 --- a/src/content/dependencies/generateArtistInfoPageChunkItem.js +++ b/src/content/dependencies/generateArtistInfoPageChunkItem.js @@ -5,7 +5,7 @@ export default { content: {type: 'html'}, otherArtistLinks: {validate: v => v.strictArrayOf(v.isHTML)}, - contribution: {type: 'string'}, + contribution: {type: 'html'}, rerelease: {type: 'boolean'}, }, @@ -30,7 +30,7 @@ export default { options.artists = language.formatConjunctionList(slots.otherArtistLinks); } - if (slots.contribution) { + if (!html.isBlank(slots.contribution)) { parts.push('withContribution'); options.contribution = slots.contribution; } diff --git a/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js b/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js index 0566f713..654f759c 100644 --- a/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js +++ b/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js @@ -1,4 +1,4 @@ -import {accumulateSum, stitchArrays} from '#sugar'; +import {accumulateSum, empty, stitchArrays} from '#sugar'; import { chunkByProperties, @@ -16,7 +16,7 @@ export default { 'linkTrack', ], - extraDependencies: ['language'], + extraDependencies: ['html', 'language'], query(artist) { const tracksAsArtistAndContributor = @@ -122,11 +122,16 @@ export default { trackContributions: query.chunks.map(({chunk}) => - chunk.map(({contribs}) => - contribs - .filter(({who}) => who === artist) - .filter(({what}) => what) - .map(({what}) => what))), + chunk + .map(({contribs}) => + contribs + .filter(({who}) => who === artist) + .filter(({what}) => what) + .map(({what}) => what)) + .map(contributions => + (empty(contributions) + ? null + : contributions))), trackRereleases: query.chunks.map(({chunk}) => @@ -134,7 +139,7 @@ export default { }; }, - generate(data, relations, {language}) { + generate(data, relations, {html, language}) { return relations.chunkedList.slots({ chunks: stitchArrays({ @@ -192,7 +197,9 @@ export default { rerelease, contribution: - language.formatUnitList(contribution), + (contribution + ? language.formatUnitList(contribution) + : html.blank()), content: (duration -- cgit 1.3.0-6-gf8a5