« get me outta code hell

write: factor out commonUtilities - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/write
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-05-27 16:28:45 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-09-12 14:16:22 -0300
commitb485117d885f723fb81a8e573050747393c004cf (patch)
tree2ff4da912cbf4a463ad74928a771d126cd07ba7d /src/write
parent7924ab5deeaca905192c11a82a937d7615328b48 (diff)
write: factor out commonUtilities
Diffstat (limited to 'src/write')
-rw-r--r--src/write/build-modes/live-dev-server.js21
-rw-r--r--src/write/build-modes/static-build.js21
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;