rework page metadata and links

This commit is contained in:
vcoppe
2024-07-08 18:54:16 +02:00
parent 83cd3fd987
commit 65b297e133
17 changed files with 145 additions and 149 deletions

View File

@@ -1,18 +1,18 @@
export const languages: Record<string, string> = {
'en': 'English',
'fr': 'Français',
};
export function getURLForLanguage(lang?: string): string {
let currentPath = window.location.pathname;
let currentPathArray = currentPath.split('/');
if (currentPathArray.length > 1 && languages.hasOwnProperty(currentPathArray[1])) {
currentPathArray.splice(1, 1);
export function getURLForLanguage(route: string | null, lang: string | null | undefined): string {
if (route === null) {
return '/';
}
if (lang !== undefined && lang !== 'en') {
currentPathArray.splice(1, 0, lang);
}
let url = route.replace('[...language]', (lang === null || lang === undefined) ? 'en' : lang).replace('/en', '');
return currentPathArray.join('/');
if (url === '') {
return '/';
} else {
return url;
}
}