« get me outta code hell

extract absoluteTo - 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>2023-01-10 16:55:04 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-01-10 16:55:04 -0400
commitd442546057f8280a141d4aa54f633a09c429e2d3 (patch)
treefa4ee7eb5716a06387aaf8734a2722646adcc54e /src/write
parent091d5221948ca4a6decd091bc3a5e0063adf1443 (diff)
extract absoluteTo
Diffstat (limited to 'src/write')
-rw-r--r--src/write/build-modes/live-dev-server.js20
-rw-r--r--src/write/build-modes/static-build.js20
2 files changed, 10 insertions, 30 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index a8e5424..d481b48 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -17,6 +17,7 @@ import {
   getPagePathname,
   getPageSubdirectoryPrefix,
   getURLsFrom,
+  getURLsFromRoot,
 } from '../../util/urls.js';
 
 import {
@@ -256,20 +257,10 @@ export async function go({
       }),
     });
 
-    const absoluteTo = (targetFullKey, ...args) => {
-      const [groupKey, subKey] = targetFullKey.split('.');
-      const from = urls.from('shared.root');
-      return (
-        '/' +
-        (groupKey === 'localized' && baseDirectory
-          ? from.to(
-              'localizedWithBaseDirectory.' + subKey,
-              baseDirectory,
-              ...args
-            )
-          : from.to(targetFullKey, ...args))
-      );
-    };
+    const absoluteTo = getURLsFromRoot({
+      baseDirectory,
+      urls,
+    });
 
     try {
       const pageSubKey = servePath[0];
@@ -314,7 +305,6 @@ export async function go({
         ...bound,
 
         absoluteTo,
-        relativeTo: to,
         to,
         urls,
 
diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js
index 1544a12..c2bb02f 100644
--- a/src/write/build-modes/static-build.js
+++ b/src/write/build-modes/static-build.js
@@ -30,6 +30,7 @@ import {
   getPagePaths,
   getPageSubdirectoryPrefix,
   getURLsFrom,
+  getURLsFromRoot,
 } from '../../util/urls.js';
 
 const pageFlags = Object.keys(pageSpecs);
@@ -302,20 +303,10 @@ export async function go({
           }),
         });
 
-        const absoluteTo = (targetFullKey, ...args) => {
-          const [groupKey, subKey] = targetFullKey.split('.');
-          const from = urls.from('shared.root');
-          return (
-            '/' +
-            (groupKey === 'localized' && baseDirectory
-              ? from.to(
-                  'localizedWithBaseDirectory.' + subKey,
-                  baseDirectory,
-                  ...args
-                )
-              : from.to(targetFullKey, ...args))
-          );
-        };
+        const absoluteTo = getURLsFromRoot({
+          baseDirectory,
+          urls,
+        });
 
         const bound = bindUtilities({
           language,
@@ -327,7 +318,6 @@ export async function go({
           ...bound,
 
           absoluteTo,
-          relativeTo: to,
           to,
           urls,