« get me outta code hell

data: Artwork.style - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-08-13 05:50:01 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-08-13 05:50:01 -0300
commit02bde385e5ec21c12750099aaae4ac1600b36f50 (patch)
tree7cd538c88b46eb469ef9995d56b608ff948ff9e5 /src
parent789ffc7f759ab51ff874f2e12a009a7fdd44baa9 (diff)
data: Artwork.style preview
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateCoverArtwork.js11
-rw-r--r--src/content/dependencies/image.js8
-rw-r--r--src/data/things/artwork.js4
3 files changed, 23 insertions, 0 deletions
diff --git a/src/content/dependencies/generateCoverArtwork.js b/src/content/dependencies/generateCoverArtwork.js
index 78a6103b..f9e942ff 100644
--- a/src/content/dependencies/generateCoverArtwork.js
+++ b/src/content/dependencies/generateCoverArtwork.js
@@ -44,6 +44,9 @@ export default {
 
     dimensions:
       artwork.dimensions,
+
+    style:
+      artwork.style,
   }),
 
   slots: {
@@ -73,6 +76,14 @@ export default {
   generate(data, relations, slots, {html}) {
     const {image} = relations;
 
+    const imgAttributes = html.attributes();
+
+    if (data.style) {
+      imgAttributes.add('style', data.style.split('\n').join(' '));
+    }
+
+    image.setSlot('imgAttributes', imgAttributes);
+
     image.setSlot('alt', slots.alt);
 
     const square =
diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js
index bf47b14f..2ffa4c48 100644
--- a/src/content/dependencies/image.js
+++ b/src/content/dependencies/image.js
@@ -60,6 +60,12 @@ export default {
       mutable: false,
     },
 
+    // Added to the <img>.
+    imgAttributes: {
+      type: 'attributes',
+      mutable: false,
+    },
+
     // Added to the <img> itself.
     alt: {type: 'string'},
 
@@ -141,6 +147,8 @@ export default {
     const imgAttributes = html.attributes([
       {class: 'image'},
 
+      slots.imgAttributes,
+
       slots.alt && {alt: slots.alt},
 
       dimensions &&
diff --git a/src/data/things/artwork.js b/src/data/things/artwork.js
index c54bcced..6e8f5fee 100644
--- a/src/data/things/artwork.js
+++ b/src/data/things/artwork.js
@@ -208,6 +208,8 @@ export class Artwork extends Thing {
       }),
     ],
 
+    style: simpleString(),
+
     artTagsFromThingProperty: simpleString(),
 
     artTags: [
@@ -412,6 +414,8 @@ export class Artwork extends Thing {
         transform: parseContributors,
       },
 
+      'Style': {property: 'style'},
+
       'Tags': {property: 'artTags'},
 
       'Referenced Artworks': {