« get me outta code hell

content: transformContent: single-link mode - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-07-26 11:12:21 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-07-26 11:13:02 -0300
commit2a255b6c2e5970a523f9e2d6cf2b4d51dea97f06 (patch)
tree98c81d5c9655c1a40c3e4b1cd93a9dd76c143e07
parent6b56b12a0e84581e61fdacce3dbaced1299aa7ae (diff)
content: transformContent: single-link mode
-rw-r--r--src/content/dependencies/generateWikiHomePage.js2
-rw-r--r--src/content/dependencies/transformContent.js15
2 files changed, 15 insertions, 2 deletions
diff --git a/src/content/dependencies/generateWikiHomePage.js b/src/content/dependencies/generateWikiHomePage.js
index 666c3f26..d3d05c40 100644
--- a/src/content/dependencies/generateWikiHomePage.js
+++ b/src/content/dependencies/generateWikiHomePage.js
@@ -80,7 +80,7 @@ export default {
             ?.map(content => ({
               html:
                 content.slots({
-                  mode: 'inline',
+                  mode: 'single-link',
                   preferShortLinkNames: true,
                 }),
             }))
diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js
index ebb4e12a..03bd7bcc 100644
--- a/src/content/dependencies/transformContent.js
+++ b/src/content/dependencies/transformContent.js
@@ -186,7 +186,7 @@ export default {
 
   slots: {
     mode: {
-      validate: v => v.is('inline', 'multiline', 'lyrics'),
+      validate: v => v.is('inline', 'multiline', 'lyrics', 'single-link'),
       default: 'multiline',
     },
 
@@ -259,6 +259,19 @@ export default {
         return getPlaceholder(node, data.content);
       });
 
+    // In single-link mode, return the link node exactly as is - exposing
+    // access to its slots.
+
+    if (slots.mode === 'single-link') {
+      const link = contentFromNodes.find(node => node.type === 'link');
+
+      if (!link) {
+        return html.blank();
+      }
+
+      return link.data;
+    }
+
     // In inline mode, no further processing is needed!
 
     if (slots.mode === 'inline') {