-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fix #193: clickable docs code samples on Svelte 5 #194
Conversation
How about doing this? export let data;
$: slug = data.slug;
$: content = data.content;
$: active = data.active; It's also three lines but more explicit. I think the double destructuring might have come after this Sveltekit 2 change: With Svelte 4 the page navigation seems to work even without the first declaration. Not sure if this was necessary for the Layer Cake site (I found this discussion https://twitter.com/geoffrich_/status/1564297325002227713) but this doesn't affect the not working destructuring with Svelte 5. |
Nice! Yeah, that makes sense — thanks for explaining the cause. :) |
Sorry — Yeah, this seems to be a because the reactive declaration |
Haha - I did quite a bit of searching to figure out what these commands meant! Could have been the automatic tool or the recommendation during one of the Sveltekit updates. In the Twitter thread Rich Harris also wrote:
|
This fixes #193. It looks like Svelte 5 slightly changes how reactivity works with
$:
on the data prop on a SvelteKit route.I addedif (slug !== data.slug)
so that the page content will still update on a navigation to a different frontend page. But this prevents the component from havingactive
stuck to be the first code file on the page.