From 957f9b83171011f2da63f2e0880be30a4dc0d978 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 8 Jun 2023 10:54:53 -0300 Subject: content: generateReleaseInfoContributionsLine --- .../generateReleaseInfoContributionsLine.js | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/content/dependencies/generateReleaseInfoContributionsLine.js (limited to 'src/content/dependencies/generateReleaseInfoContributionsLine.js') diff --git a/src/content/dependencies/generateReleaseInfoContributionsLine.js b/src/content/dependencies/generateReleaseInfoContributionsLine.js new file mode 100644 index 00000000..2b342d09 --- /dev/null +++ b/src/content/dependencies/generateReleaseInfoContributionsLine.js @@ -0,0 +1,49 @@ +import {empty} from '../../util/sugar.js'; + +export default { + contentDependencies: ['linkContribution'], + extraDependencies: ['html', 'language'], + + relations(relation, contributions) { + if (empty(contributions)) { + return {}; + } + + return { + contributionLinks: + contributions + .slice(0, 4) + .map(({who, what}) => + relation('linkContribution', who, what)), + }; + }, + + generate(relations, {html, language}) { + return html.template({ + annotation: `generateReleaseInfoContributionsLine`, + + slots: { + stringKey: {type: 'string'}, + + showContribution: {type: 'boolean', default: true}, + showIcons: {type: 'boolean', default: true}, + }, + + content(slots) { + if (!relations.contributionLinks) { + return html.blank(); + } + + return language.$(slots.stringKey, { + artists: + language.formatConjunctionList( + relations.contributionLinks.map(link => + link.slots({ + showContribution: slots.showContribution, + showIcons: slots.showIcons, + }))), + }); + }, + }); + }, +}; -- cgit 1.3.0-6-gf8a5