diff options
Diffstat (limited to 'src/content/dependencies/generateArtistInfoPageChunk.js')
-rw-r--r-- | src/content/dependencies/generateArtistInfoPageChunk.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageChunk.js b/src/content/dependencies/generateArtistInfoPageChunk.js new file mode 100644 index 00000000..eb9056cb --- /dev/null +++ b/src/content/dependencies/generateArtistInfoPageChunk.js @@ -0,0 +1,81 @@ +export default { + extraDependencies: ['html', 'language'], + + slots: { + mode: { + validate: v => v.is('flash', 'album'), + }, + + albumLink: {type: 'html'}, + flashActLink: {type: 'html'}, + + date: {validate: v => v.isDate}, + dateRangeStart: {validate: v => v.isDate}, + dateRangeEnd: {validate: v => v.isDate}, + + duration: {validate: v => v.isDuration}, + durationApproximate: {type: 'boolean'}, + + items: {type: 'html'}, + }, + + generate(slots, {html, language}) { + let accentedLink; + + accent: { + switch (slots.mode) { + case 'album': { + accentedLink = slots.albumLink; + + const options = {album: accentedLink}; + const parts = ['artistPage.creditList.album']; + + if (slots.date) { + parts.push('withDate'); + options.date = language.formatDate(slots.date); + } + + if (slots.duration) { + parts.push('withDuration'); + options.duration = + language.formatDuration(slots.duration, { + approximate: slots.durationApproximate, + }); + } + + accentedLink = language.formatString(parts.join('.'), options); + break; + } + + case 'flash': { + accentedLink = slots.flashActLink; + + const options = {act: accentedLink}; + const parts = ['artistPage.creditList.flashAct']; + + if ( + slots.dateRangeStart && + slots.dateRangeEnd && + slots.dateRangeStart !== slots.dateRangeEnd + ) { + parts.push('withDateRange'); + options.dateRange = language.formatDateRange(slots.dateRangeStart, slots.dateRangeEnd); + } else if (slots.dateRangeStart || slots.date) { + parts.push('withDate'); + options.date = language.formatDate(slots.dateFirst); + } + + accentedLink = language.formatString(parts.join('.'), options); + break; + } + } + } + + return html.tags([ + html.tag('dt', accentedLink), + html.tag('dd', + html.tag('ul', + slots.items)), + ]); + }, +}; |