Skip to content

Commit

Permalink
migrate to sveltekit 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyphyn committed Feb 11, 2024
1 parent ff52be7 commit a7c1e2a
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 20 deletions.
Binary file modified bun.lockb
Binary file not shown.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
},
"devDependencies": {
"@catdadcode/svelte-adapter-bun": "^0.5.7",
"@sveltejs/adapter-node": "^1.3.1",
"@sveltejs/adapter-node": "^2.0.0",
"@sveltejs/adapter-vercel": "^5.1.0",
"@sveltejs/kit": "^1.24.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/markdown-it": "^12.2.3",
"@types/markdown-it-container": "^2.0.6",
"@types/nprogress": "^0.2.0",
Expand All @@ -37,9 +38,9 @@
"tailwindcss": "^3.3.3",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.3.0",
"vite": "^5.0.0",
"vite-plugin-pwa": "^0.16.5",
"vitest": "^0.33.0",
"vitest": "^1.0.0",
"workbox-window": "^7.0.0"
},
"dependencies": {
Expand All @@ -52,4 +53,4 @@
"@rollup/plugin-node-resolve": "^15.2.3"
},
"type": "module"
}
}
2 changes: 1 addition & 1 deletion src/lib/lemmy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function customFetch(
if (auth && url) url.searchParams.set('auth', auth)

const res = await f(url ?? input, init)
if (!res.ok) throw error(res.status, await res.text())
if (!res.ok) error(res.status, await res.text());
return res
}

Expand Down
6 changes: 3 additions & 3 deletions src/routes/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export async function load({ url, fetch }) {
},
}
} catch (err) {
throw error(500, {
message: 'Failed to fetch homepage.',
})
error(500, {
message: 'Failed to fetch homepage.',
});
}
}
2 changes: 1 addition & 1 deletion src/routes/admin/+page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { redirect } from '@sveltejs/kit'

export const load = () => {
throw redirect(300, '/admin/config')
redirect(300, '/admin/config');
}
2 changes: 1 addition & 1 deletion src/routes/comment/[instance]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { redirect } from '@sveltejs/kit'

export function load({ params }) {
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
throw redirect(300, `/comment/${getInstance()}/${params.instance}`)
redirect(300, `/comment/${getInstance()}/${params.instance}`);
}
8 changes: 4 additions & 4 deletions src/routes/comment/[instance]/[id]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export async function load({ params, fetch }) {
id: Number(params.id),
})

throw redirect(
300,
`/post/${params.instance}/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}`
)
redirect(
300,
`/post/${params.instance}/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}`
);
}
4 changes: 2 additions & 2 deletions src/routes/post/[instance]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export function load({ params, url }) {
const newUrl = new URL(url)
newUrl.pathname = split.join('/')

throw redirect(300, newUrl.toString())
redirect(300, newUrl.toString());
}

throw error(404, 'Not found')
error(404, 'Not found');
}
2 changes: 1 addition & 1 deletion src/routes/profile/+page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { redirect } from '@sveltejs/kit'

export const load = async () => {
throw redirect(300, '/profile/user')
redirect(300, '/profile/user');
}
2 changes: 1 addition & 1 deletion src/routes/signup/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { redirect } from "@sveltejs/kit";

export const load = () => {
if (LINKED_INSTANCE_URL) {
throw redirect(300, `/signup/${LINKED_INSTANCE_URL}`)
redirect(300, `/signup/${LINKED_INSTANCE_URL}`);
}
}
2 changes: 1 addition & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import node from '@sveltejs/adapter-node';
import bun from '@catdadcode/svelte-adapter-bun'
import vercel from '@sveltejs/adapter-vercel'
import { vitePreprocess } from '@sveltejs/kit/vite';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
Expand Down

0 comments on commit a7c1e2a

Please sign in to comment.