misc: Improve error handling

This commit is contained in:
Xyphyn committed 2023-07-03 12:33:04 -07:00
1 parent 98b5e4b5c1
commit a5460a03b4
23 files changed
+285 -202

No files matched your search

@@ -0,0 +1,32 @@
<script lang="ts">
import type { Community } from 'lemmy-js-client'
export let community: Community
export let avatar: boolean = false
function linkFromCommunity(community: Community) {
const local = community.local
if (local) {
return `/c/${community.name}`
} else {
const domain = new URL(community.actor_id).hostname
return `/c/${community.name}@${domain}`
}
}
</script>
<a class="items-center flex flex-row gap-2" href={linkFromCommunity(community)}>
{#if avatar}
<img
src={community.icon ??
`https://api.dicebear.com/6.x/initials/svg?seed=${community.name}`}
alt=""
width={24}
height={24}
class="rounded-full aspect-square object-cover"
/>
{/if}
{community.title}
</a>