From 6d8fe82b5386af536ca96eb1d89150e201c603e9 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 25 May 2023 13:23:04 -0300 Subject: 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). --- src/write/build-modes/live-dev-server.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/write/build-modes') 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); } -- cgit 1.3.0-6-gf8a5