From 171784feb69f46c6820e65612f9a58a7b9ca7c4e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 17 Jun 2024 21:20:01 -0300 Subject: content, css: linkContribution: 'showChronology' basic impl. --- src/content/dependencies/linkContribution.js | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/content/dependencies/linkContribution.js') 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) -- cgit 1.3.0-6-gf8a5