From c31d38c4778e51fb90958c40af93519661538889 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 19 Nov 2024 15:56:40 -0400 Subject: content, css: cover artwork reference details, non-unique art line --- .../generateCoverArtworkReferenceDetails.js | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/content/dependencies/generateCoverArtworkReferenceDetails.js (limited to 'src/content/dependencies/generateCoverArtworkReferenceDetails.js') diff --git a/src/content/dependencies/generateCoverArtworkReferenceDetails.js b/src/content/dependencies/generateCoverArtworkReferenceDetails.js new file mode 100644 index 00000000..006b2b4b --- /dev/null +++ b/src/content/dependencies/generateCoverArtworkReferenceDetails.js @@ -0,0 +1,56 @@ +export default { + extraDependencies: ['html', 'language'], + + data: (referenced, referencedBy) => ({ + referenced: + referenced.length, + + referencedBy: + referencedBy.length, + }), + + slots: { + referencedLink: {type: 'html', mutable: true}, + referencingLink: {type: 'html', mutable: true}, + }, + + generate: (data, slots, {html, language}) => + language.encapsulate('releaseInfo', capsule => { + const referencedText = + language.$(capsule, 'referencesArtworks', { + [language.onlyIfOptions]: ['artworks'], + + artworks: + language.countArtworks(data.referenced, { + blankIfZero: true, + unit: true, + }), + }); + + const referencingText = + language.$(capsule, 'referencedByArtworks', { + [language.onlyIfOptions]: ['artworks'], + + artworks: + language.countArtworks(data.referencedBy, { + blankIfZero: true, + unit: true, + }), + }); + + return ( + html.tag('p', {class: 'image-details'}, + {[html.onlyIfContent]: true}, + {[html.joinChildren]: html.tag('br')}, + + {class: 'reference-details'}, + + [ + !html.isBlank(referencedText) && + slots.referencedLink.slot('content', referencedText), + + !html.isBlank(referencingText) && + slots.referencingLink.slot('content', referencingText), + ])); + }), +} -- cgit 1.3.0-6-gf8a5