Skip to content
Snippets Groups Projects
Commit 59ac95ca authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

feat: add support for custom title

parent 1f38aa73
No related branches found
No related tags found
No related merge requests found
<template>
<time :datetime="isoRepresentation" :title="title">
<time
:datetime="isoRepresentation"
:title="title ? title({ formattedDate, date: datetime }) : formattedDate"
>
<slot :datetime="datetime" />
</time>
</template>
......@@ -12,11 +15,12 @@ import { ensureDate } from '@/util'
const props = defineProps<{
time: Date | string
title?: (data: { formattedDate: string; date: Date }) => string
}>()
const { locale } = useI18n()
const datetime = computed(() => ensureDate(props.time))
const isoRepresentation = computed(() => formatISO(datetime.value))
const title = computed(() =>
const formattedDate = computed(() =>
datetime.value.toLocaleString(locale.value, { dateStyle: 'full', timeStyle: 'medium' }),
)
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment