Skip to content

Commit 2a61a99

Browse files
dandakaclaude
authored andcommitted
fix: improve blog date formatting (#630)
- Blog post: use full month name format (January 2, 2026) - Posts list: use short month format without leading zero (Jan 2, 2026) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 249e2ee commit 2a61a99

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/routes/_libraries/blog.$.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function BlogPost() {
101101

102102
const blogContent = `<small>_by ${formatAuthors(authors)} on ${format(
103103
new Date(published || 0),
104-
'MMM dd, yyyy',
104+
'MMMM d, yyyy',
105105
)}._</small>
106106
107107
${content}`

src/routes/_libraries/blog.index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ function BlogIndex() {
101101
{published ? (
102102
<time
103103
dateTime={published}
104-
title={format(new Date(published), 'MMM dd, yyyy')}
104+
title={format(new Date(published), 'MMM d, yyyy')}
105105
>
106106
{' '}
107-
on {format(new Date(published), 'MMM dd, yyyy')}
107+
on {format(new Date(published), 'MMM d, yyyy')}
108108
</time>
109109
) : null}
110110
</p>

src/utils/dates.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ export function format(date: Date | number, formatStr: string): string {
8181
day: 'numeric',
8282
})
8383

84+
case 'MMMM d, yyyy':
85+
// "April 29, 2023"
86+
return d.toLocaleDateString('en-US', {
87+
year: 'numeric',
88+
month: 'long',
89+
day: 'numeric',
90+
})
91+
8492
case 'yyyy-MM-dd':
8593
// "2023-04-29"
8694
return d.toISOString().split('T')[0]

0 commit comments

Comments
 (0)