-
-
Notifications
You must be signed in to change notification settings - Fork 159
chore: ensure full page reloads between SvelteKit tutorial and other pages (and vice versa) #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I think this is probably the right thing to do, yeah. In terms of implementation could it be as simple as this, in function needs_isolation(url: URL) {
return $page.data.needs_isolation.includes(url.pathname);
}
beforeNavigate(({ from, to }) => {
if (needs_isolation(from.url) !== needs_isolation(to.url)) {
location.reload();
}
}); ...where ['/tutorial/introducing-sveltekit', '/tutorial/pages', '/tutorial/layouts', ...] |
This sounds good to me. |
I already implemented a client-side reload mechanism. The problem is the headers we need to set for the Vercel deployment. The tutorial is prerendered, therefore if you come from Google and directly visit the tutorial you'll get a prerendered shell, and the handle hook has no say in setting headers there, so it needs to be handled by either
|
Ah, gotcha. Then yeah, I think |
- gives us more leeway with duplicated slugs if needed later on - makes URL a bit more organized - will make it easier to set dedicated headers for the SvelteKit tutorial (#301) - fixes a bug with redirects not being picked up due to prerendering not coming across old slugs
* chore: separate tutorial URLs into svelte and kit - gives us more leeway with duplicated slugs if needed later on - makes URL a bit more organized - will make it easier to set dedicated headers for the SvelteKit tutorial (#301) - fixes a bug with redirects not being picked up due to prerendering not coming across old slugs * fix logic * fix a bunch of links or remove obsolete ones that have no replacement
I'm still confused about the |
The logic worked prior to the tutorial slug change, and of course it can be vastly simplified now - I just didn't get around to that yet. |
* use beforeNavigate * Update apps/svelte.dev/src/routes/+layout.svelte --------- Co-authored-by: Simon H <[email protected]>
#301 wasn't quite finished, this does finalize the work: - ensure cross origin headers are only set on SvelteKit tutorial pages - remove obsolete workarounds for getting cross origin iframes/images/audio/video working
* chore: cleanup headers, remove obsolete workarounds #301 wasn't quite finished, this does finalize the work: - ensure cross origin headers are only set on SvelteKit tutorial pages - remove obsolete workarounds for getting cross origin iframes/images/audio/video working * try this
Rather than having to ensure for every other page that loading images etc plays nice with the restrictive origin headers we set for the tutorial, we make navigations from/to the SvelteKit tutorial a full page reload. In practise you'll rarely cross this border, from my testing it's also barely noticeable. So the tiny drawback this has is worth the increased stability of the rest of the page to me.
WIP, this still needs to set the headers in dev and prod correctly - I'm not 100% sure how to do that since the URLs don't contain any info about sveltekit. The two approaches I see:
/tutorial/<slug of page>
we make it/tutorial/<svelte or sveltekit, depending on which part you're on>/<slug of page>
Any opinions on which way to go? Also, objections to the overall approach?