{#if type == 'community'} { const results = await getClient(instance).search({ q: q || ' ', type_: 'Communities', limit: 20, listing_type: listing_type, sort: 'TopAll', }) return results.communities.map((c) => c.community) }} extractName={(c) => `${c.title}@${new URL(c.actor_id).hostname}`} on:select bind:query={q} {showWhenEmpty} {...$$restProps} let:item let:select >
{#if q == '' && showWhenEmpty} dispatcher('select', undefined)}>
None
{:else} No results. {/if}
select(item)}>
{item.title} {new URL(item.actor_id).hostname}
{:else if type == 'instance'} { const results = await instances || {} return q ? (results.federated_instances?.linked || []).filter( (i) => i.software === 'lemmy' && i.domain.includes(q) ) : [] }} extractName={(i) => `${i.domain}`} on:select bind:query={q} {showWhenEmpty} {...$$restProps} let:item let:select >
{#if q == '' && showWhenEmpty} dispatcher('select', undefined)}>
None (Start typing to search)
{:else} No results. {/if}
select(item)}>
{item.domain}
{/if}