« 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/linkExternal.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/linkExternal.js')
-rw-r--r--src/content/dependencies/linkExternal.js23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/content/dependencies/linkExternal.js b/src/content/dependencies/linkExternal.js
index 08191a21..7c3d86a8 100644
--- a/src/content/dependencies/linkExternal.js
+++ b/src/content/dependencies/linkExternal.js
@@ -5,21 +5,18 @@ const MASTODON_DOMAINS = ['types.pl'];
 export default {
   extraDependencies: ['html', 'language'],
 
-  data(url, {
-    type = 'generic',
-  } = {}) {
-    const types = ['generic', 'album'];
-    if (!types.includes(type)) {
-      throw new TypeError(`Expected type to be one of ${types}`);
-    }
+  data(url) {
+    return {url};
+  },
 
-    return {
-      url,
-      type,
-    };
+  slots: {
+    mode: {
+      validate: v => v.is('generic', 'album'),
+      default: 'generic',
+    },
   },
 
-  generate(data, {html, language}) {
+  generate(data, slots, {html, language}) {
     let isLocal;
     let domain;
     try {
@@ -50,7 +47,7 @@ export default {
         ? language.$('misc.external.mastodon.domain', {domain})
 
     : domain.includes('youtu')
-        ? data.type === 'album'
+        ? slots.mode === 'album'
           ? data.url.includes('list=')
             ? language.$('misc.external.youtube.playlist')
             : language.$('misc.external.youtube.fullAlbum')