diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-06-18 09:57:51 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-18 22:56:15 -0300 |
commit | 53b652508d83702f9451f0381d2f5a5ba76b7233 (patch) | |
tree | 3b557b211984090c8616df2cadefe5ed2029dcc5 /src/content/dependencies/generateContributionTooltipChronologySection.js | |
parent | 6cbdcc8b041fc8e9a0300d9616ff5dafe0710c07 (diff) |
content: generateContributionTooltip, etc
Diffstat (limited to 'src/content/dependencies/generateContributionTooltipChronologySection.js')
-rw-r--r-- | src/content/dependencies/generateContributionTooltipChronologySection.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/content/dependencies/generateContributionTooltipChronologySection.js b/src/content/dependencies/generateContributionTooltipChronologySection.js new file mode 100644 index 00000000..85b19be9 --- /dev/null +++ b/src/content/dependencies/generateContributionTooltipChronologySection.js @@ -0,0 +1,51 @@ +export default { + contentDependencies: ['linkAnythingMan'], + extraDependencies: ['html', 'language'], + + query(contribution) { + let previous = contribution; + while (previous && previous.thing === contribution.thing) { + previous = previous.previousBySameArtist; + } + + let next = contribution; + while (next && next.thing === contribution.thing) { + next = next.nextBySameArtist; + } + + return {previous, next}; + }, + + relations: (relation, query, _contribution) => ({ + previousLink: + (query.previous + ? relation('linkAnythingMan', query.previous.thing) + : null), + + nextLink: + (query.next + ? relation('linkAnythingMan', query.next.thing) + : null), + }), + + generate: (relations, {html, language}) => + language.encapsulate('misc.artistLink.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, + })), + ]), +}; |