From a4225a1e3b55f2667990c3590dcacc349d82ccc2 Mon Sep 17 00:00:00 2001 From: akhilalekha Date: Fri, 25 Jun 2021 15:04:35 +0530 Subject: [PATCH] Fix: If there's no posts show a message --- component/layout/BlogPost/SectionRelated.jsx | 52 +++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/component/layout/BlogPost/SectionRelated.jsx b/component/layout/BlogPost/SectionRelated.jsx index e7e32471..7bbcbf32 100644 --- a/component/layout/BlogPost/SectionRelated.jsx +++ b/component/layout/BlogPost/SectionRelated.jsx @@ -4,7 +4,7 @@ import AuthorDetails from "../BlogListing/AuthorDetails"; import moment from "moment"; export default function SectionRelated({ title, posts }) { - // console.log({ posts }); + // console.log(posts.length); return (
@@ -19,33 +19,37 @@ export default function SectionRelated({ title, posts }) {
- {posts.map((post) => ( -
-
- - - {`${post.title}`} - - -
-
-

- {moment(post.publishedAt).format("MMMM Do, YYYY")} -

-

+ {posts.length > 0 ? ( + posts.map((post) => ( +

- + +
+

+ {moment(post.publishedAt).format("MMMM Do, YYYY")} +

+

+ + + {/* 34 */} + {post.title.length > 34 + ? post.title.substring(0, 34) + "..." + : post.title} + + +

+ +
-
- ))} + )) + ) : ( +
No blogs!
+ )}