fix: fall back to date_created when published_at is null so every article shows a date
This commit is contained in:
@@ -73,12 +73,13 @@ export default async function ArticlePage({ params }: Props) {
|
||||
|
||||
if (!article) notFound()
|
||||
|
||||
const publishedDate = article.published_at
|
||||
const dateToFormat = article.published_at ?? article.date_created
|
||||
const publishedDate = dateToFormat
|
||||
? new Intl.DateTimeFormat('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}).format(new Date(article.published_at))
|
||||
}).format(new Date(dateToFormat))
|
||||
: null
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user