From 84f2a815ea1e25b46086869a9099659fd46a3640 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 24 Jun 2023 11:25:23 -0300 Subject: infra: refactor relations tree processing, new 'query' step Finally putting the 'step' in 'data-steps'! --- src/write/build-modes/live-dev-server.js | 19 ++++++++----------- src/write/build-modes/static-build.js | 19 ++++++++----------- 2 files changed, 16 insertions(+), 22 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 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); } -- cgit 1.3.0-6-gf8a5