From b485117d885f723fb81a8e573050747393c004cf Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 27 May 2024 16:28:45 -0300 Subject: write: factor out commonUtilities --- src/write/build-modes/live-dev-server.js | 21 +++++++++++++-------- src/write/build-modes/static-build.js | 21 +++++++++++++-------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index fe627f6f..c855533b 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -332,6 +332,17 @@ export async function go({ // Other routes determined by page and URL specs + const commonUtilities = { + defaultLanguage, + getSizeOfAdditionalFile, + getSizeOfImagePath, + languages, + missingImagePaths, + thumbsCache, + urls, + wikiData, + }; + const startTiming = () => { if (!showTimings) { return () => ''; @@ -417,19 +428,13 @@ export async function go({ const timing = startTiming(); const bound = bindUtilities({ + ...commonUtilities, + absoluteTo, - defaultLanguage, - getSizeOfAdditionalFile, - getSizeOfImagePath, language, - languages, - missingImagePaths, pagePath: servePath, pagePathStringFromRoot: pathname.replace(/^\//, ''), - thumbsCache, to, - urls, - wikiData, }); const topLevelResult = diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index c50db6b8..d743a64b 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -288,6 +288,17 @@ export async function go({ showAggregate: niceShowAggregate, }); + const commonUtilities = { + defaultLanguage, + getSizeOfAdditionalFile, + getSizeOfImagePath, + languages, + missingImagePaths, + thumbsCache, + urls, + wikiData, + }; + const perLanguageFn = async (language, i, entries) => { const baseDirectory = language === defaultLanguage ? '' : language.code; @@ -316,19 +327,13 @@ export async function go({ }); const bound = bindUtilities({ + ...commonUtilities, + absoluteTo, - defaultLanguage, - getSizeOfAdditionalFile, - getSizeOfImagePath, language, - languages, - missingImagePaths, pagePath, pagePathStringFromRoot: pathname, - thumbsCache, to, - urls, - wikiData, }); let pageHTML, oEmbedJSON; -- cgit 1.3.0-6-gf8a5