Capital/components/PostItem.vue

83 lines
2.9 KiB
Vue
Raw Normal View History

2024-08-10 09:42:49 +00:00
<template>
2024-08-18 17:18:27 +00:00
<v-card :to="url" class="mx-[2.5ch] mb-3">
2024-08-10 09:42:49 +00:00
<v-card-text>
<div class="mb-3 flex flex-row gap-4">
<nuxt-link :to="`/users/${post.publisher?.name}`">
<v-avatar :image="post.publisher?.avatar" />
2024-09-22 12:15:32 +00:00
</nuxt-link>
2024-08-10 09:42:49 +00:00
<div class="flex flex-col">
<span>{{ post.publisher?.nick }} <span class="text-xs">@{{ post.publisher?.name }}</span></span>
2024-08-10 09:42:49 +00:00
<span v-if="post.body?.title" class="text-md">{{ post.body?.title }}</span>
<span v-if="post.body?.description" class="text-sm">{{ post.body?.description }}</span>
2024-08-19 04:05:13 +00:00
<span v-if="!post.body?.title && !post.body?.description" class="text-sm">
{{ post.publisher?.description }}
2024-08-19 04:05:13 +00:00
</span>
2024-08-22 09:32:56 +00:00
<div v-if="post.type != 'story'" class="mt-1">
<v-btn size="x-small" variant="flat" append-icon="mdi-arrow-right" :text="t('continueReading')" />
</div>
2024-08-10 09:42:49 +00:00
</div>
</div>
<div v-if="post.body?.thumbnail" class="mb-5">
<v-img
:src="`${config.public.solarNetworkApi}/cgi/uc/attachments/${post.body?.thumbnail}`"
:aspect-ratio="16 / 9"
2024-08-16 12:07:20 +00:00
alt="Post thumbnail"
class="rounded-md"
cover
/>
</div>
2024-08-16 12:07:20 +00:00
<article v-if="post.type == 'story' || props.forceShowContent" class="text-base prose max-w-none">
2024-08-10 09:42:49 +00:00
<m-d-c :value="post.body?.content"></m-d-c>
</article>
<v-card v-if="post.body?.attachments?.length > 0" class="mb-5">
<attachment-carousel
:no-clickable-attachment="props.noClickableAttachment"
:attachments="post.body?.attachments"
/>
2024-08-10 09:42:49 +00:00
</v-card>
2024-08-11 14:26:29 +00:00
<div class="text-sm flex flex-col">
2024-08-10 09:42:49 +00:00
<span class="flex flex-row gap-1">
<span>
{{ post.metric.reply_count }} {{ post.metric.reply_count > 1 ? "replies" : "reply" }},
</span>
<span>
{{ post.metric.reaction_count }} {{ post.metric.reaction_count > 1 ? "reactions" : "reaction" }}
</span>
</span>
<span>
{{ post.type.startsWith("a") ? "An" : "A" }} {{ post.type }} posted on
{{ new Date(post.published_at).toLocaleString() }}
</span>
</div>
<div
v-if="post.tags?.length > 0"
class="text-xs text-grey flex flex-row gap-1 mt-3"
>
<nuxt-link
v-for="tag in post.tags"
:to="`/posts/tags/${tag.alias}`"
class="hover:underline hover:underline-dotted"
@click.stop
>
#{{ tag.alias }}
</nuxt-link>
2024-08-10 09:42:49 +00:00
</div>
</v-card-text>
</v-card>
</template>
<script setup lang="ts">
2024-08-16 16:43:08 +00:00
const props = defineProps<{ post: any, forceShowContent?: boolean, noClickableAttachment?: boolean }>()
const config = useRuntimeConfig()
2024-08-18 17:18:27 +00:00
2024-08-22 09:32:56 +00:00
const { t } = useI18n()
2024-08-18 17:18:27 +00:00
const url = computed(() => props.post.alias ? `/posts/${props.post.area_alias}/${props.post.alias}` : `/posts/${props.post.id}`)
2024-08-10 09:42:49 +00:00
</script>