diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-06-12 13:16:39 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-12 17:32:56 -0300 |
commit | 2fd2c62a731062ccca8b733dd219b6b93000b550 (patch) | |
tree | c6ad165656ee5130c91dded6182c90e0ed085964 /src/content/dependencies | |
parent | e1548a20e014e157ab218c137d5a9867343fd02e (diff) |
content: generateTrackList: blank if no tracks
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/generateTrackList.js | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/src/content/dependencies/generateTrackList.js b/src/content/dependencies/generateTrackList.js index 3c36d248..4760ff2f 100644 --- a/src/content/dependencies/generateTrackList.js +++ b/src/content/dependencies/generateTrackList.js @@ -5,55 +5,47 @@ export default { extraDependencies: ['html', 'language'], - relations(relation, tracks) { - if (empty(tracks)) { - return {}; - } + relations: (relation, tracks) => ({ + trackLinks: + tracks + .map(track => relation('linkTrack', track)), - return { - trackLinks: - tracks - .map(track => relation('linkTrack', track)), - - contributionLinks: - tracks - .map(track => - (empty(track.artistContribs) - ? null - : track.artistContribs - .map(contrib => relation('linkContribution', contrib)))), - }; - }, + contributionLinks: + tracks + .map(track => + track.artistContribs + .map(contrib => relation('linkContribution', contrib))), + }), slots: { showContribution: {type: 'boolean', default: false}, showIcons: {type: 'boolean', default: false}, }, - generate(relations, slots, {html, language}) { - return ( - html.tag('ul', - stitchArrays({ - trackLink: relations.trackLinks, - contributionLinks: relations.contributionLinks, - }).map(({trackLink, contributionLinks}) => - html.tag('li', - (empty(contributionLinks) - ? trackLink - : language.$('trackList.item.withArtists', { - track: trackLink, - by: - html.tag('span', {class: 'by'}, - html.metatag('chunkwrap', {split: ','}, - language.$('trackList.item.withArtists.by', { - artists: - language.formatConjunctionList( - contributionLinks.map(link => - link.slots({ - showContribution: slots.showContribution, - showIcons: slots.showIcons, - }))), - }))), - })))))); - }, + generate: (relations, slots, {html, language}) => + html.tag('ul', + {[html.onlyIfContent]: true}, + + stitchArrays({ + trackLink: relations.trackLinks, + contributionLinks: relations.contributionLinks, + }).map(({trackLink, contributionLinks}) => + html.tag('li', + (empty(contributionLinks) + ? trackLink + : language.$('trackList.item.withArtists', { + track: trackLink, + by: + html.tag('span', {class: 'by'}, + html.metatag('chunkwrap', {split: ','}, + language.$('trackList.item.withArtists.by', { + artists: + language.formatConjunctionList( + contributionLinks.map(link => + link.slots({ + showContribution: slots.showContribution, + showIcons: slots.showIcons, + }))), + }))), + }))))), }; |