From 3909e3de33715612fb45f7f05e61b3e26d713972 Mon Sep 17 00:00:00 2001 From: LowK Date: Fri, 5 Jan 2024 13:48:53 +0700 Subject: [PATCH] [fix] state effect --- config/config.json | 2 +- layouts/components/Report.js | 4 ++-- pages/page/[slug].js | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config/config.json b/config/config.json index a2210ca..fe96a22 100755 --- a/config/config.json +++ b/config/config.json @@ -5,7 +5,7 @@ "favicon": "/images/avatar.png" }, "settings": { - "pagination": 5, + "pagination": 6, "summary_length": 200, "blog_folder": "posts" }, diff --git a/layouts/components/Report.js b/layouts/components/Report.js index 5946902..2188472 100644 --- a/layouts/components/Report.js +++ b/layouts/components/Report.js @@ -28,8 +28,8 @@ const Report = ({ post, className }) => { className="btn-link inline-flex items-center hover:text-primary" href={post.frontmatter.url || ''} target='_blank' > - - + + diff --git a/pages/page/[slug].js b/pages/page/[slug].js index 3965129..197015c 100755 --- a/pages/page/[slug].js +++ b/pages/page/[slug].js @@ -25,7 +25,7 @@ const BlogPagination = ({ posts, currentPage, pagination }) => { }, }).then((res) => { res.json().then((data) => { - const sortedPosts = data.feeds.concat(allPosts).sort((a, b) => { + const sortedPosts = data.feeds.concat(posts).sort((a, b) => { return new Date(b.pubDate ? b.pubDate : b.frontmatter.date) - new Date(a.pubDate ? a.pubDate : a.frontmatter.date) }) @@ -34,9 +34,10 @@ const BlogPagination = ({ posts, currentPage, pagination }) => { ) setTotalPages(Math.ceil(sortedPosts.length / pagination)) setIsFeeding(false) + console.log(sortedPosts.slice(indexOfFirstPost, indexOfLastPost)) }) }) - }, []); + }, [currentPage, posts]); return (