From 2885cd1b867af6be95e80fbe1bd7e3071683944f Mon Sep 17 00:00:00 2001 From: log101 Date: Fri, 21 Jun 2024 17:01:58 +0300 Subject: [PATCH] style: hide pagination if there is only one page --- src/pages/category/[category]/[page].astro | 66 +++++++++++-------- .../[category]/posts/[slug]/index.astro | 1 + 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/pages/category/[category]/[page].astro b/src/pages/category/[category]/[page].astro index 996a057..4758446 100644 --- a/src/pages/category/[category]/[page].astro +++ b/src/pages/category/[category]/[page].astro @@ -9,9 +9,11 @@ import Post from "@/components/Post.astro"; export async function getStaticPaths({ paginate }: { paginate: any }) { const blogEntries = await getCollection("blog"); - const filteredPosts = blogEntries.filter((post) => post.data.category); return CATEGORIES.flatMap((category) => { + const filteredPosts = blogEntries.filter( + (post) => post.data.category == category + ); return paginate(filteredPosts, { params: { category }, pageSize: 3, @@ -36,39 +38,45 @@ const pages = Array.from({ length: page.lastPage }, (_, i) => i + 1); .map((p) => ) ) : (

- Henüz bu kategoride bir yazı yazılmadı. Yazarımızın ilhama veya + Henüz bu kategoride bir yazı yayınlanmadı. Yazarımızın ilhama veya teşviğe ihtiyacı olabilir!

) } -
- - { - pages.map((pageNumber) => { - switch (pageNumber) { - case page.currentPage: - return {pageNumber}; + { + page.lastPage != 1 && ( + <> +
+ + {pages.map((pageNumber) => { + switch (pageNumber) { + case page.currentPage: + return {pageNumber}; - default: - return ( - - {pageNumber} - - ); - } - }) - } - -
+ default: + return ( + + {pageNumber} + + ); + } + })} + +
+ + ) + }