Fork of Chiri for Astro for my blog
1---
2import { themeConfig } from '@/config'
3import { formatDate } from '@/utils/date'
4import type { FormattedDateProps } from '@/types'
5
6const {
7 date,
8 format,
9 context = 'default'
10} = Astro.props as FormattedDateProps & { context?: 'list' | 'post' | 'default' }
11---
12
13<time
14 datetime={date.toISOString()}
15 class={!themeConfig.date.dateOnRight &&
16 (themeConfig.date.dateFormat === 'MONTH DAY YYYY' || themeConfig.date.dateFormat === 'DAY MONTH YYYY') &&
17 context === 'list'
18 ? 'date-left'
19 : ''}
20>
21 <Fragment set:html={formatDate(date, format)} />
22</time>
23
24<style>
25 .date-left {
26 display: inline-block;
27 min-width: 86px;
28 text-align: right;
29 }
30</style>