2020-07-09 17:24:28 +02:00
|
|
|
<template>
|
|
|
|
<router-link
|
2022-07-12 10:55:28 +02:00
|
|
|
class="block md:flex bg-white dark:bg-violet-2 dark:text-white dark:hover:text-white rounded-lg shadow-md"
|
2021-11-07 21:02:06 +01:00
|
|
|
dir="auto"
|
2020-07-09 17:24:28 +02:00
|
|
|
:to="{ name: RouteName.POST, params: { slug: post.slug } }"
|
|
|
|
>
|
2021-11-02 19:47:54 +01:00
|
|
|
<lazy-image-wrapper
|
|
|
|
:picture="post.picture"
|
|
|
|
:rounded="true"
|
2022-07-12 10:55:28 +02:00
|
|
|
class="object-cover flex-none h-48 md:h-auto md:w-48 rounded-t-lg md:rounded-none md:rounded-l-lg"
|
2021-11-02 19:47:54 +01:00
|
|
|
/>
|
2022-07-12 10:55:28 +02:00
|
|
|
<div class="flex flex-col gap-1 bg-inherit p-2 rounded-lg flex-1">
|
|
|
|
<h3
|
|
|
|
class="text-xl color-violet-3 line-clamp-3 mb-2 font-bold"
|
|
|
|
:lang="post.language"
|
|
|
|
>
|
2021-11-13 15:58:54 +01:00
|
|
|
{{ post.title }}
|
|
|
|
</h3>
|
2022-07-12 10:55:28 +02:00
|
|
|
<p class="flex gap-2">
|
|
|
|
<Clock />
|
|
|
|
<span dir="auto" class="" v-if="isBeforeLastWeek">{{
|
|
|
|
formatDateTimeString(
|
|
|
|
publishedAt.toString(),
|
|
|
|
undefined,
|
|
|
|
false,
|
|
|
|
"short"
|
|
|
|
)
|
2021-11-02 19:47:54 +01:00
|
|
|
}}</span>
|
|
|
|
<span v-else>{{
|
|
|
|
formatDistanceToNow(publishedAt, {
|
2022-07-12 10:55:28 +02:00
|
|
|
locale: dateFnsLocale,
|
2021-11-02 19:47:54 +01:00
|
|
|
addSuffix: true,
|
|
|
|
})
|
|
|
|
}}</span>
|
|
|
|
</p>
|
2022-07-12 10:55:28 +02:00
|
|
|
<div v-if="postTags.length > 0" class="flex flex-wrap gap-y-0 gap-x-2">
|
|
|
|
<Tag />
|
|
|
|
<mbz-tag v-for="tag in postTags" :key="tag.slug">{{
|
|
|
|
tag.title
|
|
|
|
}}</mbz-tag>
|
|
|
|
</div>
|
|
|
|
<p class="flex gap-1" v-if="isCurrentActorMember">
|
|
|
|
<AccountEdit />
|
|
|
|
<i18n-t keypath="Published by {name}">
|
2022-08-12 16:42:40 +02:00
|
|
|
<template #name>
|
2022-07-12 10:55:28 +02:00
|
|
|
<b class="">{{ displayName(post.author) }}</b>
|
|
|
|
</template>
|
|
|
|
</i18n-t>
|
2021-11-02 19:47:54 +01:00
|
|
|
</p>
|
2020-07-09 17:24:28 +02:00
|
|
|
</div>
|
|
|
|
</router-link>
|
|
|
|
</template>
|
2022-07-12 10:55:28 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { formatDistanceToNow, subWeeks, isBefore, Locale } from "date-fns";
|
|
|
|
import RouteName from "@/router/name";
|
|
|
|
import { IPost } from "@/types/post.model";
|
2021-11-02 19:47:54 +01:00
|
|
|
import LazyImageWrapper from "@/components/Image/LazyImageWrapper.vue";
|
|
|
|
import { displayName } from "@/types/actor";
|
2022-07-12 10:55:28 +02:00
|
|
|
import { computed, inject } from "vue";
|
|
|
|
import { formatDateTimeString } from "@/filters/datetime";
|
|
|
|
import Tag from "vue-material-design-icons/Tag.vue";
|
|
|
|
import AccountEdit from "vue-material-design-icons/AccountEdit.vue";
|
|
|
|
import Clock from "vue-material-design-icons/Clock.vue";
|
2022-09-20 16:53:26 +02:00
|
|
|
import MbzTag from "@/components/TagElement.vue";
|
2020-07-09 17:24:28 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const props = withDefaults(
|
|
|
|
defineProps<{
|
|
|
|
post: IPost;
|
|
|
|
isCurrentActorMember?: boolean;
|
|
|
|
}>(),
|
|
|
|
{ isCurrentActorMember: false }
|
|
|
|
);
|
2020-07-09 17:24:28 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const dateFnsLocale = inject<Locale>("dateFnsLocale");
|
2020-10-13 20:39:59 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const postTags = computed(() => (props.post.tags ?? []).slice(0, 3));
|
2021-11-02 19:47:54 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const publishedAt = computed((): Date => {
|
|
|
|
return new Date((props.post.publishAt ?? props.post.insertedAt) as Date);
|
|
|
|
});
|
2021-11-02 19:47:54 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const isBeforeLastWeek = computed((): boolean => {
|
|
|
|
return isBefore(publishedAt.value, subWeeks(new Date(), 1));
|
|
|
|
});
|
2020-07-09 17:24:28 +02:00
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
2021-11-04 18:14:36 +01:00
|
|
|
@use "@/styles/_mixins" as *;
|
2022-07-12 10:55:28 +02:00
|
|
|
// @import "node_modules/bulma/sass/utilities/mixins.sass";
|
2021-11-02 19:47:54 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
// .post-minimalist-card-wrapper {
|
|
|
|
// display: grid;
|
|
|
|
// grid-gap: 5px 10px;
|
|
|
|
// grid-template-areas: "preview" "body";
|
|
|
|
// text-decoration: none;
|
|
|
|
// // width: 100%;
|
|
|
|
// // color: initial;
|
2020-07-09 17:24:28 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
// // @include desktop {
|
|
|
|
// grid-template-columns: 200px 3fr;
|
|
|
|
// grid-template-areas: "preview body";
|
|
|
|
// // }
|
2020-07-09 17:24:28 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
.title-info-wrapper {
|
|
|
|
.post-minimalist-title {
|
|
|
|
font-size: 18px;
|
|
|
|
line-height: 24px;
|
|
|
|
font-weight: 700;
|
|
|
|
overflow: hidden;
|
|
|
|
display: -webkit-box;
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
-webkit-line-clamp: 3;
|
2021-11-02 19:47:54 +01:00
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
}
|
|
|
|
:deep(.icon) {
|
|
|
|
vertical-align: middle;
|
|
|
|
// @include margin-right(5px);
|
|
|
|
}
|
2021-11-02 19:47:54 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
:deep(.tags) {
|
|
|
|
display: inline;
|
2021-11-02 19:47:54 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
span.tag {
|
|
|
|
max-width: 200px;
|
2021-11-02 19:47:54 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
& > span {
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2020-07-09 17:24:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
// }
|
2020-07-09 17:24:28 +02:00
|
|
|
</style>
|