FormattedDate component can be hidden

This commit is contained in:
2026-04-25 13:06:00 +01:00
parent ac8011ddb1
commit 5a56c572af
+11 -9
View File
@@ -2,20 +2,22 @@
interface Props { interface Props {
className?: string; className?: string;
date: Date | string; date: Date | string;
hidden?: boolean;
} }
let { className, date } = Astro.props; let { className, date, hidden } = Astro.props;
if (typeof(date) === 'string') { if (typeof(date) === 'string') {
date = new Date(date); date = new Date(date);
} }
--- const dateStr =
date.toLocaleDateString('en-GB', {
<time datetime={date.toISOString()} class={className ?? ''}>
{
date.toLocaleDateString('en-GB', {
year: 'numeric', year: 'numeric',
month: 'long', month: 'long',
day: 'numeric', day: 'numeric',
}) });
} ---
</time>
{ hidden
? <time datetime={date.toISOString()} class={className ?? ''} hidden>{dateStr}</time>
: <time datetime={date.toISOString()} class={className ?? ''}>{dateStr}</time>
}