diff --git a/sites/svelte.dev/src/lib/components/ReplWidget.svelte b/sites/svelte.dev/src/lib/components/ReplWidget.svelte deleted file mode 100644 index bba3f4aa95..0000000000 --- a/sites/svelte.dev/src/lib/components/ReplWidget.svelte +++ /dev/null @@ -1,95 +0,0 @@ - - -{#if browser} - -{/if} diff --git a/sites/svelte.dev/src/routes/(authed)/repl/[id]/embed/+page.server.js b/sites/svelte.dev/src/routes/(authed)/repl/[id]/embed/+page.server.js new file mode 100644 index 0000000000..5d80a583f3 --- /dev/null +++ b/sites/svelte.dev/src/routes/(authed)/repl/[id]/embed/+page.server.js @@ -0,0 +1,16 @@ +import { error } from '@sveltejs/kit'; + +export async function load({ fetch, params, url }) { + const res = await fetch(`/repl/api/${params.id}.json`); + + if (!res.ok) { + throw error(res.status); + } + + const gist = await res.json(); + + return { + gist, + version: url.searchParams.get('version') || '4' + }; +} diff --git a/sites/svelte.dev/src/routes/(authed)/repl/[id]/embed/+page.svelte b/sites/svelte.dev/src/routes/(authed)/repl/[id]/embed/+page.svelte new file mode 100644 index 0000000000..7592c53c24 --- /dev/null +++ b/sites/svelte.dev/src/routes/(authed)/repl/[id]/embed/+page.svelte @@ -0,0 +1,92 @@ + + + + {data.gist.name} • REPL • Svelte + + + + + + +
+ {#if browser} + + {/if} +
+ + diff --git a/sites/svelte.dev/src/routes/(authed)/repl/embed/+page.js b/sites/svelte.dev/src/routes/(authed)/repl/embed/+page.js deleted file mode 100644 index b27fec14d4..0000000000 --- a/sites/svelte.dev/src/routes/(authed)/repl/embed/+page.js +++ /dev/null @@ -1,8 +0,0 @@ -export function load({ url }) { - const query = url.searchParams; - return { - version: query.get('version') || '3', - gist: query.get('gist'), - example: query.get('example') - }; -} diff --git a/sites/svelte.dev/src/routes/(authed)/repl/embed/+page.server.js b/sites/svelte.dev/src/routes/(authed)/repl/embed/+page.server.js new file mode 100644 index 0000000000..d6f8ab11bb --- /dev/null +++ b/sites/svelte.dev/src/routes/(authed)/repl/embed/+page.server.js @@ -0,0 +1,14 @@ +import { redirect } from '@sveltejs/kit'; + +export function load({ url }) { + if (!url.searchParams.has('gist')) { + throw redirect(301, '/repl/hello-world/embed'); + } else { + const searchParamsWithoutGist = new URLSearchParams(url.searchParams); + searchParamsWithoutGist.delete('gist'); + throw redirect( + 301, + `/repl/${url.searchParams.get('gist')}/embed?${searchParamsWithoutGist.toString()}` + ); + } +} diff --git a/sites/svelte.dev/src/routes/(authed)/repl/embed/+page.svelte b/sites/svelte.dev/src/routes/(authed)/repl/embed/+page.svelte deleted file mode 100644 index 43fed8a1cb..0000000000 --- a/sites/svelte.dev/src/routes/(authed)/repl/embed/+page.svelte +++ /dev/null @@ -1,36 +0,0 @@ - - - - REPL • Svelte - - - - - - -
- {#if browser} - - {/if} -
- - diff --git a/sites/svelte.dev/src/routes/+layout.svelte b/sites/svelte.dev/src/routes/+layout.svelte index ab931bcd7a..9d1e6bdff9 100644 --- a/sites/svelte.dev/src/routes/+layout.svelte +++ b/sites/svelte.dev/src/routes/+layout.svelte @@ -33,7 +33,10 @@
- +