mirror of
https://github.com/kremalicious/blog.git
synced 2024-06-28 08:37:57 +02:00
21 lines
331 B
Plaintext
21 lines
331 B
Plaintext
|
---
|
||
|
import { format, formatDistance } from 'date-fns'
|
||
|
|
||
|
type Props = {
|
||
|
date: Date | undefined
|
||
|
}
|
||
|
|
||
|
const { date } = Astro.props
|
||
|
---
|
||
|
|
||
|
{
|
||
|
date ? (
|
||
|
<time
|
||
|
title={format(date, 'yyyy/MM/dd HH:mm')}
|
||
|
datetime={date.toISOString()}
|
||
|
>
|
||
|
{formatDistance(date, Date.now(), { addSuffix: true })}
|
||
|
</time>
|
||
|
) : null
|
||
|
}
|