init
This commit is contained in:
31
src/components/widgets/FormattedDate.astro
Normal file
31
src/components/widgets/FormattedDate.astro
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
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>
|
||||
Reference in New Issue
Block a user