feat: add sort to community search page
This commit is contained in:
1 parent
d3ba6d969c
commit
e9168d055e
7 files changed
+79
-55
No files matched your search
@@ -22,8 +22,8 @@
|
||||
PersonView,
|
||||
PostView,
|
||||
} from 'lemmy-js-client'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Icon, MagnifyingGlass } from 'svelte-hero-icons'
|
||||
import { Button, Select } from 'mono-svelte'
|
||||
import { Bars3BottomRight, Icon, MagnifyingGlass } from 'svelte-hero-icons'
|
||||
import { expoInOut, expoOut } from 'svelte/easing'
|
||||
import { fly, slide } from 'svelte/transition'
|
||||
|
||||
@@ -42,11 +42,21 @@
|
||||
|
||||
<h1 class="font-bold text-2xl">Search</h1>
|
||||
<div class="flex flex-row flex-wrap sm:justify-between items-center gap-4 mt-4">
|
||||
<MultiSelect
|
||||
options={['All', 'Posts', 'Comments', 'Communities', 'Users']}
|
||||
selected={$page.url.searchParams.get('type') ?? 'All'}
|
||||
on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')}
|
||||
/>
|
||||
<Select
|
||||
class="w-48"
|
||||
bind:value={data.type}
|
||||
on:change={() => searchParam($page.url, 'type', data.type ?? 'All', 'page')}
|
||||
>
|
||||
<span slot="label" class="flex items-center gap-1">
|
||||
<Icon src={Bars3BottomRight} mini size="15" />
|
||||
Type
|
||||
</span>
|
||||
<option value="All">All</option>
|
||||
<option value="Local">Posts</option>
|
||||
<option value="Comments">Comments</option>
|
||||
<option value="Communities">Communities</option>
|
||||
<option value="Users">Users</option>
|
||||
</Select>
|
||||
<div class="flex flex-row gap-2 items-center">
|
||||
<TextInput
|
||||
bind:value={query}
|
||||
|
||||
@@ -16,8 +16,8 @@ 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 sort = url.searchParams.get('sort')
|
||||
const type = url.searchParams.get('type')
|
||||
const sort = url.searchParams.get('sort') || 'New'
|
||||
const type = url.searchParams.get('type') || 'All'
|
||||
|
||||
if (query) {
|
||||
const results = await getClient(undefined, fetch).search({
|
||||
@@ -44,6 +44,8 @@ export async function load({ url, fetch }) {
|
||||
)
|
||||
|
||||
return {
|
||||
type: type,
|
||||
sort: sort,
|
||||
page: page,
|
||||
results: everything,
|
||||
streamed: {
|
||||
|
||||
Reference in new issue
Block a user