diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-01-26 10:59:32 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-04-13 15:47:34 -0300 |
commit | e440849fae1f582b053eddf327327ad78bfdc894 (patch) | |
tree | bc1d968e1cf6d463e9669a2fffdbc6d54a7a9dbb /src | |
parent | a8af1e76ec2b0d51d243f68aebf21c64f9f35be6 (diff) |
content: generateCoverArtwork: support non-square dimensions
Diffstat (limited to 'src')
-rw-r--r-- | src/content/dependencies/generateCoverArtwork.js | 20 |
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'}, |