Set site url and remove old logic

This commit is contained in:
thiloho
2025-04-26 09:57:29 +02:00
parent f8e71fc3b6
commit 4f15486742
6 changed files with 16 additions and 36 deletions

View File

@@ -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>