diff options
Diffstat (limited to 'src/content/dependencies/generateArtistInfoPageChunkItem.js')
-rw-r--r-- | src/content/dependencies/generateArtistInfoPageChunkItem.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageChunkItem.js b/src/content/dependencies/generateArtistInfoPageChunkItem.js new file mode 100644 index 0000000..b6f4072 --- /dev/null +++ b/src/content/dependencies/generateArtistInfoPageChunkItem.js @@ -0,0 +1,60 @@ +export default { + extraDependencies: ['html', 'language'], + + slots: { + content: { + type: 'html', + mutable: false, + }, + + annotation: { + type: 'html', + mutable: false, + }, + + otherArtistLinks: { + validate: v => v.strictArrayOf(v.isHTML), + }, + + rerelease: {type: 'boolean'}, + }, + + generate(slots, {html, language}) { + let accentedContent = slots.content; + + accent: { + if (slots.rerelease) { + accentedContent = + language.$('artistPage.creditList.entry.rerelease', { + entry: accentedContent, + }); + + break accent; + } + + const parts = ['artistPage.creditList.entry']; + const options = {entry: accentedContent}; + + if (slots.otherArtistLinks) { + parts.push('withArtists'); + options.artists = language.formatConjunctionList(slots.otherArtistLinks); + } + + if (!html.isBlank(slots.annotation)) { + parts.push('withAnnotation'); + options.annotation = slots.annotation; + } + + if (parts.length === 1) { + break accent; + } + + accentedContent = language.formatString(...parts, options); + } + + return ( + html.tag('li', + slots.rerelease && {class: 'rerelease'}, + accentedContent)); + }, +}; |