« get me outta code hell

content: generateFlashActNavAccent: use dots - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-10-19 22:13:01 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-11-02 22:25:46 -0300
commit047c98a6fd5f488c1d5957add8e0908c24079459 (patch)
tree29860920335fd44a3fbbb3c167f692812117474c /src/content/dependencies
parent3d0ac39a533f41cc2ff43f1a77dbe31c9cdf1fb5 (diff)
content: generateFlashActNavAccent: use dots
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateFlashActNavAccent.js83
1 files 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),
+      ],
+    }),
 };