« 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/generateAlbumSocialEmbed.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateAlbumSocialEmbed.js')
-rw-r--r--src/content/dependencies/generateAlbumSocialEmbed.js73
1 files changed, 35 insertions, 38 deletions
diff --git a/src/content/dependencies/generateAlbumSocialEmbed.js b/src/content/dependencies/generateAlbumSocialEmbed.js
index 079899d3..d8f7e9c0 100644
--- a/src/content/dependencies/generateAlbumSocialEmbed.js
+++ b/src/content/dependencies/generateAlbumSocialEmbed.js
@@ -2,18 +2,20 @@ import {empty} from '../../util/sugar.js';
 
 export default {
   contentDependencies: [
+    'generateSocialEmbed',
     'generateAlbumSocialEmbedDescription',
   ],
 
   extraDependencies: ['absoluteTo', 'language', 'urls'],
 
   relations(relation, album) {
-    const relations = {};
+    return {
+      socialEmbed:
+        relation('generateSocialEmbed'),
 
-    relations.description =
-      relation('generateAlbumSocialEmbedDescription', album);
-
-    return relations;
+      description:
+        relation('generateAlbumSocialEmbedDescription', album),
+    };
   },
 
   data(album) {
@@ -35,43 +37,38 @@ export default {
     }
 
     data.albumName = album.name;
-    data.albumColor = album.color;
 
     return data;
   },
 
   generate(data, relations, {absoluteTo, language, urls}) {
-    const socialEmbed = {};
-
-    if (data.hasHeading) {
-      socialEmbed.heading =
-        language.$('albumPage.socialEmbed.heading', {
-          group: data.headingGroupName,
-        });
-
-      socialEmbed.headingLink =
-        absoluteTo('localized.album', data.headingGroupDirectory);
-    } else {
-      socialEmbed.heading = '';
-      socialEmbed.headingLink = null;
-    }
-
-    socialEmbed.title =
-      language.$('albumPage.socialEmbed.title', {
-        album: data.albumName,
-      });
-
-    socialEmbed.description = relations.description;
-
-    if (data.hasImage) {
-      const imagePath = urls
-        .from('shared.root')
-        .to('media.albumCover', data.coverArtDirectory, data.coverArtFileExtension);
-      socialEmbed.image = '/' + imagePath;
-    }
-
-    socialEmbed.color = data.albumColor;
-
-    return socialEmbed;
+    return relations.socialEmbed.slots({
+      title:
+        language.$('albumPage.socialEmbed.title', {
+          album: data.albumName,
+        }),
+
+      description: relations.description,
+
+      headingContent:
+        (data.hasHeading
+          ? language.$('albumPage.socialEmbed.heading', {
+              group: data.headingGroupName,
+            })
+          : null),
+
+      headingLink:
+        (data.hasHeading
+          ? absoluteTo('localized.groupGallery', data.headingGroupDirectory)
+          : null),
+
+      imagePath:
+        (data.hasImage
+          ? '/' +
+            urls
+              .from('shared.root')
+              .to('media.albumCover', data.coverArtDirectory, data.coverArtFileExtension)
+          : null),
+    });
   },
 };