the horrors
This commit is contained in:
parent
0d9be3d002
commit
4245370f61
48 changed files with 2513 additions and 265 deletions
17
src/components/util/Date.astro
Normal file
17
src/components/util/Date.astro
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
export interface Props {
|
||||
date: string | Date;
|
||||
}
|
||||
const { date } = Astro.props;
|
||||
|
||||
if (!date) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const dateObj = typeof date === "string" ? new Date(date) : date;
|
||||
const options = { year: "numeric", month: "long", day: "numeric" };
|
||||
const formattedDate = dateObj.toLocaleDateString("en-GB", options);
|
||||
const isoDate = dateObj.toISOString();
|
||||
---
|
||||
|
||||
<time datetime={isoDate}>{formattedDate}</time>
|
Loading…
Add table
Add a link
Reference in a new issue