diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-04-01 09:16:33 -0300 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-04-01 09:16:33 -0300 |
| commit | 2d5330e7ed792bed36cfd886b48804657b8a2c99 (patch) | |
| tree | fc83a11bfed17c25ef716354e20a85c18460467f /src/content/dependencies | |
| parent | 1c0e7ed52e63ab60764ddd4108dabe1b40fa34ac (diff) | |
content: generateAlbumArtInfoBox: wiki file links preview
Diffstat (limited to 'src/content/dependencies')
| -rw-r--r-- | src/content/dependencies/generateAlbumArtInfoBox.js | 118 |
1 files changed, 98 insertions, 20 deletions
diff --git a/src/content/dependencies/generateAlbumArtInfoBox.js b/src/content/dependencies/generateAlbumArtInfoBox.js index 5491192a..a3b4c02d 100644 --- a/src/content/dependencies/generateAlbumArtInfoBox.js +++ b/src/content/dependencies/generateAlbumArtInfoBox.js @@ -1,3 +1,7 @@ +import {basename} from 'node:path'; + +import {empty} from '#sugar'; + export default { relations: (relation, album) => ({ wallpaperArtistContributionsLine: @@ -11,26 +15,100 @@ export default { ? relation('generateReleaseInfoContributionsLine', album.bannerArtwork.artistContribs) : null), + + linkTemplate: + relation('linkTemplate'), }), - generate: (relations, {html, language}) => - language.encapsulate('releaseInfo', capsule => - html.tag('div', {class: 'album-art-info'}, - {[html.onlyIfContent]: true}, - - html.tag('p', - {[html.onlyIfContent]: true}, - {[html.joinChildren]: html.tag('br')}, - - [ - relations.wallpaperArtistContributionsLine?.slots({ - stringKey: capsule + '.wallpaperArtBy', - chronologyKind: 'wallpaperArt', - }), - - relations.bannerArtistContributionsLine?.slots({ - stringKey: capsule + '.bannerArtBy', - chronologyKind: 'bannerArt', - }), - ]))), + data: (album) => ({ + wallpaperImagePath: + (album.wallpaperArtwork && empty(album.wallpaperParts) + ? album.wallpaperArtwork.path + : null), + + wallpaperPartPaths: + album.wallpaperParts + .filter(part => part.asset) + .map(part => ['media.albumWallpaperPart', album.directory, part.asset]), + + bannerImagePath: + (album.bannerArtwork + ? album.bannerArtwork.path + : null), + }), + + generate: (data, relations, {html, language}) => + html.tag('div', {class: 'album-art-info'}, + {[html.onlyIfContent]: true}, + {[html.joinChildren]: html.tag('hr', {class: 'cute'})}, + + [ + language.encapsulate('releaseInfo', capsule => + html.tag('p', + {[html.onlyIfContent]: true}, + {[html.joinChildren]: html.tag('br')}, + + [ + relations.wallpaperArtistContributionsLine?.slots({ + stringKey: capsule + '.wallpaperArtBy', + chronologyKind: 'wallpaperArt', + }), + + relations.bannerArtistContributionsLine?.slots({ + stringKey: capsule + '.bannerArtBy', + chronologyKind: 'bannerArt', + }), + ])), + + language.encapsulate('misc.downloadLayoutMedia', downloadCapsule => + html.tag('p', + {[html.onlyIfContent]: true}, + {[html.joinChildren]: html.tag('br')}, + + [ + language.encapsulate(downloadCapsule, workingCapsule => { + const workingOptions = {}; + + let any = false; + + if (data.wallpaperImagePath) { + any = true; + workingCapsule += '.withWallpaper'; + workingOptions.wallpaper = + relations.linkTemplate.clone().slots({ + path: data.wallpaperImagePath, + content: language.$(downloadCapsule, 'wallpaper'), + }); + } + + if (data.bannerImagePath) { + any = true; + workingCapsule += '.withBanner'; + workingOptions.banner = + relations.linkTemplate.clone().slots({ + path: data.bannerImagePath, + content: language.$(downloadCapsule, 'banner'), + }); + } + + if (any) { + return language.$(workingCapsule, workingOptions); + } else { + return html.blank(); + } + }), + + language.$(downloadCapsule, 'withWallpaperParts', { + [language.onlyIfOptions]: ['parts'], + + parts: + language.formatUnitList( + data.wallpaperPartPaths.map(path => + relations.linkTemplate.clone().slots({ + path, + content: language.sanitize(basename(path.at(-1))), + }))), + }), + ])), + ]), }; |