Files
blog2025/src/components/widgets/FormattedDate.astro
2025-07-18 16:43:10 +02:00

32 lines
681 B
Plaintext

---
import { themeConfig } from '@/config'
import { formatDate } from '@/utils/date'
import type { FormattedDateProps } from '@/types'
const {
date,
format,
context = 'default'
} = Astro.props as FormattedDateProps & { context?: 'list' | 'post' | 'default' }
---
<time
datetime={date.toISOString()}
class={!themeConfig.date.dateOnRight &&
(themeConfig.date.dateFormat === 'MONTH DAY YYYY' ||
themeConfig.date.dateFormat === 'DAY MONTH YYYY') &&
context === 'list'
? 'date-left'
: ''}
>
<Fragment set:html={formatDate(date, format)} />
</time>
<style>
.date-left {
display: inline-block;
min-width: 86px;
text-align: right;
}
</style>