diff --git a/src/containers/PostListing.tsx b/src/containers/PostListing.tsx
index 8514341..4071ed2 100644
--- a/src/containers/PostListing.tsx
+++ b/src/containers/PostListing.tsx
@@ -1,9 +1,9 @@
// @ts-nocheck
import {
- Card,
- CardDescription,
- CardHeader,
- CardTitle,
+ Card,
+ CardDescription,
+ CardHeader,
+ CardTitle,
} from "@/components/ui/card"
import { Button } from "@/components/ui/button"
import { Link } from "react-router"
@@ -11,45 +11,45 @@ import { Link } from "react-router"
import { convertDate } from "@/utils/convertDate"
const PostListing = ({ posts, title, showAllButton }) => {
- return (
- <>
-
-
- {title}
-
-
-
- {posts.map((post) => (
-
-
-
-
- {post.title}
-
-
-
- {convertDate(post.date)}
-
-
-
-
-
- ))}
-
- {showAllButton && (
-
- )}
- >
- )
+ return (
+ <>
+
+
+ {title}
+
+
+
+ {posts.map((post) => (
+
+
+
+
+ {post.title}
+
+
+
+ {convertDate(post.date)}
+
+
+
+
+
+ ))}
+
+ {showAllButton && (
+
+ )}
+ >
+ )
}
export default PostListing
diff --git a/src/pages/home.tsx b/src/pages/home.tsx
index a2996a1..5c2550d 100644
--- a/src/pages/home.tsx
+++ b/src/pages/home.tsx
@@ -9,7 +9,7 @@ const HomePage = () => {
const { posts } = usePosts()
return (
-
+
Another software engineer with a blog
diff --git a/src/pages/posts.tsx b/src/pages/posts.tsx
index 11efc5b..13fc7a4 100644
--- a/src/pages/posts.tsx
+++ b/src/pages/posts.tsx
@@ -4,128 +4,128 @@ import MainTemplate from "@/templates/MainTemplate"
import { useParams, useNavigate } from "react-router"
import { convertDate } from "@/utils/convertDate"
import {
- Pagination,
- PaginationContent,
- PaginationItem,
- PaginationNext,
- PaginationPrevious,
+ Pagination,
+ PaginationContent,
+ PaginationItem,
+ PaginationNext,
+ PaginationPrevious,
} from "@/components/ui/pagination"
import {
- Card,
- CardDescription,
- CardHeader,
- CardTitle,
+ Card,
+ CardDescription,
+ CardHeader,
+ CardTitle,
} from "@/components/ui/card"
import { Badge } from "@/components/ui/badge"
import { Link } from "react-router"
import { usePosts } from "@/hooks/usePosts"
const PostsPage = () => {
- const { page } = useParams()
+ const { page } = useParams()
- const navigate = useNavigate()
+ const navigate = useNavigate()
- const { posts } = usePosts()
- const postsPerPage = 10
+ const { posts } = usePosts()
+ const postsPerPage = 10
- const currentPage = Number(page) || 1
- const totalPages = Math.ceil(posts.length / postsPerPage)
+ const currentPage = Number(page) || 1
+ const totalPages = Math.ceil(posts.length / postsPerPage)
- useEffect(() => {
- if (currentPage < 1 || currentPage > totalPages) {
- navigate(`/posts/page/1`, { replace: true })
- }
- }, [currentPage, totalPages, navigate])
+ useEffect(() => {
+ if (currentPage < 1 || currentPage > totalPages) {
+ navigate(`/posts/page/1`, { replace: true })
+ }
+ }, [currentPage, totalPages, navigate])
- const currentPosts = useMemo(() => {
- const startIndex = (currentPage - 1) * postsPerPage
- const endIndex = startIndex + postsPerPage
- return posts.slice(startIndex, endIndex)
- }, [posts, currentPage, postsPerPage])
+ const currentPosts = useMemo(() => {
+ const startIndex = (currentPage - 1) * postsPerPage
+ const endIndex = startIndex + postsPerPage
+ return posts.slice(startIndex, endIndex)
+ }, [posts, currentPage, postsPerPage])
- const hasNextPage = currentPage < totalPages
- const hasPrevPage = currentPage > 1
+ const hasNextPage = currentPage < totalPages
+ const hasPrevPage = currentPage > 1
- const goToNextPage = () => {
- if (hasNextPage) {
- navigate(`/posts/page/${currentPage + 1}`)
- }
- }
+ const goToNextPage = () => {
+ if (hasNextPage) {
+ navigate(`/posts/page/${currentPage + 1}`)
+ }
+ }
- const goToPrevPage = () => {
- if (hasPrevPage) {
- navigate(`/posts/page/${currentPage - 1}`)
- }
- }
+ const goToPrevPage = () => {
+ if (hasPrevPage) {
+ navigate(`/posts/page/${currentPage - 1}`)
+ }
+ }
- return (
-
-
-
- All posts
-
-
-
-
- {currentPosts.map((post) => (
-
-
-
-
- {post.title}
-
-
-
-
{convertDate(post.date)}
-
- {post.tags.map((tag, i) => (
- {
- e.preventDefault()
- e.stopPropagation()
- navigate(`/tags/${tag}`)
- }}
- >
- {tag}
-
- ))}
-
-
-
-
-
-
- ))}
-
-
-
-
-
-
-
-
-
-
-
-
-
- )
+ return (
+
+
+
+ All posts
+
+
+
+
+ {currentPosts.map((post) => (
+
+
+
+
+ {post.title}
+
+
+
+
{convertDate(post.date)}
+
+ {post.tags.map((tag, i) => (
+ {
+ e.preventDefault()
+ e.stopPropagation()
+ navigate(`/tags/${tag}`)
+ }}
+ >
+ {tag}
+
+ ))}
+
+
+
+
+
+
+ ))}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
}
export { PostsPage }