migrate to sveltekit 2

remove-ttf-hack
Rich Harris 11 months ago
parent 1fcc3898bb
commit b791d0ad36

@ -31,7 +31,7 @@
"@sveltejs/adapter-vercel": "^5.1.0", "@sveltejs/adapter-vercel": "^5.1.0",
"@sveltejs/kit": "^2.4.1", "@sveltejs/kit": "^2.4.1",
"@sveltejs/site-kit": "6.0.0-next.50", "@sveltejs/site-kit": "6.0.0-next.50",
"@sveltejs/vite-plugin-svelte": "^2.4.6", "@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/cookie": "^0.5.2", "@types/cookie": "^0.5.2",
"@types/node": "^20.5.9", "@types/node": "^20.5.9",
"browserslist": "^4.21.10", "browserslist": "^4.21.10",
@ -54,7 +54,7 @@
"svelte-preprocess": "^5.0.4", "svelte-preprocess": "^5.0.4",
"tiny-glob": "^0.2.9", "tiny-glob": "^0.2.9",
"typescript": "^5.2.2", "typescript": "^5.2.2",
"vite": "^4.5.1", "vite": "^5.0.0",
"vite-imagetools": "^5.0.8" "vite-imagetools": "^5.0.8"
} }
} }

@ -9,7 +9,7 @@ export function load({ url }) {
// redirect to v2 REPL if appropriate // redirect to v2 REPL if appropriate
if (version && /^[^>]?[12]/.test(version)) { if (version && /^[^>]?[12]/.test(version)) {
throw redirect(302, `https://v2.svelte.dev/repl?${query}`); redirect(302, `https://v2.svelte.dev/repl?${query}`);
} }
const id = gist || example || 'hello-world'; const id = gist || example || 'hello-world';
@ -17,5 +17,5 @@ export function load({ url }) {
const q = new URLSearchParams(); const q = new URLSearchParams();
if (version) q.set('version', version); if (version) q.set('version', version);
if (vim) q.set('vim', vim); if (vim) q.set('vim', vim);
throw redirect(301, `/repl/${id}?${q}`); redirect(301, `/repl/${id}?${q}`);
} }

@ -4,7 +4,7 @@ export async function load({ fetch, params, url }) {
const res = await fetch(`/repl/api/${params.id}.json`); const res = await fetch(`/repl/api/${params.id}.json`);
if (!res.ok) { if (!res.ok) {
throw error(res.status); error(res.status);
} }
const gist = await res.json(); const gist = await res.json();

@ -73,13 +73,13 @@ export async function GET({ params }) {
} }
if (!UUID_REGEX.test(params.id)) { if (!UUID_REGEX.test(params.id)) {
throw error(404); error(404);
} }
const app = await gist.read(params.id); const app = await gist.read(params.id);
if (!app) { if (!app) {
throw error(404, 'not found'); error(404, 'not found');
} }
return json({ return json({

@ -4,7 +4,7 @@ import { error, json } from '@sveltejs/kit';
export async function POST({ request }) { export async function POST({ request }) {
const user = await session.from_cookie(request.headers.get('cookie')); const user = await session.from_cookie(request.headers.get('cookie'));
if (!user) throw error(401); if (!user) error(401);
const body = await request.json(); const body = await request.json();
const result = await gist.create(user, body); const result = await gist.create(user, body);

@ -5,7 +5,7 @@ import { error } from '@sveltejs/kit';
// TODO reimplement as an action // TODO reimplement as an action
export async function PUT({ params, request }) { export async function PUT({ params, request }) {
const user = await session.from_cookie(request.headers.get('cookie')); const user = await session.from_cookie(request.headers.get('cookie'));
if (!user) throw error(401, 'Unauthorized'); if (!user) error(401, 'Unauthorized');
const body = await request.json(); const body = await request.json();
await gist.update(user, params.id, body); await gist.update(user, params.id, body);

@ -11,7 +11,7 @@ export const GET = client_id
redirect_uri: `${url.origin}/auth/callback` redirect_uri: `${url.origin}/auth/callback`
}).toString(); }).toString();
throw redirect(302, Location); redirect(302, Location);
} }
: () => : () =>
new Response( new Response(

@ -6,7 +6,7 @@ export const prerender = true;
export async function load({ params }) { export async function load({ params }) {
const post = await get_processed_blog_post(await get_blog_data(), params.slug); const post = await get_processed_blog_post(await get_blog_data(), params.slug);
if (!post) throw error(404); if (!post) error(404);
// forgive me — terrible hack necessary to get diffs looking sensible // forgive me — terrible hack necessary to get diffs looking sensible
// on the `runes` blog post // on the `runes` blog post

@ -17,7 +17,7 @@ const font_data = await read(OverpassRegular).arrayBuffer();
export async function GET({ params }) { export async function GET({ params }) {
const post = await get_processed_blog_post(await get_blog_data(), params.slug); const post = await get_processed_blog_post(await get_blog_data(), params.slug);
if (!post) throw error(404); if (!post) error(404);
// @ts-ignore // @ts-ignore
const result = Card.render({ post }); const result = Card.render({ post });

@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import { dev } from '$app/environment'; import { dev } from '$app/environment';
export function load() { export function load() {
throw redirect(dev ? 307 : 308, '/docs'); redirect(dev ? 307 : 308, '/docs');
} }

@ -6,7 +6,7 @@ export const prerender = true;
export async function load({ params }) { export async function load({ params }) {
const processed_page = await get_parsed_docs(await get_docs_data(), params.slug); const processed_page = await get_parsed_docs(await get_docs_data(), params.slug);
if (!processed_page) throw error(404); if (!processed_page) error(404);
return { page: processed_page }; return { page: processed_page };
} }

@ -3,5 +3,5 @@ import { redirect } from '@sveltejs/kit';
export const prerender = true; export const prerender = true;
export function load() { export function load() {
throw redirect(301, 'examples/hello-world'); redirect(301, 'examples/hello-world');
} }

@ -12,7 +12,7 @@ export const GET = ({ params }) => {
.map((example) => example.slug) .map((example) => example.slug)
); );
if (!examples.has(params.slug)) throw error(404, 'Example not found'); if (!examples.has(params.slug)) error(404, 'Example not found');
return json(get_example(examples_data, params.slug)); return json(get_example(examples_data, params.slug));
}; };

@ -3,5 +3,5 @@ import { redirect } from '@sveltejs/kit';
export const prerender = true; export const prerender = true;
export function GET() { export function GET() {
throw redirect(308, '/docs/faq'); redirect(308, '/docs/faq');
} }

@ -1,8 +1,5 @@
import { redirect } from '@sveltejs/kit'; import { redirect } from '@sveltejs/kit';
export function load() { export function load() {
throw redirect( redirect(307, 'https://docs.google.com/document/d/1IA9Z5rcIm_KRxvh_L42d2NDdYRHZ72MfszhyJrsmf5A');
307,
'https://docs.google.com/document/d/1IA9Z5rcIm_KRxvh_L42d2NDdYRHZ72MfszhyJrsmf5A'
);
} }

@ -3,5 +3,5 @@ import { redirect } from '@sveltejs/kit';
export const prerender = true; export const prerender = true;
export function load() { export function load() {
throw redirect(301, '/tutorial/basics'); redirect(301, '/tutorial/basics');
} }

@ -8,14 +8,14 @@ import { error, redirect } from '@sveltejs/kit';
export const prerender = true; export const prerender = true;
export async function load({ params }) { export async function load({ params }) {
if (params.slug === 'local-transitions') throw redirect(307, '/tutorial/global-transitions'); if (params.slug === 'local-transitions') redirect(307, '/tutorial/global-transitions');
const tutorial_data = await get_tutorial_data(); const tutorial_data = await get_tutorial_data();
const tutorials_list = get_tutorial_list(tutorial_data); const tutorials_list = get_tutorial_list(tutorial_data);
const tutorial = await get_parsed_tutorial(tutorial_data, params.slug); const tutorial = await get_parsed_tutorial(tutorial_data, params.slug);
if (!tutorial) throw error(404); if (!tutorial) error(404);
return { return {
tutorials_list, tutorials_list,

Loading…
Cancel
Save