diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-12-28 21:56:54 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-12-28 21:56:54 -0400 |
commit | 65e77ad3a66cd61910f916a26da1f4ce7be54dcf (patch) | |
tree | 8283884f86b658a4403ab71575974de48ecbb08f /src/page | |
parent | cfefc5017cc418d8356c65e40eb20c70c9afbc88 (diff) |
album page social embeds
Diffstat (limited to 'src/page')
-rw-r--r-- | src/page/album.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/page/album.js b/src/page/album.js index 28c09907..1fc74520 100644 --- a/src/page/album.js +++ b/src/page/album.js @@ -57,6 +57,31 @@ export function write(album, {wikiData}) { const listTag = getAlbumListTag(album); + const getSocialEmbedDescription = ({ + getArtistString: _getArtistString, + language, + }) => { + const hasDuration = albumDuration > 0; + const hasTracks = album.tracks.length > 0; + const hasDate = !!album.date; + if (!hasDuration && !hasTracks && !hasDate) return ''; + + return language.formatString( + 'albumPage.socialEmbed.body' + [ + hasDuration && '.withDuration', + hasTracks && '.withTracks', + hasDate && '.withReleaseDate', + ].filter(Boolean).join(''), + Object.fromEntries([ + hasDuration && + ['duration', language.formatDuration(albumDuration)], + hasTracks && + ['tracks', language.countTracks(album.tracks.length, {unit: true})], + hasDate && + ['date', language.formatDate(album.date)], + ].filter(Boolean))); + }; + const data = { type: 'data', path: ['album', album.directory], @@ -98,6 +123,7 @@ export function write(album, {wikiData}) { type: 'page', path: ['album', album.directory], page: ({ + absoluteTo, fancifyURL, generateAdditionalFilesShortcut, generateAdditionalFilesList, @@ -139,6 +165,25 @@ export function write(album, {wikiData}) { ], }), + socialEmbed: { + heading: + (empty(album.groups) + ? '' + : language.$('albumPage.socialEmbed.heading', { + group: album.groups[0].name, + })), + headingLink: + (empty(album.groups) + ? null + : absoluteTo('localized.album', album.groups[0].directory)), + title: language.$('albumPage.socialEmbed.title', { + album: album.name, + }), + description: getSocialEmbedDescription({getArtistString, language}), + image: '/' + getAlbumCover(album, {to: urls.from('shared.root').to}), + color: album.color, + }, + banner: !empty(album.bannerArtistContribs) && { dimensions: album.bannerDimensions, path: [ |