blob: 0c7b2d744fa6ff761a7b539ecdc067966738dd11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
---
import type { HTMLAttributes } from "astro/types";
import { getFormattedDate } from "@/utils/date";
type Props = HTMLAttributes<"time"> & {
date: Date;
dateTimeOptions?: Intl.DateTimeFormatOptions;
locale?: string | undefined;
};
const { date, dateTimeOptions, locale, ...attrs } = Astro.props;
const postDate = getFormattedDate(date, dateTimeOptions, locale);
const ISO = date.toISOString();
---
<time datetime={ISO} title={ISO} {...attrs}>{postDate}</time>
|