fix: render paginate only if more than 1 page

This commit is contained in:
Timothy Lin 2021-05-29 16:13:01 +08:00
parent 88096a536b
commit 2e5a3a5a9a
2 changed files with 6 additions and 4 deletions

View File

@ -86,9 +86,11 @@ export default function ListLayout({ posts, title, initialDisplayPosts = [], pag
})}
</ul>
</div>
{pagination && !searchValue && (
<Pagination currentPage={pagination.currentPage} totalPages={pagination.totalPages} />
)}
{pagination &&
pagination.totalPages > 1 &&
!searchValue(
<Pagination currentPage={pagination.currentPage} totalPages={pagination.totalPages} />
)}
</>
)
}

View File

@ -3,7 +3,7 @@ import siteMetadata from '@/data/siteMetadata'
import ListLayout from '@/layouts/ListLayout'
import { PageSeo } from '@/components/SEO'
export const POSTS_PER_PAGE = 5
export const POSTS_PER_PAGE = 10
export async function getStaticProps() {
const posts = await getAllFilesFrontMatter('blog')