« get me outta code hell

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:
Diffstat (limited to 'src/write')
-rw-r--r--src/write/build-modes/live-dev-server.js16
-rw-r--r--src/write/build-modes/static-build.js26
-rw-r--r--src/write/page-template.js11
3 files changed, 19 insertions, 34 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index bdd4561e..ec9689bd 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -89,8 +89,7 @@ export async function go({
 
         const pathname = getPagePathname({
           baseDirectory,
-          pageSubKey: servePath[0],
-          urlArgs: servePath.slice(1),
+          pagePath: servePath,
           urls,
         });
 
@@ -248,9 +247,9 @@ export async function go({
     const to = getURLsFrom({
       urls,
       baseDirectory,
-      pageSubKey: servePath[0],
+      pagePath: servePath,
       subdirectoryPrefix: getPageSubdirectoryPrefix({
-        urlArgs: servePath.slice(1),
+        pagePath: servePath,
       }),
     });
 
@@ -260,9 +259,6 @@ export async function go({
     });
 
     try {
-      const pageSubKey = servePath[0];
-      const urlArgs = servePath.slice(1);
-
       if (page.type === 'redirect') {
         response.writeHead(301, contentTypeHTML);
 
@@ -280,8 +276,7 @@ export async function go({
       const localizedPathnames = getPagePathnameAcrossLanguages({
         defaultLanguage,
         languages,
-        pageSubKey,
-        urlArgs,
+        pagePath: servePath,
         urls,
       });
 
@@ -305,9 +300,8 @@ export async function go({
         languages,
         localizedPathnames,
         oEmbedJSONHref: null, // No oEmbed support for live dev server
-        pageSubKey,
+        pagePath: servePath,
         pathname,
-        urlArgs,
         to,
         transformMultiline: bound.transformMultiline,
         wikiData,
diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js
index edfb02c2..5141891c 100644
--- a/src/write/build-modes/static-build.js
+++ b/src/write/build-modes/static-build.js
@@ -265,30 +265,27 @@ export async function go({
 
     await progressPromiseAll(`Writing ${language.code}`, queue([
       ...pageWrites.map(page => () => {
-        const pageSubKey = page.path[0];
-        const urlArgs = page.path.slice(1);
+        const pagePath = page.path;
 
         const localizedPathnames = getPagePathnameAcrossLanguages({
           defaultLanguage,
           languages,
-          pageSubKey,
-          urlArgs,
+          pagePath,
           urls,
         });
 
         const pathname = getPagePathname({
           baseDirectory,
-          pageSubKey,
-          urlArgs,
+          pagePath,
           urls,
         });
 
         const to = getURLsFrom({
           urls,
           baseDirectory,
-          pageSubKey,
+          pagePath,
           subdirectoryPrefix: getPageSubdirectoryPrefix({
-            urlArgs: page.path.slice(1),
+            pagePath,
           }),
         });
 
@@ -330,11 +327,10 @@ export async function go({
           languages,
           localizedPathnames,
           oEmbedJSONHref,
-          pageSubKey,
+          pagePath,
           pathname,
           to,
           transformMultiline: bound.transformMultiline,
-          urlArgs,
           wikiData,
         });
 
@@ -344,8 +340,7 @@ export async function go({
           outputDirectory: path.join(outputPath, getPagePathname({
             baseDirectory,
             device: true,
-            pageSubKey,
-            urlArgs,
+            pagePath,
             urls,
           })),
         });
@@ -358,9 +353,9 @@ export async function go({
         const to = getURLsFrom({
           urls,
           baseDirectory,
-          pageSubKey: fromPath[0],
+          pagePath: fromPath,
           subdirectoryPrefix: getPageSubdirectoryPrefix({
-            urlArgs: fromPath.slice(1),
+            pagePath: fromPath,
           }),
         });
 
@@ -372,8 +367,7 @@ export async function go({
           outputDirectory: path.join(outputPath, getPagePathname({
             baseDirectory,
             device: true,
-            pageSubKey: fromPath[0],
-            urlArgs: fromPath.slice(1),
+            pagePath: fromPath,
             urls,
           })),
         });
diff --git a/src/write/page-template.js b/src/write/page-template.js
index 88d81c23..7c2f0c66 100644
--- a/src/write/page-template.js
+++ b/src/write/page-template.js
@@ -55,11 +55,10 @@ export function generateDocumentHTML(pageInfo, {
   languages,
   localizedPathnames,
   oEmbedJSONHref,
-  pageSubKey,
+  pagePath,
   pathname,
   to,
   transformMultiline,
-  urlArgs,
   wikiData,
 }) {
   const {wikiInfo} = wikiData;
@@ -169,9 +168,8 @@ export function generateDocumentHTML(pageInfo, {
           html,
           language,
           languages,
-          pageSubKey,
+          pagePath,
           to,
-          urlArgs,
         }),
       ]);
 
@@ -450,10 +448,9 @@ export function generateDocumentHTML(pageInfo, {
     {
       lang: language.intlCode,
       'data-language-code': language.code,
-      'data-url-key': 'localized.' + pageSubKey,
+      'data-url-key': 'localized.' + pagePath[0],
       ...Object.fromEntries(
-        urlArgs.map((v, i) => [['data-url-value' + i], v])
-      ),
+        pagePath.slice(1).map((v, i) => [['data-url-value' + i], v])),
       'data-rebase-localized': to('localized.root'),
       'data-rebase-shared': to('shared.root'),
       'data-rebase-media': to('media.root'),