diff --git a/__tests__/components/ArticleCard.test.tsx b/__tests__/components/ArticleCard.test.tsx index 458eb11..ffe898a 100644 --- a/__tests__/components/ArticleCard.test.tsx +++ b/__tests__/components/ArticleCard.test.tsx @@ -12,6 +12,7 @@ const mockArticle: Article = { excerpt: 'The beloved series returns.', featured_image: null, published_at: '2026-05-28T00:00:00Z', + date_created: '2026-05-28T00:00:00Z', is_featured: false, seo_title: null, seo_description: null, diff --git a/__tests__/lib/directus.test.ts b/__tests__/lib/directus.test.ts index 4af6b65..596a380 100644 --- a/__tests__/lib/directus.test.ts +++ b/__tests__/lib/directus.test.ts @@ -47,7 +47,7 @@ describe('getArticleBySlug', () => { { id: '1', title: 'Frieren S2', slug: 'frieren-s2', status: 'published', content: '

Body

', excerpt: 'Short', featured_image: null, - published_at: '2026-05-28T00:00:00Z', is_featured: false, + published_at: '2026-05-28T00:00:00Z', date_created: '2026-05-28T00:00:00Z', is_featured: false, seo_title: null, seo_description: null, category: { id: '1', name: 'Anime', slug: 'anime', description: null }, tags: [], diff --git a/app/[category]/[slug]/page.tsx b/app/[category]/[slug]/page.tsx index cff6551..0418b41 100644 --- a/app/[category]/[slug]/page.tsx +++ b/app/[category]/[slug]/page.tsx @@ -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 ( diff --git a/lib/directus.ts b/lib/directus.ts index 6923dc4..af591c4 100644 --- a/lib/directus.ts +++ b/lib/directus.ts @@ -79,7 +79,7 @@ export async function getArticleBySlug(slug: string): Promise
{ readItems('articles', { fields: [ 'id', 'title', 'slug', 'status', 'content', 'excerpt', - 'featured_image', 'published_at', 'is_featured', + 'featured_image', 'published_at', 'date_created', 'is_featured', 'seo_title', 'seo_description', 'category.id', 'category.name', 'category.slug', 'tags.tags_id.id', 'tags.tags_id.name', 'tags.tags_id.slug', diff --git a/lib/types.ts b/lib/types.ts index 57ec863..eaaba32 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -26,6 +26,7 @@ export interface Article { excerpt: string | null featured_image: string | null published_at: string | null + date_created: string | null is_featured: boolean seo_title: string | null seo_description: string | null