feat: show crossposts

This commit is contained in:
Xyphyn committed 2023-08-18 18:44:36 -07:00
1 parent a6ca698625
commit a971e04bed
2 files changed
+45 -11

No files matched your search

@@ -5,6 +5,7 @@
export let community: Community export let community: Community
export let avatar: boolean = false export let avatar: boolean = false
export let name: boolean = true
export let avatarSize: number = 24 export let avatarSize: number = 24
export let showInstance: boolean | undefined = undefined export let showInstance: boolean | undefined = undefined
@@ -27,14 +28,16 @@
/> />
{/if} {/if}
<span class="flex gap-0"> {#if name}
{#if showInstance != undefined ? showInstance : $userSettings.showInstances.community} <span class="flex gap-0">
{community.title} {#if showInstance != undefined ? showInstance : $userSettings.showInstances.community}
<span class="text-slate-500 dark:text-zinc-500 font-normal"> {community.title}
@{new URL(community.actor_id).hostname} <span class="text-slate-500 dark:text-zinc-500 font-normal">
</span> @{new URL(community.actor_id).hostname}
{:else} </span>
{community.title} {:else}
{/if} {community.title}
</span> {/if}
</span>
{/if}
</a> </a>
@@ -2,7 +2,7 @@
import { buildCommentsTreeAsync } from '$lib/components/lemmy/comment/comments.js' import { buildCommentsTreeAsync } from '$lib/components/lemmy/comment/comments.js'
import Comments from '$lib/components/lemmy/comment/Comments.svelte' import Comments from '$lib/components/lemmy/comment/Comments.svelte'
import { isImage, isVideo } from '$lib/ui/image.js' import { isImage, isVideo } from '$lib/ui/image.js'
import { getClient } from '$lib/lemmy.js' import { getClient, getInstance } from '$lib/lemmy.js'
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte' import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
import { onMount } from 'svelte' import { onMount } from 'svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte' import Markdown from '$lib/components/markdown/Markdown.svelte'
@@ -20,6 +20,9 @@
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.js'
import { instance } from '$lib/instance.js' import { instance } from '$lib/instance.js'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
import Link from '$lib/components/input/Link.svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
export let data export let data
@@ -165,6 +168,34 @@
})} })}
/> />
</div> </div>
{#if data.post.cross_posts?.length > 0}
<div class="text-sm font-bold mt-2">
<SectionTitle class="text-inherit dark:text-inherit">
Crossposts <span class="text-slate-600 dark:text-zinc-400 text-xs ml-1">
{data.post.cross_posts.length}
</span>
</SectionTitle>
<div class="divide-y divide-slate-200 dark:divide-zinc-800 flex flex-col">
{#each data.post.cross_posts as crosspost}
<div class="py-2.5 flex flex-col gap-1">
<span class="text-xs flex flex-col pointer-events-none">
<CommunityLink
community={crosspost.community}
avatarSize={22}
avatar={true}
/>
</span>
<Link
class="text-sm"
href="/post/{$page.params.instance}/{crosspost.post.id}"
>
{crosspost.post.name}
</Link>
</div>
{/each}
</div>
</div>
{/if}
</div> </div>
<div class="mt-4 flex flex-col gap-2"> <div class="mt-4 flex flex-col gap-2">
<div class="font-bold text-lg"> <div class="font-bold text-lg">