fix: Fix community links
This commit is contained in:
1 parent
e4d0f985c7
commit
b129db8ed5
3 files changed
+40
-4
No files matched your search
@@ -0,0 +1,19 @@
|
||||
<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>
|
||||
@@ -9,6 +9,7 @@
|
||||
import type { CommentNodeI } from './comments.js'
|
||||
import Comments from './Comments.svelte'
|
||||
import SvelteMarkdown from 'svelte-markdown'
|
||||
import CommunityLink from '$lib/components/CommunityLink.svelte'
|
||||
|
||||
export let data: { post: GetPostResponse; comments: GetCommentsResponse }
|
||||
|
||||
@@ -87,7 +88,7 @@
|
||||
<title>{data.post.post_view.post.name}</title>
|
||||
<div class="flex flex-col gap-2">
|
||||
<span class="flex flex-row gap-2 text-sm opacity-70">
|
||||
<a href="/">c/{postData.community.name}</a>
|
||||
<CommunityLink community={postData.community} />
|
||||
<span class="opacity-50">{postData.creator.name}</span>
|
||||
</span>
|
||||
<h1 class="font-bold text-lg">{post.name}</h1>
|
||||
@@ -108,7 +109,11 @@
|
||||
{/if}
|
||||
</div>
|
||||
<div class="mt-4 flex flex-col gap-2">
|
||||
<div class="font-bold text-lg">Comments</div>
|
||||
<div class="font-bold text-lg">
|
||||
Comments <span class="text-sm font-normal ml-2 opacity-80">
|
||||
{postData.counts.comments}
|
||||
</span>
|
||||
</div>
|
||||
<MultiSelect
|
||||
options={['hot', 'new', 'top']}
|
||||
optionNames={['Hot', 'New', 'Top']}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
} from 'svelte-hero-icons'
|
||||
import type { CommentNodeI } from './comments.js'
|
||||
import RelativeDate from '$lib/components/RelativeDate.svelte'
|
||||
import CommunityLink from '$lib/components/CommunityLink.svelte'
|
||||
|
||||
let postRes: PostView
|
||||
export { postRes as post }
|
||||
@@ -26,13 +27,15 @@
|
||||
>
|
||||
<div class="flex flex-col gap-2 bg-white dark:bg-zinc-900 p-4 rounded-md">
|
||||
<span class="flex flex-row gap-2 text-sm opacity-70">
|
||||
<a href="/c/{postRes.community.name}">c/{postRes.community.name}</a>
|
||||
<CommunityLink community={postRes.community} />
|
||||
<span class="opacity-50">{postRes.creator.name}</span>
|
||||
<span class="opacity-50">
|
||||
<RelativeDate date={new Date(postRes.post.published)} />
|
||||
</span>
|
||||
</span>
|
||||
<h1 class="font-bold text-lg">{postRes.post.name}</h1>
|
||||
<a href="/post/{postRes.post.id}" class="font-bold text-lg">
|
||||
{postRes.post.name}
|
||||
</a>
|
||||
{#if postRes.post.url}
|
||||
<a
|
||||
href={postRes.post.url}
|
||||
@@ -42,6 +45,15 @@
|
||||
{postRes.post.url}
|
||||
</a>
|
||||
{/if}
|
||||
{#if postRes.post.thumbnail_url}
|
||||
<a href="/post/{postRes.post.id}" class="inline self-start">
|
||||
<img
|
||||
src={postRes.post.thumbnail_url}
|
||||
alt={postRes.post.name}
|
||||
class="rounded-md max-h-64 max-w-max"
|
||||
/>
|
||||
</a>
|
||||
{/if}
|
||||
{#if postRes.post.body}
|
||||
<p class="text-sm max-h-24 line-clamp-3">
|
||||
{postRes.post.body}
|
||||
|
||||
Reference in new issue
Block a user