« get me outta code hell

content: general multiple artworks integration - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/linkReferencingArtworks.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-04-10 15:05:56 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-10 16:02:44 -0300
commitb9d1e8d935f7e3e833ccac1fa07bcdf196d7bdc8 (patch)
tree8ce9b830fa3c21865dd74e396ef9717a4297e821 /src/content/dependencies/linkReferencingArtworks.js
parent8424a3d380284f2e26b6057a500a69e53dc0b757 (diff)
content: general multiple artworks integration
Diffstat (limited to 'src/content/dependencies/linkReferencingArtworks.js')
-rw-r--r--src/content/dependencies/linkReferencingArtworks.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/content/dependencies/linkReferencingArtworks.js b/src/content/dependencies/linkReferencingArtworks.js
new file mode 100644
index 00000000..0cfca4db
--- /dev/null
+++ b/src/content/dependencies/linkReferencingArtworks.js
@@ -0,0 +1,24 @@
+import Thing from '#thing';
+
+export default {
+  contentDependencies: [
+    'linkAlbumReferencingArtworks',
+    'linkTrackReferencingArtworks',
+  ],
+
+  query: (artwork) => ({
+    referenceType:
+      artwork.thing.constructor[Thing.referenceType],
+  }),
+
+  relations: (relation, query, artwork) => ({
+    link:
+      (query.referenceType === 'album'
+        ? relation('linkAlbumReferencingArtworks', artwork.thing)
+     : query.referenceType === 'track'
+        ? relation('linkTrackReferencingArtworks', artwork.thing)
+        : null),
+  }),
+
+  generate: (relations) => relations.link,
+};