diff --git a/src/app/blog/[...slug]/page.tsx b/src/app/blog/[...slug]/page.tsx index 25aa5af..0dfa701 100644 --- a/src/app/blog/[...slug]/page.tsx +++ b/src/app/blog/[...slug]/page.tsx @@ -27,11 +27,19 @@ const Page = ({ }) => { const [blog, setBlog] = useState(); + const [posts, setPosts] = useState([]); + + useEffect(() => { + axiosInstance.get("/api/blogs/").then((response) => { + setPosts(response.data.results); + }); + }, []); + useEffect(() => { axiosInstance.get(`/api/blogs/${params.slug[0]}/`).then((response) => { setBlog(response.data); }); - }); + }, []); const renderHeader = () => { return (
@@ -96,22 +104,19 @@ const Page = ({ const renderTags = () => { console.log(blog?.tags[0].name); - return( - - (
- {blog?.tags.map((item) => ( - - + return ( +
+ {blog?.tags.map((item) => ( {item.name} - - ))} -
) -) + ))} +
+ ); }; const renderCommentForm = () => { @@ -155,6 +160,7 @@ const Page = ({ ); }; + console.log(posts); const renderPostRelated = (post: PostDataType) => { return ( @@ -162,10 +168,10 @@ const Page = ({ key={post.id} className="relative aspect-w-3 aspect-h-4 rounded-3xl overflow-hidden group" > - +
-

{post.title}

- + {/* {post.author.displayName} - · - {post.date} + · */} + + {post.created_at.split("T")[0]} +
- + ); }; @@ -211,8 +218,12 @@ const Page = ({

Related posts

- {/* */} - {DEMO_POSTS.filter((_, i) => i < 4).map(renderPostRelated)} + {console.log(params.slug[0], posts)} + {posts + .filter((_, i) => { + return _?.slug !== params.slug[0]; + }) + .map((item, i) => i < 4 && renderPostRelated(item))} {/* */}
diff --git a/src/shared/Badge.tsx b/src/shared/Badge.tsx index dee49a0..3b80b1b 100644 --- a/src/shared/Badge.tsx +++ b/src/shared/Badge.tsx @@ -38,7 +38,7 @@ const Badge: FC = ({ }`; } }; - const getStatus = (hasHover = true) => { + const getStatus = () => { switch (color) { case "SOLD_OUT": return `Sold Out`; @@ -51,7 +51,7 @@ const Badge: FC = ({ return `Booked`; default: - return `None`; + return color; } };