Hinzufügen von SsrSkip-Komponente in App.svelte
Some checks failed
deploy to production / deploy (push) Failing after 48s

This commit is contained in:
Sebastian Frank 2024-04-10 08:32:00 +00:00
parent 2054870366
commit de1aaadc46
Signed by: apairon
SSH Key Fingerprint: SHA256:lYVOnGlR42QHj7wuqfFgGw8cKbfyZUpzeRDGVBBAHQU
2 changed files with 20 additions and 0 deletions

View File

@ -12,6 +12,7 @@
import { loadContentAndSetStores } from "./lib/functions/fetch/loadContentAndSetStores"
import { loadNavigationAndSetStores } from "./lib/functions/fetch/loadNavigationAndSetStores"
import { loadLibraryAndSetStore } from "./lib/functions/fetch/loadLibraryAndSetStores"
import SsrSkip from "./lib/components/SsrSkip.svelte"
export let url = ""
@ -62,6 +63,7 @@
<ScrollTop />
<ScrollBottom />
<SsrSkip />
<style lang="less" global>
@import "./lib/assets/css/variables.less";

View File

@ -0,0 +1,18 @@
<script lang="ts">
import { location } from "../store"
let oldPath: string
$: if (typeof window !== "undefined" && oldPath !== $location.path) {
const ref = oldPath ? document.location.protocol + "//" + document.location.host + oldPath : document.referrer
oldPath = $location.path
fetch(oldPath, {
headers: {
"x-ssr-skip": "204",
"x-ssr-ref": ref,
"x-ssr-res": `${window.innerWidth}x${window.innerHeight}`,
// no cache
"cache-control": "no-cache, no-store, must-revalidate",
},
})
}
</script>