« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateCoverArtwork.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/content/dependencies/generateCoverArtwork.js b/src/content/dependencies/generateCoverArtwork.js
index d0941d2e..0335e54c 100644
--- a/src/content/dependencies/generateCoverArtwork.js
+++ b/src/content/dependencies/generateCoverArtwork.js
@@ -59,9 +59,23 @@ export default {
       validate: v => v.is('primary', 'thumbnail', 'commentary'),
       default: 'primary',
     },
+
+    dimensions: {
+      validate: v => v.isDimensions,
+    },
   },
 
   generate(data, relations, slots, {html}) {
+    const square =
+      (slots.dimensions
+        ? slots.dimensions[0] === slots.dimensions[1]
+        : true);
+
+    const sizeSlots =
+      (square
+        ? {square: true}
+        : {width: slots.dimensions[0], height: slots.dimensions[1]});
+
     switch (slots.mode) {
       case 'primary':
         return html.tags([
@@ -72,7 +86,7 @@ export default {
             thumb: 'medium',
             reveal: true,
             link: true,
-            square: true,
+            ...sizeSlots,
           }),
 
           !empty(relations.tagLinks) &&
@@ -93,7 +107,7 @@ export default {
           thumb: 'small',
           reveal: false,
           link: false,
-          square: true,
+          ...sizeSlots,
         });
 
       case 'commentary':
@@ -104,8 +118,8 @@ export default {
           thumb: 'medium',
           reveal: true,
           link: true,
-          square: true,
           lazy: true,
+          ...sizeSlots,
 
           attributes:
             {class: 'commentary-art'},