mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2025-02-05 08:34:43 +00:00
15 lines
430 B
TypeScript
15 lines
430 B
TypeScript
|
import { fetchCommunities } from "@utils/app";
|
||
|
import { hostname } from "@utils/helpers";
|
||
|
import { CommunityTribute } from "@utils/types";
|
||
|
|
||
|
export default async function communitySearch(
|
||
|
text: string
|
||
|
): Promise<CommunityTribute[]> {
|
||
|
const communitiesResponse = await fetchCommunities(text);
|
||
|
|
||
|
return communitiesResponse.map(cv => ({
|
||
|
key: `!${cv.community.name}@${hostname(cv.community.actor_id)}`,
|
||
|
view: cv,
|
||
|
}));
|
||
|
}
|