From e0a8e1b595dd5a636f49edce7c08b2fd12c1e452 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sat, 21 Jun 2025 15:03:29 +0900
Subject: feat(blog/nuldoc): implement pagination

---
 vhosts/blog/nuldoc-src/components/Pagination.tsx | 45 ++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 vhosts/blog/nuldoc-src/components/Pagination.tsx

(limited to 'vhosts/blog/nuldoc-src/components/Pagination.tsx')

diff --git a/vhosts/blog/nuldoc-src/components/Pagination.tsx b/vhosts/blog/nuldoc-src/components/Pagination.tsx
new file mode 100644
index 00000000..5527c924
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/components/Pagination.tsx
@@ -0,0 +1,45 @@
+type Props = {
+  currentPage: number;
+  totalPages: number;
+  basePath: string;
+};
+
+export default function Pagination(
+  { currentPage, totalPages, basePath }: Props,
+) {
+  if (totalPages <= 1) {
+    return <div></div>;
+  }
+
+  const prevPage = currentPage > 1 ? currentPage - 1 : null;
+  const nextPage = currentPage < totalPages ? currentPage + 1 : null;
+
+  const prevHref = prevPage === 1 ? basePath : `${basePath}${prevPage}/`;
+  const nextHref = `${basePath}${nextPage}/`;
+
+  return (
+    <nav className="pagination">
+      <div className="pagination-prev">
+        {prevPage
+          ? (
+            <a href={prevHref}>
+              前のページ
+            </a>
+          )
+          : null}
+      </div>
+      <div className="pagination-info">
+        {String(currentPage)} / {String(totalPages)}
+      </div>
+      <div className="pagination-next">
+        {nextPage
+          ? (
+            <a href={nextHref}>
+              次のページ
+            </a>
+          )
+          : null}
+      </div>
+    </nav>
+  );
+}
-- 
cgit v1.2.3-70-g09d2

