diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-01-17 18:54:29 -0400 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-01-17 18:54:29 -0400 |
| commit | 85fa29d1cef35f7b3ba977b35dc913d39d3268be (patch) | |
| tree | e788954c6a87f512a3571311c54f944d5f444f11 | |
| parent | 28319f6e7302be38db45e85767b156fe4496e13f (diff) | |
content, data: generateMusicVideo: same day as album/single/track
| -rw-r--r-- | src/content/dependencies/generateMusicVideo.js | 37 | ||||
| -rw-r--r-- | src/data/things/music-video.js | 18 | ||||
| -rw-r--r-- | src/static/css/site.css | 2 | ||||
| -rw-r--r-- | src/strings-default.yaml | 9 |
4 files changed, 61 insertions, 5 deletions
diff --git a/src/content/dependencies/generateMusicVideo.js b/src/content/dependencies/generateMusicVideo.js index b3171716..628c1a17 100644 --- a/src/content/dependencies/generateMusicVideo.js +++ b/src/content/dependencies/generateMusicVideo.js @@ -14,12 +14,34 @@ export default { relation('generateArtistCredit', musicVideo.contributorContribs, []), }), - data: (musicVideo, _track) => ({ + data: (musicVideo, track) => ({ label: musicVideo.label, url: musicVideo.url, + + sameDay: + (() => { + if (!musicVideo.dateIsSpecified) return null; + + const compare = (a, b) => + a.toDateString() === b.toDateString(); + + if (compare(musicVideo.date, track.album.date)) { + if (track.album.style === 'single') { + return 'single'; + } else { + return 'album'; + } + } + + if (compare(musicVideo.date, track.date)) { + return 'track'; + } + + return null; + })(), }), generate: (data, relations, {language, html}) => @@ -41,7 +63,7 @@ export default { link: data.url, }), - html.tag('p', {class: 'music-video-credits'}, + html.tag('p', {class: 'music-video-info'}, {[html.joinChildren]: html.tag('br')}, [ @@ -50,6 +72,17 @@ export default { relations.releaseLine), + language.encapsulate(capsule, 'date', capsule => [ + data.sameDay == 'album' && + language.$(capsule, 'sameDayAsAlbum'), + + data.sameDay == 'single' && + language.$(capsule, 'sameDayAsTrack'), + + data.sameDay === 'track' && + language.$(capsule, 'sameDayAsTrack'), + ]), + language.encapsulate(capsule, 'contributorsLine', capsule => language.$(capsule, { [language.onlyIfOptions]: ['credit'], diff --git a/src/data/things/music-video.js b/src/data/things/music-video.js index 6c1e3ba6..f8baa2a2 100644 --- a/src/data/things/music-video.js +++ b/src/data/things/music-video.js @@ -7,11 +7,16 @@ import Thing from '#thing'; import {isDate, isStringNonEmpty, isURL} from '#validators'; import {parseContributors, parseDate} from '#yaml'; -import {exposeConstant, exposeUpdateValueOrContinue} - from '#composite/control-flow'; import {constituteFrom} from '#composite/wiki-data'; import { + exposeConstant, + exposeDependency, + exposeUpdateValueOrContinue, + withResultOfAvailabilityCheck, +} from '#composite/control-flow'; + +import { contributionList, dimensions, directory, @@ -66,6 +71,15 @@ export class MusicVideo extends Thing { // Update only find: soupyFind(), + + // Expose only + + isMusicVideo: exposeConstant(V(true)), + + dateIsSpecified: [ + withResultOfAvailabilityCheck('_date'), + exposeDependency('#availability'), + ], }); static [Thing.yamlDocumentSpec] = { diff --git a/src/static/css/site.css b/src/static/css/site.css index 8390a0a7..806eac3a 100644 --- a/src/static/css/site.css +++ b/src/static/css/site.css @@ -1897,7 +1897,7 @@ p.image-details.origin-details .filename-line { text-align: center; } -.music-video .music-video-credits { +.music-video .music-video-info { margin: 5px 5px 6px; } diff --git a/src/strings-default.yaml b/src/strings-default.yaml index 4ddd6e48..8fdc06d3 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -1013,6 +1013,15 @@ misc: date: >- Released {DATE} + date.sameDayAsTrack: >- + Released alongside this track + + date.sameDayAsAlbum: >- + Released alongside this album + + date.sameDayAsSingle: >- + Released alongside this single + contributorsLine: >- Contributors: {CREDIT} |