« get me outta code hell

content: linkTrackDynamically - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/linkTrackDynamically.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-07 20:47:22 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-16 14:32:35 -0400
commit173ea7144c42e799dc08e1ba4e2a09410223840e (patch)
treee874a1e2aede89b7cdd0b4c96b98eec00f8f05cf /src/content/dependencies/linkTrackDynamically.js
parent8e0a343d1ff83aa67083f5a67a9bd199f3f6ad9c (diff)
content: linkTrackDynamically
Diffstat (limited to 'src/content/dependencies/linkTrackDynamically.js')
-rw-r--r--src/content/dependencies/linkTrackDynamically.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/content/dependencies/linkTrackDynamically.js b/src/content/dependencies/linkTrackDynamically.js
new file mode 100644
index 00000000..242cd4cb
--- /dev/null
+++ b/src/content/dependencies/linkTrackDynamically.js
@@ -0,0 +1,34 @@
+export default {
+  contentDependencies: ['linkTrack'],
+  extraDependencies: ['pagePath'],
+
+  relations: (relation, track) => ({
+    infoLink: relation('linkTrack', track),
+  }),
+
+  data: (track) => ({
+    trackDirectory:
+      track.directory,
+
+    albumDirectory:
+      track.album.directory,
+
+    trackHasCommentary:
+      !!track.commentary,
+  }),
+
+  generate(data, relations, {pagePath}) {
+    if (
+      pagePath[0] === 'albumCommentary' &&
+      pagePath[1] === data.albumDirectory &&
+      data.trackHasCommentary
+    ) {
+      relations.infoLink.setSlots({
+        anchor: true,
+        hash: data.trackDirectory,
+      });
+    }
+
+    return relations.infoLink;
+  },
+};