From 0bfce8e39bf928fb512843db6b4a24fb992dc3c3 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 18 Feb 2024 16:52:07 -0400 Subject: content: image: zero-effort string-form "warnings" slot --- src/content/dependencies/image.js | 12 ++++++++++-- 1 file 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'), -- cgit 1.3.0-6-gf8a5