« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/content/dependencies/linkTemplate.js6
-rw-r--r--src/strings-default.json1
-rw-r--r--tap-snapshots/test/snapshot/linkTemplate.js.test.cjs8
-rw-r--r--test/snapshot/linkTemplate.js7
4 files changed, 19 insertions, 3 deletions
diff --git a/src/content/dependencies/linkTemplate.js b/src/content/dependencies/linkTemplate.js
index dab81ad3..2a9261e2 100644
--- a/src/content/dependencies/linkTemplate.js
+++ b/src/content/dependencies/linkTemplate.js
@@ -5,6 +5,7 @@ export default {
     'appendIndexHTML',
     'getColors',
     'html',
+    'language',
     'to',
   ],
 
@@ -23,6 +24,7 @@ export default {
     appendIndexHTML,
     getColors,
     html,
+    language,
     to,
   }) {
     let href = slots.href;
@@ -64,6 +66,8 @@ export default {
         style,
         title,
       },
-      slots.content);
+      (html.isBlank(slots.content)
+        ? language.$('misc.missingLinkContent')
+        : slots.content));
   },
 }
diff --git a/src/strings-default.json b/src/strings-default.json
index ec174a27..7987a9f6 100644
--- a/src/strings-default.json
+++ b/src/strings-default.json
@@ -197,6 +197,7 @@
   "misc.external.flash.homestuck.page": "{LINK} (page {PAGE})",
   "misc.external.flash.homestuck.secret": "{LINK} (secret page)",
   "misc.external.flash.youtube": "{LINK} (on any device)",
+  "misc.missingLinkContent": "(Missing link content)",
   "misc.nav.previous": "Previous",
   "misc.nav.next": "Next",
   "misc.nav.info": "Info",
diff --git a/tap-snapshots/test/snapshot/linkTemplate.js.test.cjs b/tap-snapshots/test/snapshot/linkTemplate.js.test.cjs
index a9c1b678..e9d22ba5 100644
--- a/tap-snapshots/test/snapshot/linkTemplate.js.test.cjs
+++ b/tap-snapshots/test/snapshot/linkTemplate.js.test.cjs
@@ -10,9 +10,13 @@ exports[`test/snapshot/linkTemplate.js TAP linkTemplate (snapshot) > fill many s
 `
 
 exports[`test/snapshot/linkTemplate.js TAP linkTemplate (snapshot) > fill path slot & provide appendIndexHTML 1`] = `
-<a href="/c*lzone/myCoolPath/ham/pineapple/tomato/index.html"></a>
+<a href="/c*lzone/myCoolPath/ham/pineapple/tomato/index.html">delish</a>
+`
+
+exports[`test/snapshot/linkTemplate.js TAP linkTemplate (snapshot) > missing content 1`] = `
+<a href="banana">(Missing link content)</a>
 `
 
 exports[`test/snapshot/linkTemplate.js TAP linkTemplate (snapshot) > special characters in path argument 1`] = `
-<a href="media/album-additional/homestuck-vol-1/Showtime%20(Piano%20Refrain)%20-%20%23xXxAwesomeSheetMusick%3FrxXx%23.pdf"></a>
+<a href="media/album-additional/homestuck-vol-1/Showtime%20(Piano%20Refrain)%20-%20%23xXxAwesomeSheetMusick%3FrxXx%23.pdf">Damn, that's some good sheet music</a>
 `
diff --git a/test/snapshot/linkTemplate.js b/test/snapshot/linkTemplate.js
index 1db4582e..83d77108 100644
--- a/test/snapshot/linkTemplate.js
+++ b/test/snapshot/linkTemplate.js
@@ -30,6 +30,7 @@ testContentFunctions(t, 'linkTemplate (snapshot)', async (t, evaluate) => {
 
     slots: {
       path: ['myCoolPath', 'ham', 'pineapple', 'tomato'],
+      content: 'delish',
     },
   });
 
@@ -41,6 +42,12 @@ testContentFunctions(t, 'linkTemplate (snapshot)', async (t, evaluate) => {
         'homestuck-vol-1',
         'Showtime (Piano Refrain) - #xXxAwesomeSheetMusick?rxXx#.pdf',
       ],
+      content: `Damn, that's some good sheet music`,
     },
   });
+
+  evaluate.snapshot('missing content', {
+    name: 'linkTemplate',
+    slots: {href: 'banana'},
+  });
 });