diff --git a/src/app/blogs/Blogcard.js b/src/app/blogs/Blogcard.js index ff13dba..70e2958 100644 --- a/src/app/blogs/Blogcard.js +++ b/src/app/blogs/Blogcard.js @@ -6,17 +6,19 @@ const BlogCard = ({ title, authors, img, description, slug, date }) => { // const truncatedDescription = description.length > 100 ? `${description.slice(0, 100)}...` : description; return ( -
-
- {title} + +
+
+ {title} +
+
+

{title}

+

{date}

+

by {authors}

+

{description.slice(0, 150) + "... see more"}

+
-
-

{title}

-

{date}

-

by {authors}

-

{description.slice(0, 150) + "... see more"}

-
-
+ ); }; diff --git a/src/app/blogs/Blogcard.module.css b/src/app/blogs/Blogcard.module.css index 008fa8f..ab2bbfc 100644 --- a/src/app/blogs/Blogcard.module.css +++ b/src/app/blogs/Blogcard.module.css @@ -16,7 +16,7 @@ } .blogCard { - width: 350px; + width: 320px; height: fit-content; border: 1px solid #e0e0e0; border-radius: 8px; @@ -29,6 +29,12 @@ height: 100%; } +@media screen and (max-width: 350px) { + .blogCard { + width: 100%; + } +} + .blogCcard:hover { transform: scale(1.02); } diff --git a/src/app/blogs/[blogid]/page.js b/src/app/blogs/[blogid]/page.js index ff4d631..ad85483 100644 --- a/src/app/blogs/[blogid]/page.js +++ b/src/app/blogs/[blogid]/page.js @@ -21,13 +21,13 @@ const BlogId = ({ params }) => { // Fetch data from the API const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=blog.BlogPage&fields=*'); const data = await response.json(); - console.log("check",data); + console.log("check", data); // Find the blog post with the matching id - const matchingBlog = data.items.find(blog => blog.id === parseInt(params.blogid)); - + const matchingBlog = data.items.find(blog => blog?.meta.slug === params.blogid); + console.log("matchingBlog", data.items[0]); // Update the state with the matching blog data setBlogData(matchingBlog); - console.log("blog :",matchingBlog.blog_img_url) + console.log("blog :", matchingBlog.blog_img_url) } catch (error) { console.error('Error fetching data:', error); @@ -36,26 +36,54 @@ const BlogId = ({ params }) => { // Call the fetchData function fetchData(); - }, [params.id]); // Include params.id in the dependency array to refetch data when id changes + }, [params.blogid]); // Include params.id in the dependency array to refetch data when id changes + console.log(blogData?.blog_tags.split(",")) + + let inputDate = blogData?.published_on; + let dateObj = new Date(inputDate); + let day = dateObj.getDate(); + let month = dateObj.toLocaleString('default', { month: 'short' }); + let year = dateObj.getFullYear(); + + let formattedDate = `${day} ${month} ${year}`; // Render the component return ( <> - -
- -
- {blogData ? ( -
-

{blogData.title}

- {blogData.blog_body} -
- ) : ( -

Loading...

- )} + +
+
+ {blogData ? ( +
+
+
+
+ {blogData?.blog_tags.split(",").map((data, index) => { + return ( + {data} + ) + } + )} +
+
+ {blogData.title} +
+
+ {blogData.blog_description} +
+
+ {blogData.blog_authors}{formattedDate} +
+
+
+ {blogData.blog_body} +
+ ) : ( +

Loading...

+ )} +
-
-