misc: Improve error handling
This commit is contained in:
1 parent
98b5e4b5c1
commit
a5460a03b4
23 files changed
+285
-202
No files matched your search
@@ -1,19 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { Community } from 'lemmy-js-client'
|
||||
|
||||
export let community: Community
|
||||
|
||||
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 href={linkFromCommunity(community)}>{community.title}</a>
|
||||
@@ -1,8 +1,7 @@
|
||||
<script lang="ts">
|
||||
import Link from '$lib/components/Link.svelte'
|
||||
import Logo from '$lib/components/Logo.svelte'
|
||||
|
||||
export let instance_url: string | undefined
|
||||
import { instance_url } from '$lib/lemmy.js'
|
||||
</script>
|
||||
|
||||
<nav
|
||||
@@ -14,13 +13,13 @@
|
||||
<Logo width={40} />
|
||||
<div class="flex flex-col">
|
||||
<span class="font-bold">Xylemmy</span>
|
||||
{#if instance_url}
|
||||
{#if $instance_url}
|
||||
<a
|
||||
class="text-xs opacity-50 hover:opacity-100 hover:underline
|
||||
transition-opacity"
|
||||
href="/instance"
|
||||
>
|
||||
{new URL(`https://${instance_url}`).hostname}
|
||||
{new URL(`https://${$instance_url}`).hostname}
|
||||
</a>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
Reference in new issue
Block a user