24 lines
670 B
Svelte
24 lines
670 B
Svelte
<script lang="ts">
|
|
import { onMount } from 'svelte';
|
|
import { get } from 'svelte/store';
|
|
|
|
import { goto } from '$app/navigation';
|
|
import { resolve } from '$app/paths';
|
|
|
|
import { storedLocation } from '$lib/stores/settings';
|
|
|
|
import { buildLocationRoute } from '$lib/utils/location';
|
|
|
|
// at build time this page knows nothing about the visitor, so the redirect
|
|
// target (the persisted location) is resolved in the browser instead of
|
|
// being baked to the default city during prerender
|
|
onMount(() => {
|
|
goto(
|
|
resolve('/weather/compare/[location]', { location: buildLocationRoute(get(storedLocation)) }),
|
|
{
|
|
replaceState: true
|
|
}
|
|
);
|
|
});
|
|
</script>
|