Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add link to blogCard #93

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions src/APP/pages/blog/Blog.jsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import React from "react";
import { useParams } from "react-router-dom";
import BlogStats from "../blogs/sections/BlogStats";
import BlogWrapper from "./sections/BlogWrapper";
import useBlogData from "../../../hooks/Queries/blog/useBlogData";
function Blog() {
const { id } = useParams();
const { data: blogData, isLoading, isError, isSuccess } = useBlogData(id);
return (
<>
{isError && <p>Error fetching blog details!</p>}
{isLoading && <p>Loading blog details...</p>}
{isSuccess && (
<section className="flex flex-col p-4 md:p-8 lg:p-10">
<img
src={blogData.image}
alt="blog"
className="w-full h-60 md:h-72 object-cover rounded-lg mb-4 md:mb-8"
/>
<div className="flex flex-row items-center justify-between">
<p className="text-[#4C4D4D] text-sm md:text-base font-bold">
{new Date(blogData.created_at).toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
})}
</p>
<BlogStats likes={blogData.likes} />
</div>
<BlogWrapper blog={blogData} />
{/* <RelatedBlogs /> */}
</section>
)}
</>
);
}
export default Blog;
import React from "react";
import { useParams } from "react-router-dom";
import BlogWrapper from "./sections/BlogWrapper";
import useBlogData from "../../../hooks/Queries/blog/useBlogData";

function Blog() {
const { id } = useParams();
const { data: blogData, isLoading, isError, isSuccess } = useBlogData(id);

return (
<section className=" max-w-[1440px] mx-auto">
{isError && <p>Error fetching blog details!</p>}
{isLoading && <p>Loading blog details...</p>}
{isSuccess && (
<section className="flex flex-col p-4 md:p-8 lg:p-10">
<img
src={blogData.image}
alt="blog"
className="w-full h-60 md:h-72 object-cover rounded-lg mb-4 md:mb-8"
/>

{/* <div className="flex flex-row items-center justify-between">
<p className="text-[#4C4D4D] text-sm md:text-base font-bold">
{new Date(blogData.created_at).toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
})}
</p>

<BlogStats likes={blogData.likes} />
</div> */}

<BlogWrapper blog={blogData} />

{/* <RelatedBlogs /> */}
</section>
)}
</section>
);
}

export default Blog;

16 changes: 12 additions & 4 deletions src/APP/pages/blogs/sections/BlogCard.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useNavigate } from "react-router-dom";
import { Ellipse30, arrowRight } from "../../../../assets/images/blogs-page";
import { formatDistanceToNow } from "date-fns";
import { useNavigate, Link } from "react-router-dom";
import { arrowRight } from "../../../../assets/images/blogs-page";
import logo from "../../../../assets/images/sytLogo.png";

import BlogStats from "./BlogStats";
import { formatDistanceToNow } from "date-fns";

Expand All @@ -9,7 +12,12 @@ const BlogCard = ({ blog }) => {
addSuffix: true,
});
return (
<div className="flex flex-col items-start w-full">

<Link
to={`/blogs/${blog.id}`}
className="flex flex-col items-start w-full mb-6"
>

<img
src={blog.image}
alt="blog"
Expand Down Expand Up @@ -55,7 +63,7 @@ const BlogCard = ({ blog }) => {
</button>
</div>
</div>
</div>
</Link>
);
};

Expand Down