« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/linkExternalAsIcon.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/linkExternalAsIcon.js')
-rw-r--r--src/content/dependencies/linkExternalAsIcon.js34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/content/dependencies/linkExternalAsIcon.js b/src/content/dependencies/linkExternalAsIcon.js
index e2ce4b3c..9b146a4c 100644
--- a/src/content/dependencies/linkExternalAsIcon.js
+++ b/src/content/dependencies/linkExternalAsIcon.js
@@ -1,7 +1,13 @@
 import {isExternalLinkContext} from '#external-links';
 
 export default {
-  extraDependencies: ['html', 'language', 'to'],
+  contentDependencies: ['generateExternalIcon'],
+  extraDependencies: ['html', 'language'],
+
+  relations: (relation, url) => ({
+    icon:
+      relation('generateExternalIcon', url),
+  }),
 
   data: (url) => ({url}),
 
@@ -13,39 +19,27 @@ export default {
       validate: () => isExternalLinkContext,
       default: 'generic',
     },
-
-    withText: {type: 'boolean'},
   },
 
-  generate(data, slots, {html, language, to}) {
+  generate(data, relations, slots, {html, language}) {
     const format = style =>
       language.formatExternalLink(data.url, {style, context: slots.context});
 
     const platformText = format('platform');
     const handleText = format('handle');
-    const iconId = format('icon-id');
 
-    return html.tag('a', {class: 'icon'},
-      {href: data.url},
-
-      slots.withText &&
+    return (
+      html.tag('a', {class: 'icon'},
+        {href: data.url},
         {class: 'has-text'},
 
-      [
-        html.tag('svg', [
-          !slots.withText &&
-            html.tag('title', platformText),
-
-          html.tag('use', {
-            href: to('staticMisc.icon', iconId),
-          }),
-        ]),
+        [
+          relations.icon,
 
-        slots.withText &&
           html.tag('span', {class: 'icon-text'},
             (html.isBlank(handleText)
               ? platformText
               : handleText)),
-      ]);
+        ]));
   },
 };