« get me outta code hell

initial working changes for big data restructure - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/misc-templates.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-01-18 19:45:09 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-01-18 19:45:09 -0400
commit859b8fb20525b44a94ab5072405c6c9d6df4da5b (patch)
treeb2e56fb20931d6f8702157e7a4cb113e39faab3c /src/misc-templates.js
parentb10d00e4f4cf191ed9cb914052422db4363de349 (diff)
initial working changes for big data restructure
Diffstat (limited to 'src/misc-templates.js')
-rw-r--r--src/misc-templates.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/misc-templates.js b/src/misc-templates.js
index 578c4e5..090c437 100644
--- a/src/misc-templates.js
+++ b/src/misc-templates.js
@@ -375,3 +375,33 @@ export function generatePreviousNextLinks(current, {
         })
     ].filter(Boolean).join(', ');
 }
+
+// Footer stuff
+
+export function getFooterLocalizationLinks(pathname, {
+    languages,
+    paths,
+    strings,
+    to
+}) {
+    const { toPath } = paths;
+    const keySuffix = toPath[0].replace(/^localized\./, '.');
+    const toArgs = toPath.slice(1);
+
+    const links = Object.entries(languages)
+        .filter(([ code ]) => code !== 'default')
+        .map(([ code, strings ]) => strings)
+        .sort((
+            { json: { 'meta.languageName': a } },
+            { json: { 'meta.languageName': b } }
+        ) => a < b ? -1 : a > b ? 1 : 0)
+        .map(strings => html.tag('span', html.tag('a', {
+            href: (strings.code === languages.default.code
+                ? to('localizedDefaultLanguage' + keySuffix, ...toArgs)
+                : to('localizedWithBaseDirectory' + keySuffix, strings.code, ...toArgs))
+        }, strings.json['meta.languageName'])));
+
+    return html.tag('div',
+        {class: 'footer-localization-links'},
+        strings('misc.uiLanguage', {languages: links.join('\n')}));
+}