diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-03 10:56:21 +0300 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-03 10:56:21 +0300 |
| commit | 456cf011b36de91c9936994b1fa45703adcd309b (patch) | |
| tree | 8e60daf998f731ac50d100fa490eaecae1168042 /src/components/FormattedDate.astro | |
Initial fork of chrismwilliams/astro-theme-cactus theme
Diffstat (limited to 'src/components/FormattedDate.astro')
| -rw-r--r-- | src/components/FormattedDate.astro | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/components/FormattedDate.astro b/src/components/FormattedDate.astro new file mode 100644 index 0000000..aba7f4d --- /dev/null +++ b/src/components/FormattedDate.astro @@ -0,0 +1,16 @@ +--- +import { getFormattedDate } from "@/utils/date"; +import type { HTMLAttributes } from "astro/types"; + +type Props = HTMLAttributes<"time"> & { + date: Date; + dateTimeOptions?: Intl.DateTimeFormatOptions; +}; + +const { date, dateTimeOptions, ...attrs } = Astro.props; + +const postDate = getFormattedDate(date, dateTimeOptions); +const ISO = date.toISOString(); +--- + +<time datetime={ISO} title={ISO} {...attrs}>{postDate}</time> |
