From 859b8fb20525b44a94ab5072405c6c9d6df4da5b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 18 Jan 2022 19:45:09 -0400 Subject: initial working changes for big data restructure --- src/misc-templates.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/misc-templates.js') 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')})); +} -- cgit 1.3.0-6-gf8a5