mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 15:43:25 +00:00
rework page metadata and links
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user