feat [3/3]: add topic viewing
This commit is contained in:
1 parent
82a8747ad4
commit
a82d8c296d
14 files changed
+422
-319
No files matched your search
@@ -0,0 +1,68 @@
|
||||
<script lang="ts">
|
||||
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
|
||||
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||
import { PostListShell } from '$lib/components/ui/layout'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
import { communityLink } from '$lib/util.svelte.js'
|
||||
import { Spinner } from 'mono-svelte'
|
||||
import { SvelteURL } from 'svelte/reactivity'
|
||||
|
||||
let { data = $bindable() } = $props()
|
||||
|
||||
let title = $state('Loading...')
|
||||
data.topic.then((i) => (title = i?.title ?? ''))
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>
|
||||
{title}
|
||||
</title>
|
||||
</svelte:head>
|
||||
|
||||
<PostListShell
|
||||
client={data.client}
|
||||
posts={data.posts}
|
||||
cursor={data.next_page}
|
||||
getParams={data.params}
|
||||
params={{
|
||||
sort: data.params.sort!,
|
||||
}}
|
||||
>
|
||||
{#snippet extended()}
|
||||
<div class="min-h-56 grid place-items-center">
|
||||
{#await data.topic}
|
||||
<Spinner width={32} />
|
||||
{:then topic}
|
||||
{#if topic}
|
||||
<EntityHeader
|
||||
class="w-full relative flex flex-col"
|
||||
compact="always"
|
||||
avatarCircle={false}
|
||||
name={topic.name}
|
||||
>
|
||||
{#snippet nameDetail()}
|
||||
<p class="text-lg">{topic.name}</p>
|
||||
{/snippet}
|
||||
{#if topic.communities}
|
||||
<Expandable>
|
||||
{#snippet title()}
|
||||
{$t('content.communities')}
|
||||
{/snippet}
|
||||
<ItemList
|
||||
items={topic.communities.map((i) => ({
|
||||
id: i.id,
|
||||
name: i.title,
|
||||
url: communityLink(i),
|
||||
avatar: i.icon,
|
||||
instance: new SvelteURL(i.actor_id).hostname,
|
||||
}))}
|
||||
/>
|
||||
</Expandable>
|
||||
{/if}
|
||||
</EntityHeader>
|
||||
{/if}
|
||||
{/await}
|
||||
</div>
|
||||
{/snippet}
|
||||
</PostListShell>
|
||||
Reference in new issue
Block a user