From e440849fae1f582b053eddf327327ad78bfdc894 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 26 Jan 2024 10:59:32 -0400 Subject: content: generateCoverArtwork: support non-square dimensions --- src/content/dependencies/generateCoverArtwork.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/content') 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'}, -- cgit 1.3.0-6-gf8a5