Skip to content

Commit e045358

Browse files
committed
use onversion mechanism
1 parent fe4c0cd commit e045358

File tree

1 file changed

+8
-13
lines changed
  • apps/svelte.dev/src/routes/(authed)/playground/[id]/embed

1 file changed

+8
-13
lines changed

apps/svelte.dev/src/routes/(authed)/playground/[id]/embed/+page.svelte

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,6 @@
1313
let repl = $state() as ReturnType<typeof Repl>;
1414
1515
let version = page.url.searchParams.get('version') || 'latest';
16-
let is_pr_or_commit_version = version.startsWith('pr-') || version.startsWith('commit-');
17-
18-
if (version !== 'local' && !is_pr_or_commit_version) {
19-
$effect(() => {
20-
fetch(`https://cdn.jsdelivr.net/npm/svelte@${version}/package.json`)
21-
.then((r) => r.json())
22-
.then((pkg) => {
23-
if (pkg.version !== data.version) {
24-
replaceState(`/playground/${data.gist.id}/embed?version=${pkg.version}`, {});
25-
}
26-
});
27-
});
28-
}
2916
3017
// TODO make this munging unnecessary
3118
function munge(data: any): File {
@@ -85,6 +72,14 @@
8572
injectedJS={mapbox_setup}
8673
previewTheme={theme.current}
8774
embedded={page.url.searchParams.has('output-only') ? 'output-only' : true}
75+
onversion={(v) => {
76+
if (version === v) return;
77+
78+
const url = new URL(location.href);
79+
url.searchParams.set('version', v);
80+
81+
replaceState(url, {});
82+
}}
8883
/>
8984
{/if}
9085
</div>

0 commit comments

Comments
 (0)