39 lines
674 B
Vue
39 lines
674 B
Vue
<script setup lang="ts">
|
|
import { momentFormat } from '~/utils/filters'
|
|
import { useTimeAgo } from '@vueuse/core'
|
|
import { computed } from 'vue'
|
|
|
|
interface Props {
|
|
date: string,
|
|
icon?: boolean
|
|
}
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
icon: false
|
|
})
|
|
|
|
const date = computed(() => new Date(props.date))
|
|
|
|
// TODO (wvffle): Translate useTimeAgo
|
|
const realDate = useTimeAgo(date)
|
|
</script>
|
|
|
|
<template>
|
|
<time
|
|
:datetime="date.toString()"
|
|
:title="momentFormat(date)"
|
|
>
|
|
<i
|
|
v-if="props.icon"
|
|
class="bi bi-clock"
|
|
/>
|
|
{{ realDate }}
|
|
</time>
|
|
</template>
|
|
|
|
<style scoped>
|
|
i {
|
|
margin-right: 8px;
|
|
font-size: 14px;
|
|
}
|
|
</style> |