Store previous page globally from beforeNavigate

This commit is contained in:
2022-06-13 14:21:23 +02:00
parent 9a63338c92
commit 622e304efa
2 changed files with 4 additions and 5 deletions

View File

@@ -66,7 +66,7 @@
}
// Define previous URL
$: previousUrl = $previousPage ? $previousPage : `/${location.country.slug}/${location.slug}`
$: previousUrl = $previousPage ?? `/${location.country.slug}/${location.slug}`
/**

View File

@@ -1,6 +1,7 @@
<script lang="ts">
import '../style/style.scss'
import { navigating, page } from '$app/stores'
import { beforeNavigate } from '$app/navigation'
import { onMount, setContext } from 'svelte'
import { pageLoading, previousPage } from '$utils/stores'
import { DURATION } from '$utils/contants'
@@ -24,10 +25,8 @@
* On page change
*/
// Store previous page (for photo Viewer close button)
let previous = ''
page.subscribe(value => {
$previousPage = previous
previous = value.url.pathname
beforeNavigate(({ from }) => {
$previousPage = from.pathname
})
// Define page loading from navigating store