mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-01 08:12:32 +00:00
correct alternate links
This commit is contained in:
@@ -4,7 +4,17 @@
|
|||||||
import { languages } from '$lib/languages';
|
import { languages } from '$lib/languages';
|
||||||
import { _, isLoading } from 'svelte-i18n';
|
import { _, isLoading } from 'svelte-i18n';
|
||||||
|
|
||||||
$: location = $page.route.id?.split('/')[2] ?? 'home';
|
let location: string;
|
||||||
|
|
||||||
|
$: if ($page.route.id) {
|
||||||
|
location = $page.route.id;
|
||||||
|
Object.keys($page.params).forEach((param) => {
|
||||||
|
if (param !== 'language') {
|
||||||
|
location = location.replace(`[${param}]`, $page.params[param]);
|
||||||
|
location = location.replace(`[...${param}]`, $page.params[param]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -46,15 +56,13 @@
|
|||||||
<link
|
<link
|
||||||
rel="alternate"
|
rel="alternate"
|
||||||
hreflang="x-default"
|
hreflang="x-default"
|
||||||
href="https://gpx.studio{base}/{location === 'home' ? '' : location}"
|
href="https://gpx.studio{base}{location.replace('/[...language]', '')}"
|
||||||
/>
|
/>
|
||||||
{#each Object.keys(languages) as lang}
|
{#each Object.keys(languages) as lang}
|
||||||
<link
|
<link
|
||||||
rel="alternate"
|
rel="alternate"
|
||||||
hreflang={lang}
|
hreflang={lang}
|
||||||
href="https://gpx.studio{base}/{lang === 'en' ? '' : lang + '/'}{location === 'home'
|
href="https://gpx.studio{base}{location.replace('[...language]', lang)}"
|
||||||
? ''
|
|
||||||
: location}"
|
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
Reference in New Issue
Block a user