-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add community cards with a hacky slot parameter
- Loading branch information
Showing
9 changed files
with
78 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,25 @@ | ||
import { profile } from '$lib/auth.js' | ||
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte' | ||
import { getClient } from '$lib/lemmy.js' | ||
import { userSettings } from '$lib/settings.js' | ||
import type { ListingType, SortType } from 'lemmy-js-client' | ||
import { get } from 'svelte/store' | ||
|
||
export async function load(req: any) { | ||
const cursor: string | undefined = req.url.searchParams.get('cursor') | ||
const page = Number(req.url.searchParams.get('page')) || undefined | ||
|
||
const sort: SortType = | ||
(req.url.searchParams.get('sort') as SortType) || | ||
get(userSettings).defaultSort.sort | ||
const community = await getClient(undefined, req.fetch).getCommunity({ | ||
name: req.params.name, | ||
}) | ||
|
||
return { | ||
sort: sort, | ||
page: page || 1, | ||
posts: getClient(undefined, req.fetch).getPosts({ | ||
limit: 40, | ||
community_name: req.params.name, | ||
page: page, | ||
sort: sort, | ||
page_cursor: cursor | ||
}), | ||
community: getClient(undefined, req.fetch).getCommunity({ | ||
name: req.params.name, | ||
}), | ||
community: community, | ||
slots: { | ||
sidebar: { | ||
component: CommunityCard, | ||
props: { | ||
community_view: community.community_view, | ||
moderators: community.moderators, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { client } from '$lib/lemmy.js' | ||
import { userSettings } from '$lib/settings.js' | ||
import type { SortType } from 'lemmy-js-client' | ||
import { get } from 'svelte/store' | ||
|
||
export async function load({ params, fetch, url }) { | ||
const cursor: string | undefined = url.searchParams.get('cursor') as | ||
| string | ||
| undefined | ||
const page = Number(url.searchParams.get('page')) || undefined | ||
|
||
const sort: SortType = | ||
(url.searchParams.get('sort') as SortType) || | ||
get(userSettings).defaultSort.sort | ||
|
||
return { | ||
sort: sort, | ||
page: page || 1, | ||
posts: client({ func: fetch }).getPosts({ | ||
limit: 40, | ||
community_name: params.name, | ||
page: page, | ||
sort: sort, | ||
page_cursor: cursor, | ||
}), | ||
} | ||
} |