« get me outta code hell

extract fn for localizedPathnames - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-01-10 19:45:13 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-01-10 19:45:32 -0400
commite06292fe8e7d789d38ac43fd9eee6816e39e18fe (patch)
treeb640471c8d401df418d94af6b8bfc3ce3e81c1ec /src/util
parent592acc152dc68e0f24300c090c9eabb9f21cef6b (diff)
extract fn for localizedPathnames
Diffstat (limited to 'src/util')
-rw-r--r--src/util/urls.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util/urls.js b/src/util/urls.js
index a74e0dfb..ead6c769 100644
--- a/src/util/urls.js
+++ b/src/util/urls.js
@@ -233,6 +233,29 @@ export function getPagePathname({
           ...urlArgs));
 }
 
+export function getPagePathnameAcrossLanguages({
+  defaultLanguage,
+  languages,
+  pageSubKey,
+  urlArgs,
+  urls,
+}) {
+  return withEntries(languages, entries => entries
+    .filter(([key, language]) => key !== 'default' && !language.hidden)
+    .map(([_key, language]) => [
+      language.code,
+      getPagePathname({
+        baseDirectory:
+          (language === defaultLanguage
+            ? ''
+            : language.code),
+        fullKey: 'localized.' + pageSubKey,
+        urlArgs,
+        urls,
+      }),
+    ]));
+}
+
 // Needed for the rare path arguments which themselves contains one or more
 // slashes, e.g. for listings, with arguments like 'albums/by-name'.
 export function getPageSubdirectoryPrefix({urlArgs}) {