« get me outta code hell

content, css: linkContribution: 'showChronology' basic impl. - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-06-17 21:20:01 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-18 22:56:15 -0300
commit171784feb69f46c6820e65612f9a58a7b9ca7c4e (patch)
tree4f5c69417508db4df6aa2b782eb0137bee3c239e /src/content
parent2ed49fea8ca5c49801e905bacce4c6aa96137867 (diff)
content, css: linkContribution: 'showChronology' basic impl.
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/linkContribution.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/content/dependencies/linkContribution.js b/src/content/dependencies/linkContribution.js
index c17cc45a..aee93d60 100644
--- a/src/content/dependencies/linkContribution.js
+++ b/src/content/dependencies/linkContribution.js
@@ -5,6 +5,7 @@ export default {
     'generateTextWithTooltip',
     'generateTooltip',
     'linkArtist',
+    'linkAnythingMan',
     'linkExternalAsIcon',
   ],
 
@@ -22,6 +23,26 @@ export default {
     relations.tooltip =
       relation('generateTooltip');
 
+    let previous = contribution;
+    while (previous && previous.thing === contribution.thing) {
+      previous = previous.previousBySameArtist;
+    }
+
+    let next = contribution;
+    while (next && next.thing === contribution.thing) {
+      next = next.nextBySameArtist;
+    }
+
+    if (previous) {
+      relations.previousLink =
+        relation('linkAnythingMan', previous.thing);
+    }
+
+    if (next) {
+      relations.nextLink =
+        relation('linkAnythingMan', next.thing);
+    }
+
     if (!empty(contribution.artist.urls)) {
       relations.artistIcons =
         contribution.artist.urls
@@ -41,6 +62,7 @@ export default {
   slots: {
     showContribution: {type: 'boolean', default: false},
     showIcons: {type: 'boolean', default: false},
+    showChronology: {type: 'boolean', default: false},
     preventWrapping: {type: 'boolean', default: true},
 
     iconMode: {
@@ -94,6 +116,29 @@ export default {
           }));
     }
 
+    if (slots.showChronology) {
+      tooltipContent.push(
+        language.encapsulate(capsule, 'chronology', capsule => [
+          html.tag('span', {class: 'chronology-link'},
+            {[html.onlyIfContent]: true},
+
+            language.$(capsule, 'previous', {
+              [language.onlyIfOptions]: ['thing'],
+
+              thing: relations.previousLink,
+            })),
+
+          html.tag('span', {class: 'chronology-link'},
+            {[html.onlyIfContent]: true},
+
+            language.$(capsule, 'next', {
+              [language.onlyIfOptions]: ['thing'],
+
+              thing: relations.nextLink,
+            })),
+        ]));
+    }
+
     // TODO: It probably shouldn't be necessary to do an isBlank call here.
     options.artist =
       (html.isBlank(tooltipContent)