fix(docs): fix copyCode action breaking client-side navigation
Wrap article in {#key $page.url.pathname} so the copyCode action is fully destroyed and recreated on each route change. Without this, the action's DOM wrapper divs around <pre> elements persist across navigations, causing Svelte's DOM reconciliation to silently fail and render empty content on all subsequent pages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Yechan Kim committed
Apr 12, 2026 at 20:09 UTC
f0ec16344aa76a7448f596f087304d760e43b62e
1 file changed
+3
-1
docs/src/routes/+layout.svelte
+3
-1
@@ -137,9 +137,11 @@
137
</aside>
138
139
<main class="min-w-0 flex-1 px-4 py-8 lg:px-8">
140
- <article use:copyCode={$page.url.pathname} class="prose prose-gray dark:prose-invert mx-auto max-w-3xl">
140
+ {#key $page.url.pathname}
141
+ <article use:copyCode class="prose prose-gray dark:prose-invert mx-auto max-w-3xl">
142
{@render children()}
143
</article>
144
+ {/key}
145
<div class="mx-auto max-w-3xl">
146
<PrevNextNav prev={prevNext.prev} next={prevNext.next} />
147
</div>