feat: Add posts to profile pages
This commit is contained in:
1 parent
948ad6fb1c
commit
28d9820b1e
5 files changed
+69
-29
No files matched your search
@@ -14,7 +14,6 @@
|
|||||||
PencilSquare,
|
PencilSquare,
|
||||||
UserGroup,
|
UserGroup,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
|
||||||
|
|
||||||
export let community_view: CommunityView
|
export let community_view: CommunityView
|
||||||
</script>
|
</script>
|
||||||
@@ -26,7 +25,7 @@
|
|||||||
`https://api.dicebear.com/6.x/initials/svg?seed=${community_view.community.name}`}
|
`https://api.dicebear.com/6.x/initials/svg?seed=${community_view.community.name}`}
|
||||||
alt={community_view.community.name}
|
alt={community_view.community.name}
|
||||||
/>
|
/>
|
||||||
<span class="flex flex-row items-center gap-1 text-sm">
|
<span class="flex flex-row items-center gap-1 text-sm capitalize">
|
||||||
<Icon src={Calendar} width={16} height={16} mini />
|
<Icon src={Calendar} width={16} height={16} mini />
|
||||||
<RelativeDate date={new Date(community_view.community.published)} />
|
<RelativeDate date={new Date(community_view.community.published)} />
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card class="bg-white flex flex-col overflow-hidden max-w-xl w-full relative">
|
<Card class="bg-white flex flex-col overflow-hidden w-full relative">
|
||||||
<div class="flex flex-col gap-2 bg-white dark:bg-zinc-900 p-4 rounded-md">
|
<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-xs items-center">
|
<span class="flex flex-row gap-2 text-xs items-center">
|
||||||
<CommunityLink avatarSize={20} avatar community={postRes.community} />
|
<CommunityLink avatarSize={20} avatar community={postRes.community} />
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
<title>Xylemmy</title>
|
<title>Xylemmy</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-row gap-4">
|
<div class="flex flex-row gap-4 justify-between">
|
||||||
<div class="flex flex-col gap-4 max-w-full">
|
<div class="flex flex-col gap-4 max-w-full w-full">
|
||||||
<div class="flex flex-col sm:flex-row gap-4 max-w-full">
|
<div class="flex flex-col sm:flex-row gap-4 max-w-full">
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
options={['Subscribed', 'Local', 'All']}
|
options={['Subscribed', 'Local', 'All']}
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-auto hidden lg:block max-w-sm w-full">
|
<div class="hidden lg:block max-w-sm w-full">
|
||||||
{#await data.streamed.site}
|
{#await data.streamed.site}
|
||||||
<Card>
|
<Card>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-row gap-4 justify-between">
|
<div class="flex flex-row gap-4 justify-between">
|
||||||
<div class="flex flex-col gap-4 max-w-full">
|
<div class="flex flex-col gap-4 max-w-full w-full">
|
||||||
<div class="flex flex-col sm:flex-row gap-4 max-w-full">
|
<div class="flex flex-col sm:flex-row gap-4 max-w-full w-full">
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
options={['Active', 'Hot', 'TopAll', 'New']}
|
options={['Active', 'Hot', 'TopAll', 'New']}
|
||||||
optionNames={['Active', 'Hot', 'Top', 'New']}
|
optionNames={['Active', 'Hot', 'Top', 'New']}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
||||||
import Link from '$lib/components/input/Link.svelte'
|
import Link from '$lib/components/input/Link.svelte'
|
||||||
|
import Post from '$lib/components/lemmy/Post.svelte'
|
||||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
@@ -8,7 +9,12 @@
|
|||||||
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
import type { GetPersonDetailsResponse } from 'lemmy-js-client'
|
import { getClient } from '$lib/lemmy.js'
|
||||||
|
import type {
|
||||||
|
CommentView,
|
||||||
|
GetPersonDetailsResponse,
|
||||||
|
PostView,
|
||||||
|
} from 'lemmy-js-client'
|
||||||
import {
|
import {
|
||||||
Calendar,
|
Calendar,
|
||||||
ChatBubbleOvalLeftEllipsis,
|
ChatBubbleOvalLeftEllipsis,
|
||||||
@@ -19,6 +25,35 @@
|
|||||||
export let data: {
|
export let data: {
|
||||||
user: GetPersonDetailsResponse
|
user: GetPersonDetailsResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Item {
|
||||||
|
post: boolean
|
||||||
|
comment: boolean
|
||||||
|
item: CommentView & PostView
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDateOfItem(item: Item): number {
|
||||||
|
if (item.post) {
|
||||||
|
return Date.parse(item.item.post.published)
|
||||||
|
} else if (item.comment) {
|
||||||
|
return Date.parse(item.item.comment.published)
|
||||||
|
} else {
|
||||||
|
return Date.now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const items: Item[] = [...data.user.comments, ...data.user.posts]
|
||||||
|
.map((i) => {
|
||||||
|
const post = 'read' in i
|
||||||
|
const comment = !post
|
||||||
|
|
||||||
|
return {
|
||||||
|
post: post,
|
||||||
|
comment: comment,
|
||||||
|
item: i as CommentView & PostView,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.sort((a, b) => getDateOfItem(b) - getDateOfItem(a))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -27,27 +62,33 @@
|
|||||||
|
|
||||||
<div class="flex flex-row gap-4 max-w-full">
|
<div class="flex flex-row gap-4 max-w-full">
|
||||||
<div class="flex flex-col gap-4 max-w-full">
|
<div class="flex flex-col gap-4 max-w-full">
|
||||||
{#each data.user.comments as item}
|
{#each items as item}
|
||||||
<Card class="flex flex-col bg-white rounded-md p-4 flex-1">
|
{#if item.post}
|
||||||
<div class="flex flex-row justify-between items-center">
|
<Post post={item.item} />
|
||||||
<div class="flex flex-col gap-1">
|
{:else}
|
||||||
<span class="text-xs dark:text-slate-400 text-zinc-600">
|
<Card class="flex flex-col bg-white rounded-md p-4 flex-1">
|
||||||
<CommunityLink avatar community={item.community} />
|
<div class="flex flex-row justify-between items-center">
|
||||||
</span>
|
<div class="flex flex-col gap-1">
|
||||||
<span class="flex flex-row items-center text-sm font-bold">
|
<span class="text-xs dark:text-slate-400 text-zinc-600">
|
||||||
{item.post.name}
|
<CommunityLink avatar community={item.item.community} />
|
||||||
</span>
|
</span>
|
||||||
|
<span class="flex flex-row items-center text-sm font-bold">
|
||||||
|
{item.item.post.name}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<Link href="/post/{item.item.post.id}#{item.item.comment.id}">
|
||||||
|
Jump
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<Link href="/post/{item.post.id}#{item.comment.id}">Jump</Link>
|
<div class="list-none">
|
||||||
</div>
|
<Comment
|
||||||
<div class="list-none">
|
postId={item.item.post.id}
|
||||||
<Comment
|
node={{ children: [], comment_view: item.item, depth: 1 }}
|
||||||
postId={item.post.id}
|
replying={false}
|
||||||
node={{ children: [], comment_view: item, depth: 1 }}
|
/>
|
||||||
replying={false}
|
</div>
|
||||||
/>
|
</Card>
|
||||||
</div>
|
{/if}
|
||||||
</Card>
|
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user