misc: Improve error handling

This commit is contained in:
Xyphyn committed 2023-07-03 12:33:04 -07:00
1 parent 98b5e4b5c1
commit a5460a03b4
23 files changed
+285 -202

No files matched your search

+22 -4
View File
@@ -1,5 +1,23 @@
import { redirect } from '@sveltejs/kit';
import { getClient } from '$lib/lemmy.js'
import type { ListingType, SortType } from 'lemmy-js-client'
export function load({ params }) {
throw redirect(300, `/c/${params.name}/posts`)
}
export function load(req: any) {
const page = Number(req.url.searchParams.get('page') || 1) || 1
const sort: SortType =
(req.url.searchParams.get('sort') as SortType) || 'Active'
return {
posts: getClient().getPosts({
limit: 40,
community_name: req.params.name,
page: page,
sort: sort,
}),
streamed: {
community: getClient().getCommunity({
name: req.params.name,
}),
},
}
}