diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-09-11 17:30:55 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-09-11 17:32:22 -0300 |
commit | 2da0d55d67c099defa7058dcb558f6ea7e0d2651 (patch) | |
tree | 400635bba0c2097c99bd12cf0210c6ba1c57633d /src | |
parent | f198626619b9dba45156632d1d81eced1192bd38 (diff) |
content: generateTrackSocialEmbedDescription: implement this
Geez
Diffstat (limited to 'src')
-rw-r--r-- | src/content/dependencies/generateTrackSocialEmbed.js | 18 | ||||
-rw-r--r-- | src/content/dependencies/generateTrackSocialEmbedDescription.js | 73 |
2 files changed, 40 insertions, 51 deletions
diff --git a/src/content/dependencies/generateTrackSocialEmbed.js b/src/content/dependencies/generateTrackSocialEmbed.js index 9868f0e2..d8e21e38 100644 --- a/src/content/dependencies/generateTrackSocialEmbed.js +++ b/src/content/dependencies/generateTrackSocialEmbed.js @@ -47,6 +47,9 @@ export default { track: data.trackName, }), + description: + relations.description, + headingContent: language.$(embedCapsule, 'heading', { album: data.albumName, @@ -69,18 +72,3 @@ export default { : null), })), }; - -/* - socialEmbed: { - heading: language.$('trackPage.socialEmbed.heading', { - album: track.album.name, - }), - headingLink: absoluteTo('localized.album', album.directory), - title: language.$('trackPage.socialEmbed.title', { - track: track.name, - }), - description: getSocialEmbedDescription({getArtistString, language}), - image: '/' + getTrackCover(track, {to: urls.from('shared.root').to}), - color: track.color, - }, -*/ diff --git a/src/content/dependencies/generateTrackSocialEmbedDescription.js b/src/content/dependencies/generateTrackSocialEmbedDescription.js index cf21eadf..4706aa26 100644 --- a/src/content/dependencies/generateTrackSocialEmbedDescription.js +++ b/src/content/dependencies/generateTrackSocialEmbedDescription.js @@ -1,38 +1,39 @@ +import {empty} from '#sugar'; + export default { - generate() { - }, -}; + extraDependencies: ['html', 'language'], + + data: (track) => ({ + artistNames: + track.artistContribs + .map(contrib => contrib.artist.name), + + coverArtistNames: + track.coverArtistContribs + .map(contrib => contrib.artist.name), + }), -/* - const getSocialEmbedDescription = ({ - getArtistString: _getArtistString, - language, - }) => { - const hasArtists = !empty(track.artistContribs); - const hasCoverArtists = !empty(track.coverArtistContribs); - const getArtistString = (contribs) => - _getArtistString(contribs, { - // We don't want to put actual HTML tags in social embeds (sadly - // they don't get parsed and displayed, generally speaking), so - // override the link argument so that artist "links" just show - // their names. - link: {artist: (artist) => artist.name}, - }); - if (!hasArtists && !hasCoverArtists) return ''; - return language.formatString( - 'trackPage.socialEmbed.body' + - [hasArtists && '.withArtists', hasCoverArtists && '.withCoverArtists'] - .filter(Boolean) - .join(''), - Object.fromEntries( - [ - hasArtists && ['artists', getArtistString(track.artistContribs)], - hasCoverArtists && [ - 'coverArtists', - getArtistString(track.coverArtistContribs), - ], - ].filter(Boolean) - ) - ); - }; -*/ + generate: (data, {html, language}) => + language.encapsulate('trackPage.socialEmbed.body', baseCapsule => + language.encapsulate(baseCapsule, workingCapsule => { + const workingOptions = {}; + + if (!empty(data.artistNames)) { + workingCapsule += '.withArtists'; + workingOptions.artists = + language.formatConjunctionList(data.artistNames); + } + + if (!empty(data.coverArtistNames)) { + workingCapsule += '.withCoverArtists'; + workingOptions.coverArtists = + language.formatConjunctionList(data.coverArtistNames); + } + + if (workingCapsule === baseCapsule) { + return html.blank(); + } else { + return language.$(workingCapsule, workingOptions); + } + })), +}; |