Skip to content

Commit 4441a69

Browse files
dandakaclaude
andauthored
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 <[email protected]>
1 parent dc3ae56 commit 4441a69

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
@@ -88,10 +88,10 @@ function BlogIndex() {
8888
{published ? (
8989
<time
9090
dateTime={published}
91-
title={format(new Date(published), 'MMM dd, yyyy')}
91+
title={format(new Date(published), 'MMM d, yyyy')}
9292
>
9393
{' '}
94-
on {format(new Date(published), 'MMM dd, yyyy')}
94+
on {format(new Date(published), 'MMM d, yyyy')}
9595
</time>
9696
) : null}
9797
</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)