feat: add community search to search page
This commit is contained in:
1 parent
819fde66ab
commit
e946d0de48
44 files changed
+79
-218
No files matched your search
@@ -1,5 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
||||
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
|
||||
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
@@ -29,7 +31,7 @@
|
||||
|
||||
export let data
|
||||
|
||||
let query = ''
|
||||
let query = data.query || ''
|
||||
|
||||
let pageNum = data.page
|
||||
</script>
|
||||
@@ -50,7 +52,7 @@
|
||||
Type
|
||||
</span>
|
||||
<option value="All">All</option>
|
||||
<option value="Local">Posts</option>
|
||||
<option value="Posts">Posts</option>
|
||||
<option value="Comments">Comments</option>
|
||||
<option value="Communities">Communities</option>
|
||||
<option value="Users">Users</option>
|
||||
@@ -70,6 +72,16 @@
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="max-w-sm mt-2">
|
||||
<ObjectAutocomplete
|
||||
label="Community"
|
||||
jwt={$profile?.jwt}
|
||||
listing_type={'All'}
|
||||
showWhenEmpty={true}
|
||||
on:select={(c) =>
|
||||
searchParam($page.url, 'community', c.detail?.id || undefined, 'page')}
|
||||
/>
|
||||
</div>
|
||||
{#if !data.results}
|
||||
<Placeholder
|
||||
icon={MagnifyingGlass}
|
||||
|
||||
@@ -15,7 +15,7 @@ import { get } from 'svelte/store'
|
||||
export async function load({ url, fetch }) {
|
||||
const query = url.searchParams.get('q')
|
||||
const page = Number(url.searchParams.get('page')) || 1
|
||||
const community = url.searchParams.get('community_name')
|
||||
const community = Number(url.searchParams.get('community')) || undefined
|
||||
const sort = url.searchParams.get('sort') || 'New'
|
||||
const type = url.searchParams.get('type') || 'All'
|
||||
|
||||
@@ -23,7 +23,7 @@ export async function load({ url, fetch }) {
|
||||
const results = await getClient(undefined, fetch).search({
|
||||
q: query,
|
||||
auth: get(profile)?.jwt,
|
||||
community_name: community ?? undefined,
|
||||
community_id: community ?? undefined,
|
||||
limit: 40,
|
||||
page: page,
|
||||
sort: (sort as SortType) || 'New',
|
||||
@@ -47,6 +47,7 @@ export async function load({ url, fetch }) {
|
||||
type: type,
|
||||
sort: sort,
|
||||
page: page,
|
||||
query: query,
|
||||
results: everything,
|
||||
streamed: {
|
||||
object: get(profile)?.jwt
|
||||
@@ -61,5 +62,8 @@ export async function load({ url, fetch }) {
|
||||
|
||||
return {
|
||||
page: 1,
|
||||
sort: sort,
|
||||
type: type,
|
||||
query: query,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user