« get me outta code hell

content: linkContribution: show "Other" as fallback platform - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-03-29 16:28:50 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-03-29 20:01:45 -0300
commitcbfea6a0e017c4a8a4c47df688072d95180313a2 (patch)
tree876ae87b8e896382edee4775dc34ee60195cea48 /src/content/dependencies
parent4e11adf60b74db6a69fcebbf07dcd7c8e8b00a20 (diff)
content: linkContribution: show "Other" as fallback platform
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/linkContribution.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/content/dependencies/linkContribution.js b/src/content/dependencies/linkContribution.js
index c69a5b48..41ce1146 100644
--- a/src/content/dependencies/linkContribution.js
+++ b/src/content/dependencies/linkContribution.js
@@ -78,18 +78,33 @@ export default {
                   stitchArrays({
                     icon: relations.artistIcons,
                     url: data.urls,
-                  }).map(({icon, url}) => [
-                      icon.slots({
+                  }).map(({icon, url}) => {
+                      icon.setSlots({
                         context: 'artist',
                         withText: true,
-                      }),
+                      });
 
-                      html.tag('span', {class: 'icon-platform'},
+                      let platformText =
                         language.formatExternalLink(url, {
                           context: 'artist',
                           style: 'platform',
-                        })),
-                    ]),
+                        });
+
+                      // This is a pretty ridiculous hack, but we currently
+                      // don't have a way of telling formatExternalLink to *not*
+                      // use the fallback string, which just formats the URL as
+                      // its host/domain... so is technically detectable.
+                      if (platformText.toString() === (new URL(url)).host) {
+                        platformText =
+                          language.$('misc.artistLink.noExternalLinkPlatformName');
+                      }
+
+                      const platformSpan =
+                        html.tag('span', {class: 'icon-platform'},
+                          platformText);
+
+                      return [icon, platformSpan];
+                    }),
               }),
           })
         : relations.artistLink);