diff --git a/src/app/(routes)/blog/[slug]/page.tsx b/src/app/(routes)/blog/[slug]/page.tsx index 1318e1a..cd0dd51 100644 --- a/src/app/(routes)/blog/[slug]/page.tsx +++ b/src/app/(routes)/blog/[slug]/page.tsx @@ -1,4 +1,5 @@ import { + resolvePublishDateToIsoDate, retrieveContentfulEntry, retrieveContentfulPublishedSlugs, } from "@/app/_lib/contentful"; @@ -89,7 +90,6 @@ export default async function SpecificBlogPage({ params }: SpecificBlogPageProps redirect("/404"); } const fullTitle = entry.fields.title; - const dateCreatedAt = entry.sys.createdAt; const content = entry.fields.content; return ( <> @@ -103,7 +103,10 @@ export default async function SpecificBlogPage({ params }: SpecificBlogPageProps - +

{fullTitle}

diff --git a/src/app/(routes)/blog/_components/article-full-card.tsx b/src/app/(routes)/blog/_components/article-full-card.tsx index 1d7cd0f..edd9e13 100644 --- a/src/app/(routes)/blog/_components/article-full-card.tsx +++ b/src/app/(routes)/blog/_components/article-full-card.tsx @@ -1,4 +1,7 @@ -import { retrieveContentfulEntry } from "@/app/_lib/contentful"; +import { + resolvePublishDateToIsoDate, + retrieveContentfulEntry, +} from "@/app/_lib/contentful"; import ContentfulImage from "../[slug]/_components/contentful-image"; import { MetaInfo } from "../[slug]/_components/meta-info"; import { documentToPlainTextString } from "@contentful/rich-text-plain-text-renderer"; @@ -20,7 +23,7 @@ export default async function ArticleFullCard({ slug }: { slug: string }) { >
diff --git a/src/app/(routes)/blog/_components/article-snippet-card.tsx b/src/app/(routes)/blog/_components/article-snippet-card.tsx index df41432..db2501c 100644 --- a/src/app/(routes)/blog/_components/article-snippet-card.tsx +++ b/src/app/(routes)/blog/_components/article-snippet-card.tsx @@ -1,4 +1,4 @@ -import { BlogPostType } from "@/app/_lib/contentful"; +import { BlogPostType, resolvePublishDateToIsoDate } from "@/app/_lib/contentful"; import { Text } from "@/app/_components/text"; import Link from "next/link"; import ContentfulImage from "../[slug]/_components/contentful-image"; @@ -18,7 +18,7 @@ export default function ArticleSnippetCard({
diff --git a/src/app/_lib/contentful.ts b/src/app/_lib/contentful.ts index 0aec826..f4aec90 100644 --- a/src/app/_lib/contentful.ts +++ b/src/app/_lib/contentful.ts @@ -128,3 +128,7 @@ export function getReadingTime(content: Document): number { const wordCount = words(rawText).length; return Math.round(wordCount / averageReadingSpeed); } + +export function resolvePublishDateToIsoDate(entry: BlogPostType): string { + return entry.fields.publishDate ?? entry.sys.createdAt; +}