« get me outta code hell

content: transformContent: let inline images link to things - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-03-10 12:52:55 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-03-31 19:19:46 -0300
commit4d4f858a698b1276a4d5bdbb61f26c0c269f1079 (patch)
treeb0d0611842252722d4bcc0675c3a80cbb7173a94 /src/content
parent651f3b51df11e6be6ab85dd793ec6eb91d1ddf57 (diff)
content: transformContent: let inline images link to things
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/transformContent.js31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js
index 15c87019..654bb258 100644
--- a/src/content/dependencies/transformContent.js
+++ b/src/content/dependencies/transformContent.js
@@ -255,18 +255,31 @@ export default {
             } = node;
 
             if (node.inline) {
+              let content =
+                html.tag('img',
+                  src && {src},
+                  width && {width},
+                  height && {height},
+                  style && {style},
+
+                  pixelate &&
+                    {class: 'pixelate'});
+
+              if (link) {
+                // TODO: Would be nice to use an external link component here,
+                // just for the title text (ex. "YouTube (opens in new tab)")
+                content =
+                  html.tag('a',
+                    {href: link},
+                    {target: '_blank'},
+
+                    content);
+              }
+
               return {
                 type: 'processed-image',
                 inline: true,
-                data:
-                  html.tag('img',
-                    src && {src},
-                    width && {width},
-                    height && {height},
-                    style && {style},
-
-                    pixelate &&
-                      {class: 'pixelate'}),
+                data: content,
               };
             }