fix: Fix #10
This commit is contained in:
1 parent
7ea6d141be
commit
90587cfa26
5 files changed
+29
-18
No files matched your search
+18
-11
@@ -2,6 +2,7 @@ import { authData, getClient } from '$lib/lemmy.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import type { ListingType, SortType } from 'lemmy-js-client'
|
||||
import { get } from 'svelte/store'
|
||||
import { error } from '@sveltejs/kit'
|
||||
|
||||
export async function load({ url }) {
|
||||
const page = Number(url.searchParams.get('page') || 1) || 1
|
||||
@@ -13,16 +14,22 @@ export async function load({ url }) {
|
||||
(url.searchParams.get('type') as ListingType) ||
|
||||
get(userSettings).defaultSort.feed
|
||||
|
||||
return {
|
||||
posts: getClient().getPosts({
|
||||
limit: 20,
|
||||
page: page,
|
||||
sort: sort,
|
||||
type_: listingType,
|
||||
auth: get(authData)?.token,
|
||||
}),
|
||||
streamed: {
|
||||
site: getClient().getSite({}),
|
||||
},
|
||||
try {
|
||||
return {
|
||||
posts: await getClient().getPosts({
|
||||
limit: 20,
|
||||
page: page,
|
||||
sort: sort,
|
||||
type_: listingType,
|
||||
auth: get(authData)?.token,
|
||||
}),
|
||||
streamed: {
|
||||
site: getClient().getSite({}),
|
||||
},
|
||||
}
|
||||
} catch (err) {
|
||||
throw error(500, {
|
||||
message: 'Failed to fetch homepage.',
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user