« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateContributionTooltipChronologySection.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateContributionTooltipChronologySection.js')
-rw-r--r--src/content/dependencies/generateContributionTooltipChronologySection.js24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/content/dependencies/generateContributionTooltipChronologySection.js b/src/content/dependencies/generateContributionTooltipChronologySection.js
index 78c9051c..378c0e1c 100644
--- a/src/content/dependencies/generateContributionTooltipChronologySection.js
+++ b/src/content/dependencies/generateContributionTooltipChronologySection.js
@@ -1,3 +1,19 @@
+import Thing from '#thing';
+
+function getName(thing) {
+  if (!thing) {
+    return null;
+  }
+
+  const referenceType = thing.constructor[Thing.referenceType];
+
+  if (referenceType === 'artwork') {
+    return thing.thing.name;
+  }
+
+  return thing.name;
+}
+
 export default {
   contentDependencies: ['linkAnythingMan'],
   extraDependencies: ['html', 'language'],
@@ -30,14 +46,10 @@ export default {
 
   data: (query, _contribution) => ({
     previousName:
-      (query.previous
-        ? query.previous.thing.name
-        : null),
+      getName(query.previous?.thing),
 
     nextName:
-      (query.next
-        ? query.next.thing.name
-        : null),
+      getName(query.next?.thing),
   }),
 
   slots: {