diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-11-17 08:44:06 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-17 13:40:01 -0400 |
commit | 0d74914e3c3c345ddac3025b561b88ed9a055f95 (patch) | |
tree | 7770ad0c4c81eebc34b3702c09c839efe134b808 /src/content/dependencies/generateGroupInfoPage.js | |
parent | 6bcbe4f3489bafff4a78f87e030c08db734af021 (diff) |
data, content: closely linked artist annotations
Basic implementation only here, nothing custom for particular annotations for example.
Diffstat (limited to 'src/content/dependencies/generateGroupInfoPage.js')
-rw-r--r-- | src/content/dependencies/generateGroupInfoPage.js | 39 |
1 files changed, 30 insertions, 9 deletions
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); + }))), }); })), |