Skip to content

Commit

Permalink
Handle updates
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Oct 3, 2024
1 parent cec2b2d commit adc822a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
<script>
import { browser } from "$app/environment";
import { beforeNavigate } from "$app/navigation";
import { updated } from "$app/stores";
import { locale } from "svelte-i18n";
import "@/style/variables.css";
import "@/style/global.css";
import "@/style/kit.css";
$: useCyrillicCharset = browser ? ["uk", "ru"].includes($locale) : false;
// this checks if the site has been updated and triggers a full page reload
// on the next navigation to update the cache
beforeNavigate(({ willUnload, to }) => {
if ($updated && !willUnload && to?.url) {
location.href = to.url.href;
}
});
// https://vite.dev/guide/build#load-error-handling
function reload() {
window.location.reload();
}
</script>
<svelte:head>
Expand All @@ -16,4 +32,6 @@
{/if}
</svelte:head>
<svelte:window on:vite:preloadError={reload} />
<slot />

0 comments on commit adc822a

Please sign in to comment.