« get me outta code hell

content: image: zero-effort string-form "warnings" slot - 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>2024-02-18 16:52:07 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-02-18 16:52:07 -0400
commit0bfce8e39bf928fb512843db6b4a24fb992dc3c3 (patch)
treeb26620360ab7b4160be638d475d554a799790863 /src
parent5deabd42ad8ca2fc049a4ccb24a7892b0dcc7356 (diff)
content: image: zero-effort string-form "warnings" slot
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/image.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js
index 1582d3f4..db307a6b 100644
--- a/src/content/dependencies/image.js
+++ b/src/content/dependencies/image.js
@@ -55,6 +55,10 @@ export default {
       validate: v => v.isColor,
     },
 
+    warnings: {
+      validate: v => v.looseArrayOf(v.isString),
+    },
+
     reveal: {type: 'boolean', default: true},
     lazy: {type: 'boolean', default: false},
     square: {type: 'boolean', default: false},
@@ -120,11 +124,15 @@ export default {
       !isMissingImageFile &&
       (typeof slots.link === 'string' || slots.link);
 
+    const contentWarnings =
+      slots.warnings ??
+      data.contentWarnings;
+
     const willReveal =
       slots.reveal &&
       originalSrc &&
       !isMissingImageFile &&
-      !empty(data.contentWarnings);
+      !empty(contentWarnings);
 
     const willSquare = slots.square;
 
@@ -159,7 +167,7 @@ export default {
 
         html.tag('span', {class: 'reveal-warnings'},
           language.$('misc.contentWarnings.warnings', {
-            warnings: language.formatUnitList(data.contentWarnings),
+            warnings: language.formatUnitList(contentWarnings),
           })),
 
         html.tag('br'),