upgrade to different layout
This commit is contained in:
19
src/components/FormattedDate.astro
Normal file
19
src/components/FormattedDate.astro
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
export interface Props {
|
||||
date?: Date | string;
|
||||
}
|
||||
|
||||
const { date } = Astro.props;
|
||||
|
||||
const parsedDate = typeof date === 'string' ? new Date(date) : date;
|
||||
---
|
||||
|
||||
{parsedDate && (
|
||||
<time datetime={parsedDate.toISOString()}>
|
||||
{parsedDate.toLocaleDateString('en-us', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
})}
|
||||
</time>
|
||||
)}
|
Reference in New Issue
Block a user