« get me outta code hell

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:
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);
       }