From cbfea6a0e017c4a8a4c47df688072d95180313a2 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 29 Mar 2024 16:28:50 -0300 Subject: content: linkContribution: show "Other" as fallback platform --- src/content/dependencies/linkContribution.js | 27 +++++++++++++++++++++------ src/strings-default.yaml | 4 ++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/content/dependencies/linkContribution.js b/src/content/dependencies/linkContribution.js index c69a5b4..41ce114 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); diff --git a/src/strings-default.yaml b/src/strings-default.yaml index cd05ce5..de0cc96 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -453,6 +453,10 @@ misc: # Combination of above. withContribution.withExternalLinks: "{ARTIST} ({CONTRIB}) ({LINKS})" + # Displayed in an artist's tooltip, if one of their URLs + # isn't a specially detected web platform. + noExternalLinkPlatformName: "Other" + # chronology: # # "Chronology links" are a section that appear in the nav bar for -- cgit 1.3.0-6-gf8a5