Store previous page globally from beforeNavigate
This commit is contained in:
@@ -66,7 +66,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define previous URL
|
// 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">
|
<script lang="ts">
|
||||||
import '../style/style.scss'
|
import '../style/style.scss'
|
||||||
import { navigating, page } from '$app/stores'
|
import { navigating, page } from '$app/stores'
|
||||||
|
import { beforeNavigate } from '$app/navigation'
|
||||||
import { onMount, setContext } from 'svelte'
|
import { onMount, setContext } from 'svelte'
|
||||||
import { pageLoading, previousPage } from '$utils/stores'
|
import { pageLoading, previousPage } from '$utils/stores'
|
||||||
import { DURATION } from '$utils/contants'
|
import { DURATION } from '$utils/contants'
|
||||||
@@ -24,10 +25,8 @@
|
|||||||
* On page change
|
* On page change
|
||||||
*/
|
*/
|
||||||
// Store previous page (for photo Viewer close button)
|
// Store previous page (for photo Viewer close button)
|
||||||
let previous = ''
|
beforeNavigate(({ from }) => {
|
||||||
page.subscribe(value => {
|
$previousPage = from.pathname
|
||||||
$previousPage = previous
|
|
||||||
previous = value.url.pathname
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Define page loading from navigating store
|
// Define page loading from navigating store
|
||||||
|
|||||||
Reference in New Issue
Block a user