diff --git a/src/routes/communities/+page.server.ts b/src/routes/communities/+page.server.ts index c1ab34ae..36c35ff2 100644 --- a/src/routes/communities/+page.server.ts +++ b/src/routes/communities/+page.server.ts @@ -4,11 +4,23 @@ import type { ListingType } from 'lemmy-js-client' export function load(req) { const type = req.url.searchParams.get('listingType') as ListingType const page = Number(req.url.searchParams.get('page')) || 1 + const query = req.url.searchParams.get('q') - return lemmy.listCommunities({ - limit: 40, - page: page, - sort: 'Active', - type_: type, - }) + if (query) { + return lemmy.search({ + limit: 40, + page: page, + sort: 'Active', + type_: 'Communities', + listing_type: type, + q: query, + }) + } else { + return lemmy.listCommunities({ + limit: 40, + page: page, + sort: 'Active', + type_: type, + }) + } } diff --git a/src/routes/communities/+page.svelte b/src/routes/communities/+page.svelte index d86157b8..1960bbae 100644 --- a/src/routes/communities/+page.svelte +++ b/src/routes/communities/+page.svelte @@ -10,23 +10,44 @@ UserGroup, } from 'svelte-hero-icons' import CommunityLink from '$lib/components/CommunityLink.svelte' + import Link from '$lib/components/Link.svelte' + import { Color } from '$lib/ui/colors.js' export let data + + let search = '' - { - const url = $page.url - url.searchParams.set('type', e.detail) - url.searchParams.delete('page') - goto(url, { - invalidateAll: true, - }) - }} -/> - +
+ { + const url = $page.url + url.searchParams.set('type', e.detail) + url.searchParams.delete('page') + goto(url, { + invalidateAll: true, + }) + }} + /> +
+ + + Search + +
+