« get me outta code hell

content: generateChronologyLinks, generatePreviousNextLinks - 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>2023-04-15 19:50:02 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-04-15 19:50:02 -0300
commited422988035ce2e67464c544267adce4df4f5f35 (patch)
tree3e89b89301cb5bab4e9558c9f9ad6343bec850e1 /src/content/dependencies/generatePreviousNextLinks.js
parent60e85440588fa9c52ae2d856c1e53126935222a4 (diff)
content: generateChronologyLinks, generatePreviousNextLinks
Diffstat (limited to 'src/content/dependencies/generatePreviousNextLinks.js')
-rw-r--r--src/content/dependencies/generatePreviousNextLinks.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/content/dependencies/generatePreviousNextLinks.js b/src/content/dependencies/generatePreviousNextLinks.js
new file mode 100644
index 00000000..42b2c42b
--- /dev/null
+++ b/src/content/dependencies/generatePreviousNextLinks.js
@@ -0,0 +1,36 @@
+export default {
+  // Returns an array with the slotted previous and next links, prepared
+  // 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.
+
+  extraDependencies: ['html', 'language'],
+
+  generate({html, language}) {
+    return html.template({
+      annotation: `generatePreviousNextLinks`,
+
+      slots: {
+        previousLink: {type: 'html'},
+        nextLink: {type: 'html'},
+      },
+
+      content(slots) {
+        return [
+          !html.isBlank(slots.previousLink) &&
+            slots.previousLink.slots({
+              tooltip: true,
+              attributes: {id: 'previous-button'},
+              content: language.$('misc.nav.previous'),
+            }),
+
+          !html.isBlank(slots.nextLink) &&
+            slots.nextLink?.slots({
+              tooltip: true,
+              attributes: {id: 'next-button'},
+              content: language.$('misc.nav.next'),
+            }),
+        ].filter(Boolean);
+      },
+    });
+  },
+};