From 5706477b7132f7ae2ec72000542a81d6ef2c0c51 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 1 Jun 2021 14:17:53 -0300 Subject: embed to() inside banner & cover image code --- src/upd8.js | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/upd8.js b/src/upd8.js index c5f97926..94fab3b8 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -2007,13 +2007,18 @@ writePage.html = (pageFn, { nav.content ]); - const bannerHTML = banner.position && banner.src && html.tag('div', + const bannerSrc = ( + banner.src ? banner.src : + banner.path ? to(...banner.path) : + null); + + const bannerHTML = banner.position && bannerSrc && html.tag('div', { id: 'banner', class: banner.classes }, html.tag('img', { - src: banner.src, + src: bannerSrc, alt: banner.alt, width: banner.dimensions[0] || 1100, height: banner.dimensions[1] || 200 @@ -2630,13 +2635,22 @@ function getRevealStringFromTags(tags, {strings}) { } function generateCoverLink({ - link, strings, wikiData, + link, strings, to, wikiData, src, + path, alt, tags = [] }) { const { wikiInfo } = wikiData; + if (!src && path) { + src = to(...path); + } + + if (!src) { + throw new Error(`Expected src or path`); + } + return fixWS`
${img({ @@ -2744,7 +2758,6 @@ function writeAlbumPage(album, {wikiData}) { getArtistString, link, strings, - to, transformMultiline }) => ({ title: strings('albumPage.title', {album: album.name}), @@ -2755,7 +2768,7 @@ function writeAlbumPage(album, {wikiData}) { banner: album.bannerArtists && { dimensions: album.bannerDimensions, - src: to('media.albumBanner', album.directory), + path: ['media.albumBanner', album.directory], alt: strings('misc.alt.albumBanner'), position: 'top' }, @@ -2763,7 +2776,7 @@ function writeAlbumPage(album, {wikiData}) { main: { content: fixWS` ${generateCoverLink({ - src: to('media.albumCover', album.directory), + path: ['media.albumCover', album.directory], alt: strings('misc.alt.albumCover'), tags: album.artTags })} @@ -2807,9 +2820,9 @@ function writeAlbumPage(album, {wikiData}) {

${commentaryEntries && `

${ strings('releaseInfo.viewCommentary', { - link: `${ - strings('releaseInfo.viewCommentary.link') - }` + link: link.albumCommentary(album, { + text: strings('releaseInfo.viewCommentary.link') + }) }) }

`} ${album.urls.length && `

${ @@ -3016,7 +3029,7 @@ function writeTrackPage(track, {wikiData}) { banner: album.bannerArtists && { classes: ['dim'], dimensions: album.bannerDimensions, - src: to('media.albumBanner', album.directory), + path: ['media.albumBanner', album.directory], alt: strings('misc.alt.albumBanner'), position: 'bottom' }, @@ -3421,7 +3434,7 @@ function writeArtistPage(artist, {wikiData}) { main: { content: fixWS` ${artist.hasAvatar && generateCoverLink({ - src: to('localized.artistAvatar', artist.directory), + path: ['localized.artistAvatar', artist.directory], alt: strings('misc.alt.artistAvatar') })}

${strings('artistPage.title', {artist: name})}

@@ -6462,6 +6475,7 @@ async function main() { [bindOpts.bindIndex]: 0, link: bound.link, strings, + to, wikiData }); -- cgit 1.3.0-6-gf8a5