diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-01-08 11:49:44 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-01-08 11:49:44 -0400 |
commit | 154c050db72ebf06d4514326c696ab43fb3f8dc8 (patch) | |
tree | 96219177a6d692d0acba5cd9e5bbd7c3a25cb566 /src/write/build-modes | |
parent | 47a4404b4a294e7e127b64f9f930236072b56194 (diff) |
basic actual stub for live-dev-server
Diffstat (limited to 'src/write/build-modes')
-rw-r--r-- | src/write/build-modes/live-dev-server.js | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index 76b6d47f..c3094712 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -1,4 +1,9 @@ -import {logInfo} from '../../util/cli.js'; +import * as pageSpecs from '../../page/index.js'; + +import { + logInfo, + progressCallAll, +} from '../../util/cli.js'; export function getCLIOptions() { // Stub. @@ -16,16 +21,40 @@ export async function go({ _srcRootPath, _urls, _urlSpec, - _wikiData, + wikiData, _cachebust, _developersComment, _getSizeOfAdditionalFile, }) { - // Stub. - logInfo`So we are back in the mine!`; - logInfo`We are swinging our pickaxe in-`; - logInfo`...multiple directions,`; - logInfo`...multiple directions.`; + let targetSpecPairs = getPageSpecsWithTargets({wikiData}); + const writes = progressCallAll(`Computing page data & paths for ${targetSpecPairs.length} targets.`, + targetSpecPairs.map(({ + pageSpec, + target, + targetless, + }) => () => + targetless + ? pageSpec.writeTargetless({wikiData}) + : pageSpec.write(target, {wikiData}))).flat(); + + logInfo`Will be serving a total of ${writes.length} pages.`; + return true; } + +function getPageSpecsWithTargets({ + wikiData, +}) { + return Object.values(pageSpecs) + .filter(pageSpec => pageSpec.condition?.({wikiData}) ?? true) + .flatMap(pageSpec => [ + ...pageSpec.targets + ? pageSpec.targets({wikiData}) + .map(target => ({pageSpec, target})) + : [], + Object.hasOwn(pageSpec, 'writeTargetless') && + {pageSpec, targetless: true}, + ]) + .filter(Boolean); +} |