diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-08-14 12:36:08 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-02 22:25:45 -0300 |
commit | 3d0ac39a533f41cc2ff43f1a77dbe31c9cdf1fb5 (patch) | |
tree | a38573be819f6977a6a6e743d3a140768d0ebf52 /src/content | |
parent | fa950223d7f9531d1c4dbf3fa1235743196d2a84 (diff) |
content: generateFlashNavAccent: update internals + use dots
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/dependencies/generateFlashNavAccent.js | 81 |
1 files changed, 37 insertions, 44 deletions
diff --git a/src/content/dependencies/generateFlashNavAccent.js b/src/content/dependencies/generateFlashNavAccent.js index 55e056dc..0f5d2d6b 100644 --- a/src/content/dependencies/generateFlashNavAccent.js +++ b/src/content/dependencies/generateFlashNavAccent.js @@ -1,16 +1,17 @@ -import {atOffset, empty} from '#sugar'; +import {atOffset} from '#sugar'; export default { contentDependencies: [ - 'generatePreviousNextLinks', + 'generateInterpageDotSwitcher', + 'generateNextLink', + 'generatePreviousLink', 'linkFlash', ], extraDependencies: ['html', 'language', 'wikiData'], - sprawl({flashActData}) { - return {flashActData}; - }, + sprawl: ({flashActData}) => + ({flashActData}), query(sprawl, flash) { // Don't sort chronologically here. The previous/next buttons should match @@ -31,43 +32,35 @@ export default { return {previousFlash, nextFlash}; }, - relations(relation, query) { - const relations = {}; - - if (query.previousFlash || query.nextFlash) { - relations.previousNextLinks = - relation('generatePreviousNextLinks'); - - relations.previousFlashLink = - (query.previousFlash - ? relation('linkFlash', query.previousFlash) - : null); - - relations.nextFlashLink = - (query.nextFlash - ? relation('linkFlash', query.nextFlash) - : null); - } - - return relations; - }, - - generate(relations, {html, language}) { - const {content: previousNextLinks = []} = - relations.previousNextLinks && - relations.previousNextLinks.slots({ - previousLink: relations.previousFlashLink, - nextLink: relations.nextFlashLink, - }); - - 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'), + + previousFlashLink: + (query.previousFlash + ? relation('linkFlash', query.previousFlash) + : null), + + nextFlashLink: + (query.nextFlash + ? relation('linkFlash', query.nextFlash) + : null), + }), + + generate: (relations) => + relations.switcher.slots({ + links: [ + relations.previousLink + .slot('link', relations.previousFlashLink), + + relations.nextLink + .slot('link', relations.nextFlashLink), + ], + }), }; |