diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-06-08 10:54:53 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-06-08 10:54:53 -0300 |
commit | 957f9b83171011f2da63f2e0880be30a4dc0d978 (patch) | |
tree | 43c09ea80e1b7f996c91d3d443cad6bbafd2bc3c /src/content/dependencies/generateReleaseInfoContributionsLine.js | |
parent | c36d6b999a554733ad4f3397f8047eb9f40db95e (diff) |
content: generateReleaseInfoContributionsLine
Diffstat (limited to 'src/content/dependencies/generateReleaseInfoContributionsLine.js')
-rw-r--r-- | src/content/dependencies/generateReleaseInfoContributionsLine.js | 49 |
1 files changed, 49 insertions, 0 deletions
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, + }))), + }); + }, + }); + }, +}; |