« 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.js6
-rw-r--r--src/write/build-modes/static-build.js6
2 files changed, 7 insertions, 5 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index a87da27b..edee3267 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -321,6 +321,10 @@ export async function go({
 
     try {
       if (page.type === 'redirect') {
+        const title =
+          page.title ??
+          page.getTitle?.({language});
+
         const target = to('localized.' + page.toPath[0], ...page.toPath.slice(1));
 
         response.writeHead(301, {
@@ -328,7 +332,7 @@ export async function go({
           'Location': target,
         });
 
-        const redirectHTML = generateRedirectHTML(page.title, target, {language});
+        const redirectHTML = generateRedirectHTML(title, target, {language});
 
         response.end(redirectHTML);
 
diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js
index dc2bb2c0..4f074058 100644
--- a/src/write/build-modes/static-build.js
+++ b/src/write/build-modes/static-build.js
@@ -355,10 +355,8 @@ export async function go({
         });
       }),
 
-      ...redirectWrites.map(({fromPath, toPath, title: titleFn}) => () => {
-        const title = titleFn({
-          language,
-        });
+      ...redirectWrites.map(({fromPath, toPath, title, getTitle}) => () => {
+        title ??= getTitle?.({language});
 
         const to = getURLsFrom({
           baseDirectory,