« get me outta code hell

content: sprawl & transformContent - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/write
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-05-25 13:23:04 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-05-25 13:23:04 -0300
commit6d8fe82b5386af536ca96eb1d89150e201c603e9 (patch)
treec5d8cce46834facc82e66779e69e7cef67627d28 /src/write
parentbd0741dcf0c23489bf710249ab8fd9ba647db843 (diff)
content: sprawl & transformContent
Sprawling basically means tying a component to objects which
aren't directly passed to it. This is necessary for functions
like transformContent, which was *mostly* implemented here
(the multiline/lyrics modes are stubs, and a number of links
haven't been implemented yet).
Diffstat (limited to 'src/write')
-rw-r--r--src/write/bind-utilities.js1
-rw-r--r--src/write/build-modes/live-dev-server.js21
2 files changed, 14 insertions, 8 deletions
diff --git a/src/write/bind-utilities.js b/src/write/bind-utilities.js
index be9ad66c..a31e02f7 100644
--- a/src/write/bind-utilities.js
+++ b/src/write/bind-utilities.js
@@ -49,6 +49,7 @@ export function bindUtilities({
     thumb,
     to,
     urls,
+    wikiData,
     wikiInfo: wikiData.wikiInfo,
   });
 
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index c15fc465..d4b7472d 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -364,7 +364,7 @@ export async function go({
 
       // NOTE: ALL THIS STUFF IS PASTED, REVIEW AND INTEGRATE SOON(TM)
 
-      const treeInfo = getRelationsTree(allContentDependencies, name, ...args);
+      const treeInfo = getRelationsTree(allContentDependencies, name, wikiData, ...args);
       const flatTreeInfo = flattenRelationsTree(treeInfo);
       const {root, relationIdentifier, flatRelationSlots} = flatTreeInfo;
 
@@ -431,20 +431,25 @@ export async function go({
 
       const slotResults = {};
 
-      function runContentFunction({name, args, relations}) {
+      function runContentFunction({name, args, relations: flatRelations}) {
         const contentFunction = fulfilledContentDependencies[name];
 
         if (!contentFunction) {
           throw new Error(`Content function ${name} unfulfilled or not listed`);
         }
 
-        const filledRelations =
-          fillRelationsLayoutFromSlotResults(relationIdentifier, slotResults, relations);
+        const sprawl =
+          contentFunction.sprawl?.(allExtraDependencies.wikiData, ...args);
 
-        const generateArgs = [
-          contentFunction.data?.(...args),
-          filledRelations,
-        ].filter(Boolean);
+        const relations =
+          fillRelationsLayoutFromSlotResults(relationIdentifier, slotResults, flatRelations);
+
+        const data =
+          (sprawl
+            ? contentFunction.data?.(sprawl, ...args)
+            : contentFunction.data?.(...args));
+
+        const generateArgs = [data, relations].filter(Boolean);
 
         return contentFunction(...generateArgs);
       }