From 047c98a6fd5f488c1d5957add8e0908c24079459 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 19 Oct 2024 22:13:01 -0300 Subject: content: generateFlashActNavAccent: use dots --- .../dependencies/generateFlashActNavAccent.js | 83 ++++++++++------------ 1 file changed, 38 insertions(+), 45 deletions(-) diff --git a/src/content/dependencies/generateFlashActNavAccent.js b/src/content/dependencies/generateFlashActNavAccent.js index 424948f9..c4ec77b8 100644 --- a/src/content/dependencies/generateFlashActNavAccent.js +++ b/src/content/dependencies/generateFlashActNavAccent.js @@ -1,16 +1,17 @@ -import {atOffset, empty} from '#sugar'; +import {atOffset} from '#sugar'; export default { contentDependencies: [ - 'generatePreviousNextLinks', + 'generateInterpageDotSwitcher', + 'generateNextLink', + 'generatePreviousLink', 'linkFlashAct', ], - extraDependencies: ['html', 'language', 'wikiData'], + extraDependencies: ['wikiData'], - sprawl({flashActData}) { - return {flashActData}; - }, + sprawl: ({flashActData}) => + ({flashActData}), query(sprawl, flashAct) { // Like with generateFlashNavAccent, don't sort chronologically here. @@ -29,43 +30,35 @@ export default { return {previousFlashAct, nextFlashAct}; }, - relations(relation, query) { - const relations = {}; - - if (query.previousFlashAct || query.nextFlashAct) { - relations.previousNextLinks = - relation('generatePreviousNextLinks'); - - relations.previousFlashActLink = - (query.previousFlashAct - ? relation('linkFlashAct', query.previousFlashAct) - : null); - - relations.nextFlashActLink = - (query.nextFlashAct - ? relation('linkFlashAct', query.nextFlashAct) - : null); - } - - return relations; - }, - - generate(relations, {html, language}) { - const {content: previousNextLinks = []} = - relations.previousNextLinks && - relations.previousNextLinks.slots({ - previousLink: relations.previousFlashActLink, - nextLink: relations.nextFlashActLink, - }); - - const allLinks = [ - ...previousNextLinks, - ].filter(Boolean); - - if (empty(allLinks)) { - return html.blank(); - } - - return `(${language.formatUnitList(allLinks)})`; - }, + relations: (relation, query) => ({ + switcher: + relation('generateInterpageDotSwitcher'), + + previousLink: + relation('generatePreviousLink'), + + nextLink: + relation('generateNextLink'), + + previousFlashActLink: + (query.previousFlashAct + ? relation('linkFlashAct', query.previousFlashAct) + : null), + + nextFlashActLink: + (query.nextFlashAct + ? relation('linkFlashAct', query.nextFlashAct) + : null), + }), + + generate: (relations) => + relations.switcher.slots({ + links: [ + relations.previousLink + .slot('link', relations.previousFlashActLink), + + relations.nextLink + .slot('link', relations.nextFlashActLink), + ], + }), }; -- cgit 1.3.0-6-gf8a5