diff --git a/apps/svelte.dev/src/hooks.server.js b/apps/svelte.dev/src/hooks.server.js index ea49afc4da..7dd6e768f2 100644 --- a/apps/svelte.dev/src/hooks.server.js +++ b/apps/svelte.dev/src/hooks.server.js @@ -19,24 +19,9 @@ const fonts = [ /** @type {import('@sveltejs/kit').Handle} */ export async function handle({ event, resolve }) { - // Best effort to redirect from Svelte 4 docs to new docs - if (event.url.pathname.startsWith('/docs')) { - const destination = mappings.get(event.url.pathname); - if (destination) { - redirect(307, destination); // TODO make 301 once we're sure - } + if (!event.url.pathname.startsWith('/playground')) { + redirect(301, 'https://svelte.dev/' + event.url.pathname); } - const response = await resolve(event, { - preload: ({ type, path }) => { - if (type === 'font') { - if (!path.endsWith('.woff2')) return false; - return fonts.some((font) => path.includes(font)); - } - - return type === 'js' || type === 'css'; // future-proof, if we add `assets` later - } - }); - - return response; + return resolve(event); } diff --git a/apps/svelte.dev/src/routes/(authed)/+layout.server.js b/apps/svelte.dev/src/routes/(authed)/+layout.server.js deleted file mode 100644 index 0ef4588346..0000000000 --- a/apps/svelte.dev/src/routes/(authed)/+layout.server.js +++ /dev/null @@ -1,12 +0,0 @@ -import * as session from '$lib/db/session'; - -/** @type {import('@sveltejs/adapter-vercel').Config} */ -export const config = { - runtime: 'nodejs20.x' // see https://github.com/sveltejs/svelte/pull/9136 -}; - -export async function load({ request }) { - return { - user: await session.from_cookie(request.headers.get('cookie')) - }; -} diff --git a/apps/svelte.dev/src/routes/(authed)/+layout.svelte b/apps/svelte.dev/src/routes/(authed)/+layout.svelte deleted file mode 100644 index 7b91ed29fb..0000000000 --- a/apps/svelte.dev/src/routes/(authed)/+layout.svelte +++ /dev/null @@ -1,27 +0,0 @@ - - - diff --git a/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.js b/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.js index b130a6663c..8f217bdef5 100644 --- a/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.js +++ b/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.js @@ -1,18 +1,14 @@ import { browser } from '$app/environment'; +import { redirect } from '@sveltejs/kit'; -export function load({ data, url }) { - // initialize vim with the search param - const vim_search_params = url.searchParams.get('vim'); - let vim = vim_search_params !== null && vim_search_params !== 'false'; - // when in the browser check if there's a local storage entry and eventually override - // vim if there's not a search params otherwise update the local storage +export function load() { + // redirect old svelte-5-preview.vercel.app playground links, + // which all have a hash that starts with this pattern if (browser) { - const vim_local_storage = window.localStorage.getItem('svelte:vim-enabled'); - if (vim_search_params !== null) { - window.localStorage.setItem('svelte:vim-enabled', vim.toString()); - } else if (vim_local_storage) { - vim = vim_local_storage !== 'false'; + if (location.hash) { + redirect(307, `https://svelte.dev/${location.pathname}#${location.hash}`); + } else { + redirect(307, `https://svelte.dev/${location.pathname}`); } } - return { ...data, vim }; } diff --git a/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.server.ts b/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.server.ts deleted file mode 100644 index 6bb2dfbdce..0000000000 --- a/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.server.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { error } from '@sveltejs/kit'; -import type { Examples } from '../api/examples/all.json/+server.js'; - -export async function load({ fetch, params, url }) { - const examples_res = fetch('/playground/api/examples/all.json').then((r) => r.json()); - const res = await fetch(`/playground/api/${params.id}.json`); - - if (!res.ok) { - error(res.status); - } - - const [gist, examples] = await Promise.all([res.json(), examples_res as Promise]); - - return { - gist, - examples: examples - .filter((section) => !section.title.includes('Embeds')) - .map((section) => ({ - title: section.title, - examples: section.examples.map((example) => ({ - title: example.title, - slug: example.slug - })) - })), - version: url.searchParams.get('version') || 'latest' - }; -} diff --git a/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.svelte b/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.svelte index bd9e6d6861..e69de29bb2 100644 --- a/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.svelte +++ b/apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.svelte @@ -1,223 +0,0 @@ - - - - {name} • Playground • Svelte - - - - - - - { - if (!setting_hash) { - set_files(); - } - }} -/> - -
- - - {#if browser} -
{ - // Only change hash on editor blur to not pollute everyone's browser history - if (modified) { - const json = JSON.stringify({ files: repl.toJSON().files }); - change_hash(json); - } - }} - > - -
- {/if} -
- - diff --git a/apps/svelte.dev/src/routes/(authed)/playground/api/examples/all.json/+server.ts b/apps/svelte.dev/src/routes/(authed)/playground/api/examples/all.json/+server.ts index 8e202001d8..99542d2d13 100644 --- a/apps/svelte.dev/src/routes/(authed)/playground/api/examples/all.json/+server.ts +++ b/apps/svelte.dev/src/routes/(authed)/playground/api/examples/all.json/+server.ts @@ -11,8 +11,6 @@ export type Examples = Array<{ }>; }>; -export const prerender = true; - async function munge(files: Record) { const result = []; diff --git a/apps/svelte.dev/src/routes/+layout.server.ts b/apps/svelte.dev/src/routes/+layout.server.ts deleted file mode 100644 index 7c8f9cf344..0000000000 --- a/apps/svelte.dev/src/routes/+layout.server.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { docs, index } from '$lib/server/content'; -import { fetchBanner } from '@sveltejs/site-kit/components'; -import type { NavigationLink } from '@sveltejs/site-kit'; - -const nav_links: NavigationLink[] = [ - { - title: 'Docs', - slug: 'docs', - sections: Object.values(docs.topics) - .map((topic) => ({ - title: topic.metadata.title, - path: '/' + topic.slug, // this will make the UI show a flyout menu for the docs nav entry - sections: topic.children.map((section) => ({ - title: section.metadata.title, - sections: section.children.map((page) => ({ - title: page.metadata.title, - path: '/' + page.slug - })) - })) - })) - .sort((a, b) => a.title.localeCompare(b.title)) // Svelte first - }, - { - title: 'Tutorial', - slug: 'tutorial', - sections: index.tutorial.children.map((topic) => ({ - title: topic.metadata.title, - sections: topic.children.map((section) => ({ - title: section.metadata.title, - sections: section.children.map((page) => ({ - title: page.metadata.title, - path: '/tutorial/' + page.slug.split('/').pop() - })) - })) - })) - }, - { - title: 'Playground', - slug: 'playground' - }, - { - title: 'Blog', - slug: 'blog' - } -]; - -const sections: Record = { - docs: 'Docs', - playground: 'Playground', - blog: 'Blog', - tutorial: 'Tutorial', - search: 'Search' -}; - -export const load = async ({ url, fetch }) => { - const banner = await fetchBanner('svelte.dev', fetch); - const nav_title = sections[url.pathname.split('/')[1]!] ?? ''; - - return { - nav_title, - nav_links, - banner - }; -}; diff --git a/apps/svelte.dev/src/routes/+layout.svelte b/apps/svelte.dev/src/routes/+layout.svelte deleted file mode 100644 index d8f6ef1cfe..0000000000 --- a/apps/svelte.dev/src/routes/+layout.svelte +++ /dev/null @@ -1,55 +0,0 @@ - - - - {#if !$page.route.id?.startsWith('/blog/')} - - - - {/if} - - - - {#snippet top_nav()} -