Store previous page globally from beforeNavigate
This commit is contained in:
@@ -66,7 +66,7 @@
|
||||
}
|
||||
|
||||
// Define previous URL
|
||||
$: previousUrl = $previousPage ? $previousPage : `/${location.country.slug}/${location.slug}`
|
||||
$: previousUrl = $previousPage ?? `/${location.country.slug}/${location.slug}`
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user