« get me outta code hell

content, wiki-data: sameDayAs - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateMusicVideoDateLine.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-03-26 16:44:07 -0300
committer(quasar) nebula <qznebula@protonmail.com>2026-03-26 16:44:07 -0300
commit01bd5cec3a83e9ced7715954e76dd820aa7e91dd (patch)
tree2a0417a4ba60f2969c6c29a1352883a4d68b64d6 /src/content/dependencies/generateMusicVideoDateLine.js
parent4225157ef21e584037efb816651608d8aa269025 (diff)
content, wiki-data: sameDayAs
Diffstat (limited to 'src/content/dependencies/generateMusicVideoDateLine.js')
-rw-r--r--src/content/dependencies/generateMusicVideoDateLine.js39
1 files changed, 9 insertions, 30 deletions
diff --git a/src/content/dependencies/generateMusicVideoDateLine.js b/src/content/dependencies/generateMusicVideoDateLine.js
index 98992584..7b8b57f7 100644
--- a/src/content/dependencies/generateMusicVideoDateLine.js
+++ b/src/content/dependencies/generateMusicVideoDateLine.js
@@ -1,27 +1,4 @@
-function sameDay(musicVideo, thing) {
-  if (!musicVideo.dateIsSpecified) return null;
-
-  const compare = (a, b) =>
-    a && b &&
-    a.toDateString() === b.toDateString();
-
-  const album = thing.isTrack ? thing.album : thing;
-  const track = thing.isTrack ? thing : null;
-
-  if (compare(musicVideo.date, album.date)) {
-    if (album.style === 'single') {
-      return 'single';
-    } else {
-      return 'album';
-    }
-  }
-
-  if (compare(musicVideo.date, track?.date)) {
-    return 'track';
-  }
-
-  return null;
-}
+import {sameDayAs} from '#wiki-data';
 
 export default {
   data: (musicVideo, thing) => ({
@@ -31,22 +8,24 @@ export default {
     dateIsSpecified:
       musicVideo.dateIsSpecified,
 
-    sameDay:
-      sameDay(musicVideo, thing),
+    sameDayAs:
+      (musicVideo.dateIsSpecified
+        ? sameDayAs(musicVideo.date, thing)
+        : null),
   }),
 
   generate: (data, {language}) =>
     language.encapsulate('misc.musicVideo.date', capsule => [
-      data.sameDay === 'album' &&
+      data.sameDayAs === 'album' &&
         language.$(capsule, 'sameDayAsAlbum'),
 
-      data.sameDay === 'single' &&
+      data.sameDayAs === 'single' &&
         language.$(capsule, 'sameDayAsSingle'),
 
-      data.sameDay === 'track' &&
+      data.sameDayAs === 'track' &&
         language.$(capsule, 'sameDayAsTrack'),
 
-      data.sameDay === null &&
+      data.sameDayAs === null &&
       data.dateIsSpecified &&
         language.$(capsule, {
           date: