From 76845689c624b603509abbe6f0a289362bb42a04 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 8 Apr 2023 18:18:13 -0300 Subject: content: generateFooterLocalizationLinks --- .../generateFooterLocalizationLinks.js | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/content/dependencies/generateFooterLocalizationLinks.js (limited to 'src/content/dependencies') diff --git a/src/content/dependencies/generateFooterLocalizationLinks.js b/src/content/dependencies/generateFooterLocalizationLinks.js new file mode 100644 index 00000000..01b5b209 --- /dev/null +++ b/src/content/dependencies/generateFooterLocalizationLinks.js @@ -0,0 +1,56 @@ +export default { + extraDependencies: [ + 'defaultLanguage', + 'html', + 'language', + 'languages', + 'pagePath', + 'to', + ], + + generate({ + defaultLanguage, + html, + language, + languages, + pagePath, + to, + }) { + const links = Object.entries(languages) + .filter(([code, language]) => code !== 'default' && !language.hidden) + .map(([code, language]) => language) + .sort(({name: a}, {name: b}) => (a < b ? -1 : a > b ? 1 : 0)) + .map((language) => + html.tag('span', + html.tag('a', + { + href: + language === defaultLanguage + ? to( + 'localizedDefaultLanguage.' + pagePath[0], + ...pagePath.slice(1)) + : to( + 'localizedWithBaseDirectory.' + pagePath[0], + language.code, + ...pagePath.slice(1)), + }, + language.name))); + + return html.tag('div', {class: 'footer-localization-links'}, + language.$('misc.uiLanguage', { + languages: links.join('\n'), + })); + }, +}; + +/* +function unbound_getFooterLocalizationLinks({ + html, + defaultLanguage, + language, + languages, + pagePath, + to, +}) { +} +*/ -- cgit 1.3.0-6-gf8a5