« get me outta code hell

content: linkTemplate: suffixNormalContent here too - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-03-20 21:26:39 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-03-20 21:26:50 -0300
commitd35b498ff059643e4686807bda25f7bab5d87ccc (patch)
tree2d828387f3e8a78c2aece72769ee973afc248792
parent853dd7ea8811b823d4fc4f2fa14fa3ac44b5416f (diff)
content: linkTemplate: suffixNormalContent here too
-rw-r--r--src/content/dependencies/linkTemplate.js24
-rw-r--r--src/static/css/site.css8
2 files changed, 23 insertions, 9 deletions
diff --git a/src/content/dependencies/linkTemplate.js b/src/content/dependencies/linkTemplate.js
index 63cc82e8..4f853dc4 100644
--- a/src/content/dependencies/linkTemplate.js
+++ b/src/content/dependencies/linkTemplate.js
@@ -26,6 +26,11 @@ export default {
       type: 'html',
       mutable: false,
     },
+
+    suffixNormalContent: {
+      type: 'html',
+      mutable: false,
+    },
   },
 
   generate(slots, {
@@ -61,13 +66,22 @@ export default {
       attributes.set('title', slots.tooltip);
     }
 
-    const content =
+    const mainContent =
       (html.isBlank(slots.content)
         ? language.$('misc.missingLinkContent')
-        : striptags(html.resolve(slots.content, {normalize: 'string'}), {
-            disallowedTags: new Set(['a']),
-          }));
+        : striptags(
+            html.resolve(slots.content, {normalize: 'string'}),
+            {disallowedTags: new Set(['a'])}));
+
+    const allContent =
+      (html.isBlank(slots.suffixNormalContent)
+        ? mainContent
+        : html.tags([
+            mainContent,
+            html.tag('span', {class: 'normal-content'},
+              slots.suffixNormalContent),
+          ], {[html.joinChildren]: ''}));
 
-    return html.tag('a', attributes, content);
+    return html.tag('a', attributes, allContent);
   },
 }
diff --git a/src/static/css/site.css b/src/static/css/site.css
index 542a2f7d..5515030f 100644
--- a/src/static/css/site.css
+++ b/src/static/css/site.css
@@ -887,6 +887,10 @@ a:not([href]):hover {
   text-decoration: none;
 }
 
+a .normal-content {
+  color: white;
+}
+
 .external-link:not(.from-content) {
   white-space: nowrap;
 }
@@ -900,10 +904,6 @@ a:not([href]):hover {
   color: white;
 }
 
-.external-link .normal-content {
-  color: white;
-}
-
 .image-media-link::after {
   content: '';
   display: inline-block;