diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-06-24 11:25:23 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-06-24 11:25:47 -0300 |
commit | 84f2a815ea1e25b46086869a9099659fd46a3640 (patch) | |
tree | 1088941c7402b1954cfa668ea876eeacf48ba266 /src/write | |
parent | 205285e6f0e8387478fb855fa2d58e2050ff4204 (diff) |
infra: refactor relations tree processing, new 'query' step
Finally putting the 'step' in 'data-steps'!
Diffstat (limited to 'src/write')
-rw-r--r-- | src/write/build-modes/live-dev-server.js | 19 | ||||
-rw-r--r-- | src/write/build-modes/static-build.js | 19 |
2 files changed, 16 insertions, 22 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index e3ab21d5..8af37d3a 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -428,25 +428,22 @@ export async function go({ const slotResults = {}; - function runContentFunction({name, args, relations: flatRelations}) { + function runContentFunction({name, args, relations: layout}) { const contentFunction = fulfilledContentDependencies[name]; if (!contentFunction) { throw new Error(`Content function ${name} unfulfilled or not listed`); } - const sprawl = - contentFunction.sprawl?.(allExtraDependencies.wikiData, ...args); + const generateArgs = []; - const relations = - fillRelationsLayoutFromSlotResults(relationIdentifier, slotResults, flatRelations); - - const data = - (sprawl - ? contentFunction.data?.(sprawl, ...args) - : contentFunction.data?.(...args)); + if (contentFunction.data) { + generateArgs.push(contentFunction.data(...args)); + } - const generateArgs = [data, relations].filter(Boolean); + if (layout) { + generateArgs.push(fillRelationsLayoutFromSlotResults(relationIdentifier, slotResults, layout)); + } return contentFunction(...generateArgs); } diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index e0b4ab16..67a4df67 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -390,25 +390,22 @@ export async function go({ const slotResults = {}; - function runContentFunction({name, args, relations: flatRelations}) { + function runContentFunction({name, args, relations: layout}) { const contentFunction = fulfilledContentDependencies[name]; if (!contentFunction) { throw new Error(`Content function ${name} unfulfilled or not listed`); } - const sprawl = - contentFunction.sprawl?.(allExtraDependencies.wikiData, ...args); + const generateArgs = []; - const relations = - fillRelationsLayoutFromSlotResults(relationIdentifier, slotResults, flatRelations); - - const data = - (sprawl - ? contentFunction.data?.(sprawl, ...args) - : contentFunction.data?.(...args)); + if (contentFunction.data) { + generateArgs.push(contentFunction.data(...args)); + } - const generateArgs = [data, relations].filter(Boolean); + if (layout) { + generateArgs.push(fillRelationsLayoutFromSlotResults(relationIdentifier, slotResults, layout)); + } return contentFunction(...generateArgs); } |