vigil/src/lib/FullPost.svelte

94 lines
2.7 KiB
Svelte
Raw Normal View History

2025-09-12 19:20:30 +02:00
<script lang="ts">
import { DateTime } from "luxon";
import { RiEditLine, RiFlagLine, RiHistoryLine, RiHome2Line, RiUserLine } from "svelte-remixicon";
2025-09-12 19:20:30 +02:00
import type { PostEntry } from "./backend";
import SLayout from "./SLayout.svelte";
import GuildAbout from "./GuildAbout.svelte";
import UserAbout from "./UserAbout.svelte";
import UserMenu from "./UserMenu.svelte";
import PostMeta from "./PostMeta.svelte";
import GuildMenu from "./GuildMenu.svelte";
import { SvelteShowdown } from "svelte-showdown";
2025-10-07 11:46:05 +02:00
import VoteButton from "./VoteButton.svelte";
import { getMe } from "./globals.svelte";
2025-10-23 12:57:04 +02:00
import CommentCount from "./CommentCount.svelte";
2025-10-23 15:43:00 +02:00
import CommentSection from "./CommentSection.svelte";
2025-09-12 19:20:30 +02:00
let { post }: { post: PostEntry } = $props();
let me = getMe();
2025-10-23 12:57:04 +02:00
let { title, id, content = '', to, votes, my_vote, comment_count } = post;
2025-09-12 19:20:30 +02:00
</script>
<SLayout title={to.display_name + (to.type === 'guild' ? ` (+${to.name})` : to.type === 'user' ? ` (@${to.username})` : '')}>
<article class="card">
<div class="post-frame" id={id}>
<div class="post-body">
<h1>{title}</h1>
<PostMeta {post} />
<!-- here go reports -->
<!-- here goes removal message -->
<div class="post-content">
<SvelteShowdown content={ content || "" } />
<!-- content, formatted as markdown -->
</div>
</div><!-- .post-body -->
2025-10-23 11:08:14 +02:00
<aside class="message-stats">
2025-09-12 19:20:30 +02:00
<!-- upvotes / downvotes -->
2025-10-23 11:08:14 +02:00
<VoteButton score={votes} vote={my_vote} {id} />
2025-10-23 12:57:04 +02:00
<CommentCount count={comment_count} />
2025-10-23 11:08:14 +02:00
</aside>
2025-09-12 19:20:30 +02:00
<ul class="message-options row">
{#if me && me.id !== post.author?.id}
<li><a href="/report/post/{id}"><RiFlagLine/> Report</a></li>
{/if}
{#if me && me.id === post.author?.id }
2025-10-23 09:59:18 +02:00
<li><a href="/edit/={id}"><RiEditLine/> Edit</a></li>
{/if}
2025-09-12 19:20:30 +02:00
</ul>
</div>
</article>
2025-10-23 15:43:00 +02:00
<CommentSection {post} />
2025-10-23 12:57:04 +02:00
2025-09-12 19:20:30 +02:00
{#snippet left()}
{#if to.type === 'guild'}
<GuildMenu guild={to} />
{:else if to.type == 'user'}
<UserMenu user={to} />
{/if}
{/snippet}
{#snippet right()}
{#if to.type === 'guild'}
<GuildAbout guild={to} />
{:else if to.type === 'user'}
<UserAbout user={to} />
{/if}
{/snippet}
</SLayout>
<style>
2025-10-07 11:46:05 +02:00
.post-frame {
position: relative;
}
2025-09-12 19:20:30 +02:00
.post-content {
overflow-x: auto;
}
2025-10-07 11:46:05 +02:00
.post-body {
2025-10-23 15:43:00 +02:00
margin-inline-start: 2em;
2025-10-07 11:46:05 +02:00
}
.message-stats {
position: absolute;
inset-inline-start: 0;
top: 0;
2025-10-23 15:43:00 +02:00
width: 2em;
2025-10-07 11:46:05 +02:00
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
}
2025-09-12 19:20:30 +02:00
</style>