« get me outta code hell

content: *mostly* port linkExternal to language.formatExternalLink - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util/external-links.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-23 17:42:49 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-24 13:45:11 -0400
commitc5e02f9d314118a534fd0e942d87e74864674498 (patch)
treebd47495d4de76d11fdd975df540b63542973f55f /src/util/external-links.js
parent8f17782a5f2adbafd031b269195879eb7f79e05f (diff)
content: *mostly* port linkExternal to language.formatExternalLink
Diffstat (limited to 'src/util/external-links.js')
-rw-r--r--src/util/external-links.js17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/util/external-links.js b/src/util/external-links.js
index 8e1c3ca..2047a72 100644
--- a/src/util/external-links.js
+++ b/src/util/external-links.js
@@ -12,6 +12,7 @@ import {
 export const externalLinkStyles = [
   'normal',
   'compact',
+  'platform',
   'icon-id',
 ];
 
@@ -181,16 +182,15 @@ export function getMatchingDescriptorsForExternalLink(url, descriptors) {
 export function getExternalLinkStringsFromDescriptor(url, descriptor, language) {
   const prefix = 'misc.external';
 
-  const results = {
-    'normal': null,
-    'compact': null,
-    'icon-id': null,
-  };
+  const results =
+    Object.fromEntries(externalLinkStyles.map(style => [style, null]));
 
   const {hostname: domain, pathname} = new URL(url);
 
   const place = language.$(prefix, descriptor.string);
 
+  results['platform'] = place;
+
   if (descriptor.icon) {
     results['icon-id'] = descriptor.icon;
   }
@@ -270,11 +270,8 @@ export function getExternalLinkStringsFromDescriptor(url, descriptor, language)
 }
 
 export function getExternalLinkStringsFromDescriptors(url, descriptors, language) {
-  const results = {
-    'normal': null,
-    'compact': null,
-    'icon-id': null,
-  };
+  const results =
+    Object.fromEntries(externalLinkStyles.map(style => [style, null]));
 
   const remainingKeys =
     new Set(Object.keys(results));