From cda91b9ea998ae61822ee054199ddea4514e70bb Mon Sep 17 00:00:00 2001 From: dzfelix Date: Wed, 28 Aug 2024 12:28:30 +0300 Subject: [PATCH] breadcrumbs & author link --- src/app/[locale]/blog/[slug]/page.tsx | 37 +++++++++++++++++----- src/components/BlogPosts/BlogPostsList.tsx | 2 ++ src/lib/contentful/authors.ts | 1 + src/lib/contentful/blogPosts.ts | 1 + src/types/author.ts | 2 ++ src/types/blogPost.ts | 1 + 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/app/[locale]/blog/[slug]/page.tsx b/src/app/[locale]/blog/[slug]/page.tsx index ca1938a..df0e865 100644 --- a/src/app/[locale]/blog/[slug]/page.tsx +++ b/src/app/[locale]/blog/[slug]/page.tsx @@ -5,9 +5,11 @@ import { notFound } from 'next/navigation'; import {fetchBlogPost, fetchBlogPosts, Widget} from "../../../../lib/contentful/blogPosts"; import Util from "node:util"; import RichText from "../../../../lib/contentful/RichText"; +import Link from "next/link"; interface BlogPostPageParams { slug: string + locale: string } interface BlogPostPageProps { @@ -61,23 +63,25 @@ export default async function BlogItem({params}: { params: BlogPostPageParams })
- +
- -
-
{item.author?.name}
-
{item.createdAt}
-
+ + +
+
{item.author?.name}
+
{item.createdAt}
+
+
- + 165
- + Share
@@ -86,6 +90,23 @@ export default async function BlogItem({params}: { params: BlogPostPageParams }) {item.body.map(renderWidget)}
+
+ +
+ + ); }; diff --git a/src/components/BlogPosts/BlogPostsList.tsx b/src/components/BlogPosts/BlogPostsList.tsx index 954402d..7a26f94 100644 --- a/src/components/BlogPosts/BlogPostsList.tsx +++ b/src/components/BlogPosts/BlogPostsList.tsx @@ -44,6 +44,7 @@ export const BlogPostsList = ({ basePath = '/', locale, pageSize = DEFAULT_PAGE
+
@@ -51,6 +52,7 @@ export const BlogPostsList = ({ basePath = '/', locale, pageSize = DEFAULT_PAGE
{item.createdAt}
+
diff --git a/src/lib/contentful/authors.ts b/src/lib/contentful/authors.ts index 57a2f30..d378554 100644 --- a/src/lib/contentful/authors.ts +++ b/src/lib/contentful/authors.ts @@ -11,6 +11,7 @@ export function parseContentfulAuthor(authorEntry?: AuthorEntry): Auth return { name: authorEntry.fields.name || '', + expertId: authorEntry.fields.expertId || '', avatar: parseContentfulContentImage(authorEntry.fields.avatar), } } \ No newline at end of file diff --git a/src/lib/contentful/blogPosts.ts b/src/lib/contentful/blogPosts.ts index 8c670a8..2ab08eb 100644 --- a/src/lib/contentful/blogPosts.ts +++ b/src/lib/contentful/blogPosts.ts @@ -59,6 +59,7 @@ export function parseContentfulBlogPost(entry?: PostEntry): BlogPost | null { author: parseContentfulAuthor(entry.fields.author), createdAt: dayjs(entry.sys.createdAt).format('MMM DD, YYYY'), category: entry.fields.category.fields.title, + categorySlug: entry.fields.category.fields.slug, body: parseWidgets(entry.fields.body) || [] } } diff --git a/src/types/author.ts b/src/types/author.ts index 05c7eac..f836cc4 100644 --- a/src/types/author.ts +++ b/src/types/author.ts @@ -5,10 +5,12 @@ import {ContentImage} from "../lib/contentful/contentImage"; export interface AuthorFields { name: EntryFieldTypes.Symbol avatar: EntryFieldTypes.AssetLink + expertId: EntryFieldTypes.AssetLink } export interface Author { name: string + expertId: string avatar: ContentImage | null } diff --git a/src/types/blogPost.ts b/src/types/blogPost.ts index 5304b7d..f97d749 100644 --- a/src/types/blogPost.ts +++ b/src/types/blogPost.ts @@ -28,6 +28,7 @@ export interface BlogPost { listImage: ContentImage | null author: Author | null category: string + categorySlug: string createdAt: string metaDescription: string body: Array