« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util/urls.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/urls.js')
-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 a74e0df..ead6c76 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}) {