« get me outta code hell

content, css, test: generateAlbumSecondaryNav: new prev/next - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateSecondaryNavParentSiblingsPart.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-08-15 11:44:46 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-11-02 22:25:46 -0300
commitdf1d07633d344e278b4e5d10a2f1629ccb8ef7df (patch)
tree7f7d0311ed3f38f3742a9d1223a87b8375a3dc7a /src/content/dependencies/generateSecondaryNavParentSiblingsPart.js
parente77262e34657164b5c194d2e639ff4ce627134a9 (diff)
content, css, test: generateAlbumSecondaryNav: new prev/next
Diffstat (limited to 'src/content/dependencies/generateSecondaryNavParentSiblingsPart.js')
-rw-r--r--src/content/dependencies/generateSecondaryNavParentSiblingsPart.js103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/content/dependencies/generateSecondaryNavParentSiblingsPart.js b/src/content/dependencies/generateSecondaryNavParentSiblingsPart.js
new file mode 100644
index 00000000..c5f1df84
--- /dev/null
+++ b/src/content/dependencies/generateSecondaryNavParentSiblingsPart.js
@@ -0,0 +1,103 @@
+export default {
+  contentDependencies: [
+    'generateColorStyleAttribute',
+    'generateInterpageDotSwitcher',
+    'generateNextLink',
+    'generatePreviousLink',
+    'linkAlbumDynamically',
+    'linkGroup',
+  ],
+
+  extraDependencies: ['html', 'language'],
+
+  relations: (relation) => ({
+    switcher:
+      relation('generateInterpageDotSwitcher'),
+
+    previousLink:
+      relation('generatePreviousLink'),
+
+    nextLink:
+      relation('generateNextLink'),
+  }),
+
+  slots: {
+    mode: {
+      validate: v => v.is('album', 'track'),
+      default: 'album',
+    },
+
+    attributes: {
+      type: 'attributes',
+      mutable: false,
+    },
+
+    colorStyle: {
+      type: 'html',
+      mutable: true,
+    },
+
+    mainLink: {
+      type: 'html',
+      mutable: true,
+    },
+
+    previousLink: {
+      type: 'html',
+      mutable: false,
+    },
+
+    nextLink: {
+      type: 'html',
+      mutable: false,
+    },
+
+    stringsKey: {
+      type: 'string',
+    },
+
+    mainLinkOption: {
+      type: 'string',
+    },
+  },
+
+  generate: (relations, slots, {html, language}) =>
+    html.tag('span',
+      slots.attributes,
+
+      !html.isBlank(slots.colorStyle) &&
+        slots.colorStyle
+          .slot('context', 'primary-only'),
+
+      language.encapsulate(slots.stringsKey, workingCapsule => {
+        const workingOptions = {};
+
+        workingOptions[slots.mainLinkOption] =
+          slots.mainLink
+            .slot('color', false);
+
+        if (slots.mode === 'album') addPreviousNext: {
+          if (html.isBlank(slots.previousLink) && html.isBlank(slots.nextLink)) {
+            break addPreviousNext;
+          }
+
+          workingCapsule += '.withPreviousNext';
+          workingOptions.previousNext =
+            relations.switcher.slots({
+              links: [
+                relations.previousLink.slots({
+                  id: false,
+                  link: slots.previousLink,
+                }),
+
+                relations.nextLink.slots({
+                  id: false,
+                  link: slots.nextLink,
+                }),
+              ],
+            });
+        }
+
+        return language.$(workingCapsule, workingOptions);
+      })),
+};