From 0d74914e3c3c345ddac3025b561b88ed9a055f95 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 17 Nov 2024 08:44:06 -0400 Subject: data, content: closely linked artist annotations Basic implementation only here, nothing custom for particular annotations for example. --- src/content/dependencies/generateGroupInfoPage.js | 39 +++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'src/content/dependencies/generateGroupInfoPage.js') diff --git a/src/content/dependencies/generateGroupInfoPage.js b/src/content/dependencies/generateGroupInfoPage.js index deddfd68..918d6476 100644 --- a/src/content/dependencies/generateGroupInfoPage.js +++ b/src/content/dependencies/generateGroupInfoPage.js @@ -1,3 +1,5 @@ +import {stitchArrays} from '#sugar'; + export default { contentDependencies: [ 'generateColorStyleAttribute', @@ -43,7 +45,8 @@ export default { closeArtistLinks: group.closelyLinkedArtists - .map(artist => relation('linkArtist', artist)), + .map(({thing: artist}) => + relation('linkArtist', artist)), visitLinks: group.urls @@ -62,6 +65,10 @@ export default { color: group.color, + + closeArtistAnnotations: + group.closelyLinkedArtists + .map(({annotation}) => annotation), }), generate: (data, relations, {html, language}) => @@ -76,23 +83,37 @@ export default { {[html.onlyIfContent]: true}, language.encapsulate(pageCapsule, 'closelyLinkedArtists', capsule => { - let option; - [capsule, option] = + const [workingCapsule, option] = (relations.closeArtistLinks.length === 0 ? [null, null] : relations.closeArtistLinks.length === 1 ? [language.encapsulate(capsule, 'one'), 'artist'] : [language.encapsulate(capsule, 'multiple'), 'artists']); - if (!capsule) return html.blank(); + if (!workingCapsule) return html.blank(); - return language.$(capsule, { + return language.$(workingCapsule, { [option]: language.formatUnitList( - relations.closeArtistLinks - .map(link => link.slots({ - attributes: [relations.wikiColorAttribute], - }))), + stitchArrays({ + link: relations.closeArtistLinks, + annotation: data.closeArtistAnnotations, + }).map(({link, annotation}) => + language.encapsulate(capsule, 'artist', workingCapsule => { + const workingOptions = {}; + + workingOptions.artist = + link.slots({ + attributes: [relations.wikiColorAttribute], + }); + + if (annotation) { + workingCapsule += '.withAnnotation'; + workingOptions.annotation = annotation; + } + + return language.$(workingCapsule, workingOptions); + }))), }); })), -- cgit 1.3.0-6-gf8a5