From cd35aa4215bec35ee5aee112288e2562b2d7237d Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 30 Jul 2023 21:55:05 -0300 Subject: content: image, transformContent: support custom img links --- src/content/dependencies/image.js | 6 +++++- src/content/dependencies/transformContent.js | 4 ++-- src/util/replacer.js | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js index 2fbe118..745dfe9 100644 --- a/src/content/dependencies/image.js +++ b/src/content/dependencies/image.js @@ -33,8 +33,12 @@ export default { thumb: {type: 'string'}, + link: { + validate: v => v.oneOf(v.isBoolean, v.isString), + default: false, + }, + reveal: {type: 'boolean', default: true}, - link: {type: 'boolean', default: false}, lazy: {type: 'boolean', default: false}, square: {type: 'boolean', default: false}, diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js index d003c5b..718b7d1 100644 --- a/src/content/dependencies/transformContent.js +++ b/src/content/dependencies/transformContent.js @@ -336,7 +336,7 @@ export default { ? to('media.path', node.src.slice('media/'.length)) : node.src); - const {width, height} = node; + const {link, width, height} = node; if (node.inline) { return { @@ -353,7 +353,7 @@ export default { data: image.slots({ src, - link: true, + link: link ?? true, width: width ?? null, height: height ?? null, thumb: slots.thumb, diff --git a/src/util/replacer.js b/src/util/replacer.js index 7240940..caf16bb 100644 --- a/src/util/replacer.js +++ b/src/util/replacer.js @@ -392,6 +392,7 @@ export function postprocessImages(inputNodes) { return false; })(); + if (attributes.link) imageNode.link = attributes.link; if (attributes.width) imageNode.width = parseInt(attributes.width); if (attributes.height) imageNode.height = parseInt(attributes.height); -- cgit 1.3.0-6-gf8a5