« get me outta code hell

content: linkContribution: add preventWrapping slot - 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>2023-08-10 10:53:45 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-08-10 10:53:45 -0300
commitf49326e998f69931b52969c4235b0ee478ddc682 (patch)
tree22821489f63ef6a5395ddd6aad930082917f45ff
parentf00554fe281dfccfed09524b4fc9a6677a56ffcf (diff)
content: linkContribution: add preventWrapping slot
-rw-r--r--src/content/dependencies/linkContribution.js3
-rw-r--r--tap-snapshots/test/snapshot/linkContribution.js.test.cjs21
-rw-r--r--test/snapshot/linkContribution.js6
3 files changed, 29 insertions, 1 deletions
diff --git a/src/content/dependencies/linkContribution.js b/src/content/dependencies/linkContribution.js
index f4c05388..2219ae1d 100644
--- a/src/content/dependencies/linkContribution.js
+++ b/src/content/dependencies/linkContribution.js
@@ -36,6 +36,7 @@ export default {
   slots: {
     showContribution: {type: 'boolean', default: false},
     showIcons: {type: 'boolean', default: false},
+    preventWrapping: {type: 'boolean', default: true},
   },
 
   generate(data, relations, slots, {html, language}) {
@@ -63,7 +64,7 @@ export default {
     const content = language.formatString(parts.join('.'), options);
 
     return (
-      (parts.length > 1
+      (parts.length > 1 && slots.preventWrapping
         ? html.tag('span',
             {[html.noEdgeWhitespace]: true, class: 'nowrap'},
             content)
diff --git a/tap-snapshots/test/snapshot/linkContribution.js.test.cjs b/tap-snapshots/test/snapshot/linkContribution.js.test.cjs
index dd796898..7124ad18 100644
--- a/tap-snapshots/test/snapshot/linkContribution.js.test.cjs
+++ b/tap-snapshots/test/snapshot/linkContribution.js.test.cjs
@@ -35,6 +35,27 @@ exports[`test/snapshot/linkContribution.js TAP linkContribution (snapshot) > no
 <a href="artist/toby-fox/">Toby Fox</a>
 `
 
+exports[`test/snapshot/linkContribution.js TAP linkContribution (snapshot) > no preventWrapping 1`] = `
+<a href="artist/clark-powell/">Clark Powell</a> (<span class="icons"><a href="https://soundcloud.com/plazmataz" class="icon">
+        <svg>
+            <title>SoundCloud</title>
+            <use href="static/icons.svg#icon-soundcloud"></use>
+        </svg>
+    </a></span>)
+<a href="artist/the-big-baddies/">Grounder & Scratch</a> (Snooping)
+<a href="artist/toby-fox/">Toby Fox</a> (Arrangement) (<span class="icons"><a href="https://tobyfox.bandcamp.com/" class="icon">
+        <svg>
+            <title>Bandcamp</title>
+            <use href="static/icons.svg#icon-bandcamp"></use>
+        </svg>
+    </a>, <a href="https://toby.fox/" class="icon">
+        <svg>
+            <title>External (toby.fox)</title>
+            <use href="static/icons.svg#icon-globe"></use>
+        </svg>
+    </a></span>)
+`
+
 exports[`test/snapshot/linkContribution.js TAP linkContribution (snapshot) > only showContribution 1`] = `
 <a href="artist/clark-powell/">Clark Powell</a>
 <span class="nowrap"><a href="artist/the-big-baddies/">Grounder & Scratch</a> (Snooping)</span>
diff --git a/test/snapshot/linkContribution.js b/test/snapshot/linkContribution.js
index 10b1bd08..ccb74674 100644
--- a/test/snapshot/linkContribution.js
+++ b/test/snapshot/linkContribution.js
@@ -64,4 +64,10 @@ testContentFunctions(t, 'linkContribution (snapshot)', async (t, evaluate) => {
     ],
     slots: {showIcons: true},
   });
+
+  quickSnapshot('no preventWrapping', {
+    showContribution: true,
+    showIcons: true,
+    preventWrapping: false,
+  });
 });