html: make post page more semantic
This commit is contained in:
1 parent
70a3a1610b
commit
f353e26f87
1 file changed
+86
-68
@@ -18,6 +18,7 @@
|
||||
Icon,
|
||||
InformationCircle,
|
||||
Home,
|
||||
PlusCircle,
|
||||
} from 'svelte-hero-icons'
|
||||
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
|
||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||
@@ -44,6 +45,7 @@
|
||||
import { t } from '$lib/translations.js'
|
||||
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
||||
import { resumables } from '$lib/lemmy/item.js'
|
||||
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
|
||||
|
||||
export let data
|
||||
|
||||
@@ -156,12 +158,22 @@
|
||||
<meta property="twitter:card" content={post.post_view.post.thumbnail_url} />
|
||||
{/if}
|
||||
{#if post.post_view.post.body}
|
||||
<meta property="og:description" content={post.post_view.post.body} />
|
||||
<meta property="twitter:description" content={post.post_view.post.body} />
|
||||
<meta
|
||||
property="description"
|
||||
content={post.post_view.post.body.slice(0, 500)}
|
||||
/>
|
||||
<meta
|
||||
property="og:description"
|
||||
content={post.post_view.post.body.slice(0, 500)}
|
||||
/>
|
||||
<meta
|
||||
property="twitter:description"
|
||||
content={post.post_view.post.body.slice(0, 500)}
|
||||
/>
|
||||
{/if}
|
||||
</svelte:head>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<article class="flex flex-col gap-2">
|
||||
{#if remoteView}
|
||||
<div
|
||||
class="sticky top-0 bg-slate-50 dark:bg-zinc-950 z-20
|
||||
@@ -199,8 +211,8 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="flex flex-row justify-between items-center gap-2 flex-wrap">
|
||||
<div class="w-max">
|
||||
<header class="flex flex-col gap-2">
|
||||
<div class="flex flex-row justify-between items-center gap-2 flex-wrap">
|
||||
<PostMeta
|
||||
community={post.post_view.community}
|
||||
user={post.post_view.creator}
|
||||
@@ -219,15 +231,16 @@
|
||||
}}
|
||||
published={publishedToDate(post.post_view.post.published)}
|
||||
bind:title={post.post_view.post.name}
|
||||
style="width: max-content;"
|
||||
/>
|
||||
<Button on:click={() => history.back()} size="square-md">
|
||||
<Icon src={ArrowLeft} mini size="16" slot="prefix" />
|
||||
</Button>
|
||||
</div>
|
||||
<Button on:click={() => history.back()} size="square-md">
|
||||
<Icon src={ArrowLeft} mini size="16" slot="prefix" />
|
||||
</Button>
|
||||
</div>
|
||||
<h1 class="font-bold text-xl font-display leading-5">
|
||||
<Markdown source={post.post_view.post.name} inline />
|
||||
</h1>
|
||||
<h1 class="font-bold text-xl font-display leading-5">
|
||||
<Markdown source={post.post_view.post.name} inline />
|
||||
</h1>
|
||||
</header>
|
||||
<PostMedia
|
||||
type={mediaType(post.post_view.post.url)}
|
||||
post={post.post_view.post}
|
||||
@@ -270,45 +283,38 @@
|
||||
</div>
|
||||
</Expandable>
|
||||
{/if}
|
||||
</div>
|
||||
{#if data.thread.showContext}
|
||||
<Material
|
||||
elevation="max"
|
||||
padding="none"
|
||||
color="distinct"
|
||||
class="py-2 px-4 text-sm flex flex-row justify-between items-center
|
||||
flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
||||
</article>
|
||||
{#if data.thread.showContext || data.thread.singleThread}
|
||||
<div
|
||||
class="sticky mx-auto z-50 max-w-full min-w-0 flex items-center gap-8 overflow-auto
|
||||
bg-slate-50/50 dark:bg-zinc-900/50 backdrop-blur-xl border border-slate-100/50 dark:border-zinc-800/50
|
||||
p-1 rounded-full px-2"
|
||||
style="top: max(1.5rem, {$contentPadding.top}px);"
|
||||
>
|
||||
<p class="font-medium text-sm flex items-center gap-2">
|
||||
<Icon src={InformationCircle} mini size="20" />
|
||||
{$t('routes.post.thread.part')}
|
||||
{data.thread.showContext
|
||||
? $t('routes.post.thread.part')
|
||||
: $t('routes.post.thread.single')}
|
||||
</p>
|
||||
<Button
|
||||
color="none"
|
||||
rounding="pill"
|
||||
{loading}
|
||||
disabled={loading}
|
||||
href="/comment/{$page.params.instance}/{data.thread.showContext}"
|
||||
href={data.thread.showContext
|
||||
? `/comment/${$page.params.instance}/${data.thread.showContext}`
|
||||
: undefined}
|
||||
class="hover:bg-slate-200/30 dark:hover:bg-zinc-800/30"
|
||||
on:click={data.thread.singleThread ? reloadComments : undefined}
|
||||
>
|
||||
{$t('routes.post.thread.context')}
|
||||
{data.thread.showContext
|
||||
? $t('routes.post.thread.context')
|
||||
: $t('routes.post.thread.allComments')}
|
||||
</Button>
|
||||
</Material>
|
||||
{:else if data.thread.singleThread}
|
||||
<Material
|
||||
elevation="max"
|
||||
padding="none"
|
||||
color="distinct"
|
||||
class="py-2 px-4 text-sm flex sm:flex-row justify-between items-center
|
||||
sm:gap-4 sticky top-20 w-full box-border z-20 mt-4 flex-col gap-2"
|
||||
>
|
||||
<p class="font-medium text-sm flex items-center gap-2">
|
||||
<Icon src={InformationCircle} mini size="20" />
|
||||
{$t('routes.post.thread.single')}
|
||||
</p>
|
||||
<Button {loading} disabled={loading} on:click={reloadComments}>
|
||||
{$t('routes.post.thread.allComments')}
|
||||
</Button>
|
||||
</Material>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="mt-4 flex flex-col gap-2 w-full">
|
||||
<section class="mt-4 flex flex-col gap-2 w-full">
|
||||
<div class="flex flex-row justify-between flex-wrap gap-2">
|
||||
<div class="text-base">
|
||||
<span class="font-bold">
|
||||
@@ -316,10 +322,10 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
||||
</span>
|
||||
{$t('routes.post.commentCount')}
|
||||
</div>
|
||||
<div class="gap-2 flex items-center h-8">
|
||||
<div class="gap-2 flex items-center h-full">
|
||||
<Select
|
||||
size="sm"
|
||||
class="!h-full"
|
||||
size="md"
|
||||
class="h-full"
|
||||
bind:value={commentSort}
|
||||
on:change={reloadComments}
|
||||
>
|
||||
@@ -335,7 +341,7 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
||||
</div>
|
||||
</div>
|
||||
{#await data.comments}
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="space-y-4">
|
||||
{#each new Array(10) as empty}
|
||||
<div class="animate-pulse flex flex-col gap-2 skeleton w-full">
|
||||
<div class="w-96 h-4" />
|
||||
@@ -346,28 +352,40 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
||||
</div>
|
||||
{:then comments}
|
||||
{#if $profile?.jwt}
|
||||
<CommentForm
|
||||
postId={post.post_view.post.id}
|
||||
on:comment={(comment) =>
|
||||
(comments.comments = [
|
||||
comment.detail.comment_view,
|
||||
...comments.comments,
|
||||
])}
|
||||
locked={(post.post_view.post.locked &&
|
||||
!(
|
||||
$profile?.user?.local_user_view.local_user.admin ||
|
||||
$profile?.user?.moderates
|
||||
.map((c) => c.community.id)
|
||||
.includes(data.post.community_view.community.id)
|
||||
)) ||
|
||||
$page.params.instance.toLowerCase() != $instance.toLowerCase()}
|
||||
banned={data.post.community_view.banned_from_community}
|
||||
on:focus={() => (commenting = true)}
|
||||
tools={commenting}
|
||||
preview={commenting}
|
||||
placeholder={commenting ? undefined : $t('routes.post.addComment')}
|
||||
rows={commenting ? 7 : 1}
|
||||
/>
|
||||
{#if !commenting}
|
||||
<Button
|
||||
rounding="pill"
|
||||
class="mx-auto"
|
||||
size="lg"
|
||||
on:click={() => (commenting = true)}
|
||||
>
|
||||
<Icon src={PlusCircle} size="16" micro />
|
||||
{$t('routes.post.addComment')}
|
||||
</Button>
|
||||
{:else}
|
||||
<CommentForm
|
||||
postId={post.post_view.post.id}
|
||||
on:comment={(comment) =>
|
||||
(comments.comments = [
|
||||
comment.detail.comment_view,
|
||||
...comments.comments,
|
||||
])}
|
||||
locked={(post.post_view.post.locked &&
|
||||
!(
|
||||
$profile?.user?.local_user_view.local_user.admin ||
|
||||
$profile?.user?.moderates
|
||||
.map((c) => c.community.id)
|
||||
.includes(data.post.community_view.community.id)
|
||||
)) ||
|
||||
$page.params.instance.toLowerCase() != $instance.toLowerCase()}
|
||||
banned={data.post.community_view.banned_from_community}
|
||||
on:focus={() => (commenting = true)}
|
||||
tools={commenting}
|
||||
preview={commenting}
|
||||
placeholder={commenting ? undefined : $t('routes.post.addComment')}
|
||||
rows={commenting ? 7 : 1}
|
||||
/>
|
||||
{/if}
|
||||
{/if}
|
||||
<Comments
|
||||
post={post.post_view.post}
|
||||
@@ -400,7 +418,7 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
||||
</Button>
|
||||
</EndPlaceholder>
|
||||
{/if}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style lang="postcss">
|
||||
.skeleton * {
|
||||
|
||||
Reference in new issue
Block a user