Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 65a7d01

Browse files
committed
fix: normalize possible unix timestamp
1 parent fdcaccd commit 65a7d01

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/karbon/src/runtime/api/normalize-article.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface RawArticleLike {
2626
authors: RawUserLike[]
2727
tags: ArticleTag[]
2828
desk: ArticleDesk
29-
published_at: string
29+
published_at: string | number
3030
}
3131

3232
export interface PaidContent {
@@ -58,6 +58,7 @@ export function normalizeArticle({
5858
authors,
5959
desk,
6060
tags,
61+
published_at,
6162
...rest
6263
}: RawArticleLike) {
6364
const articleFilter = useArticleFilter()
@@ -69,6 +70,8 @@ export function normalizeArticle({
6970
plan,
7071
bio: articleFilter(bio),
7172
bioHTML: bio,
73+
// published_at could be unix timestamp
74+
published_at: typeof published_at === 'string' ? published_at : new Date(published_at * 1000).toISOString(),
7275
title: unwrapParagraph(title),
7376
blurb: unwrapParagraph(blurb),
7477
seo: destr<RawSEO>(seo),

0 commit comments

Comments
 (0)