mirror of
https://github.com/thiloho/thiloho.github.io.git
synced 2025-11-22 10:21:36 +01:00
Set site url and remove old logic
This commit is contained in:
@@ -1,29 +1,17 @@
|
||||
---
|
||||
interface Props {
|
||||
date: Date | string;
|
||||
date: Date;
|
||||
}
|
||||
|
||||
const { date } = Astro.props;
|
||||
|
||||
const isStringDate = typeof date === "string";
|
||||
const transformedDate = isStringDate ? new Date(date) : date;
|
||||
|
||||
// Create the base options object
|
||||
const localeOptions = {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
};
|
||||
|
||||
// Conditionally add time options if it's a string date
|
||||
if (isStringDate) {
|
||||
Object.assign(localeOptions, {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit"
|
||||
});
|
||||
}
|
||||
---
|
||||
|
||||
<time datetime={transformedDate.toISOString()}>
|
||||
{transformedDate.toLocaleString("en-us", localeOptions)}
|
||||
</time>
|
||||
<time datetime={date.toISOString()}>
|
||||
{
|
||||
date.toLocaleString("en-us", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
})
|
||||
}
|
||||
</time>
|
||||
|
||||
Reference in New Issue
Block a user