« get me outta code hell

content: generate{Previous,Next,PreviousNext}Link - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generatePreviousNextLinks.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-08-14 10:42:19 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-11-02 22:25:43 -0300
commit4ee17a3fc87de8fee776b32854ae5e9cf6b5ef1c (patch)
tree04c34bc82c019b6be5850d3a60c37647ccecbd44 /src/content/dependencies/generatePreviousNextLinks.js
parent3a7e5ebf3adf0232768c667f868dfea615fa161c (diff)
content: generate{Previous,Next,PreviousNext}Link
Diffstat (limited to 'src/content/dependencies/generatePreviousNextLinks.js')
-rw-r--r--src/content/dependencies/generatePreviousNextLinks.js37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/content/dependencies/generatePreviousNextLinks.js b/src/content/dependencies/generatePreviousNextLinks.js
index 9771de39..d9f80849 100644
--- a/src/content/dependencies/generatePreviousNextLinks.js
+++ b/src/content/dependencies/generatePreviousNextLinks.js
@@ -3,8 +3,17 @@ export default {
   // for inclusion in a page's navigation bar. Include with other links
   // in the nav bar and then join them all as a unit list, for example.
 
+  contentDependencies: ['generateNextLink', 'generatePreviousLink'],
   extraDependencies: ['html', 'language'],
 
+  relations: (relation) => ({
+    previousLink:
+      relation('generatePreviousLink'),
+
+    nextLink:
+      relation('generateNextLink'),
+  }),
+
   slots: {
     previousLink: {
       type: 'html',
@@ -22,27 +31,25 @@ export default {
     },
   },
 
-  generate(slots, {html, language}) {
+  generate(relations, slots, {html, language}) {
     const previousNext = [];
 
+    relations.previousLink.setSlots({
+      link: slots.previousLink,
+      id: slots.id,
+    });
+
+    relations.nextLink.setSlots({
+      link: slots.nextLink,
+      id: slots.id,
+    });
+
     if (!html.isBlank(slots.previousLink)) {
-      previousNext.push(
-        slots.previousLink.slots({
-          tooltipStyle: 'browser',
-          color: false,
-          attributes: {id: slots.id && 'previous-button'},
-          content: language.$('misc.nav.previous'),
-        }));
+      previousNext.push(relations.previousLink);
     }
 
     if (!html.isBlank(slots.nextLink)) {
-      previousNext.push(
-        slots.nextLink.slots({
-          tooltipStyle: 'browser',
-          color: false,
-          attributes: {id: slots.id && 'next-button'},
-          content: language.$('misc.nav.next'),
-        }));
+      previousNext.push(relations.nextLink);
     }
 
     return previousNext;