« get me outta code hell

content: contextual external links - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/linkExternal.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-23 18:52:04 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-24 13:45:34 -0400
commit8c69ef2b14c4719fa0cd0c7daca27c613167b7ca (patch)
tree8742a45bb243c9e1fdc1a7a7504316f92f9315ce /src/content/dependencies/linkExternal.js
parentcf08893d48db6f8082a176f54d0d92cb82716b3a (diff)
content: contextual external links
Diffstat (limited to 'src/content/dependencies/linkExternal.js')
-rw-r--r--src/content/dependencies/linkExternal.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/content/dependencies/linkExternal.js b/src/content/dependencies/linkExternal.js
index 1b81efcc..e51ea89e 100644
--- a/src/content/dependencies/linkExternal.js
+++ b/src/content/dependencies/linkExternal.js
@@ -1,3 +1,5 @@
+import {isExternalLinkContext} from '#external-links';
+
 export default {
   extraDependencies: ['html', 'language', 'wikiData'],
 
@@ -16,8 +18,11 @@ export default {
   },
 
   slots: {
-    mode: {
-      validate: v => v.is('generic', 'album', 'flash'),
+    context: {
+      // This awkward syntax is because the slot descriptor validator can't
+      // differentiate between a function that returns a validator (the usual
+      // syntax) and a function that is itself a validator.
+      validate: () => isExternalLinkContext,
       default: 'generic',
     },
   },
@@ -26,7 +31,10 @@ export default {
     return (
       html.tag('a',
         {href: data.url, class: 'nowrap'},
-        language.formatExternalLink(data.url, {style: 'platform'})));
+        language.formatExternalLink(data.url, {
+          style: 'platform',
+          context: slots.context,
+        })));
   },
 
     /*