mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-07 15:10:32 +00:00
修复分页组件bug
This commit is contained in:
@@ -47,7 +47,7 @@ const PaginationSimple = ({ page, showNext }) => {
|
|||||||
{locale.PAGINATION.NEXT}→
|
{locale.PAGINATION.NEXT}→
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PaginationSimple
|
export default PaginationSimple
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const PaginationNumber = ({ page, totalPage }) => {
|
|||||||
|
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPageElement(page, currentPage, pagePrefix) {
|
function getPageElement(page, currentPage, pagePrefix) {
|
||||||
@@ -66,7 +66,7 @@ function getPageElement(page, currentPage, pagePrefix) {
|
|||||||
{page}
|
{page}
|
||||||
|
|
||||||
</Link>)
|
</Link>)
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function generatePages(pagePrefix, page, currentPage, totalPage) {
|
function generatePages(pagePrefix, page, currentPage, totalPage) {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import BLOG from '@/blog.config'
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
|
|
||||||
@@ -13,6 +12,7 @@ const PaginationSimple = ({ page, totalPage }) => {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const currentPage = +page
|
const currentPage = +page
|
||||||
const showNext = currentPage < totalPage
|
const showNext = currentPage < totalPage
|
||||||
|
const pagePrefix = router.asPath.replace(/\/page\/[1-9]\d*/, '').replace(/\/$/, '')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="my-10 mx-6 flex justify-between font-medium text-black dark:text-gray-100 space-x-2">
|
<div className="my-10 mx-6 flex justify-between font-medium text-black dark:text-gray-100 space-x-2">
|
||||||
@@ -20,8 +20,8 @@ const PaginationSimple = ({ page, totalPage }) => {
|
|||||||
href={{
|
href={{
|
||||||
pathname:
|
pathname:
|
||||||
currentPage - 1 === 1
|
currentPage - 1 === 1
|
||||||
? `${BLOG.SUB_PATH || '/'}`
|
? `${pagePrefix}/`
|
||||||
: `/page/${currentPage - 1}`,
|
: `${pagePrefix}/page/${currentPage - 1}`,
|
||||||
query: router.query.s ? { s: router.query.s } : {}
|
query: router.query.s ? { s: router.query.s } : {}
|
||||||
}}
|
}}
|
||||||
passHref
|
passHref
|
||||||
@@ -36,7 +36,7 @@ const PaginationSimple = ({ page, totalPage }) => {
|
|||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
href={{
|
href={{
|
||||||
pathname: `/page/${currentPage + 1}`,
|
pathname: `${pagePrefix}/page/${currentPage + 1}`,
|
||||||
query: router.query.s ? { s: router.query.s } : {}
|
query: router.query.s ? { s: router.query.s } : {}
|
||||||
}}
|
}}
|
||||||
passHref
|
passHref
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const PaginationSimple = ({ page, totalPage }) => {
|
|||||||
{locale.PAGINATION.NEXT}→
|
{locale.PAGINATION.NEXT}→
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PaginationSimple
|
export default PaginationSimple
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import BLOG from '@/blog.config'
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { useGlobal } from '@/lib/global'
|
import { useGlobal } from '@/lib/global'
|
||||||
@@ -14,6 +13,8 @@ const PaginationSimple = ({ page, showNext }) => {
|
|||||||
const { locale } = useGlobal()
|
const { locale } = useGlobal()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const currentPage = +page
|
const currentPage = +page
|
||||||
|
const pagePrefix = router.asPath.replace(/\/page\/[1-9]\d*/, '').replace(/\/$/, '')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
data-aos="fade-down"
|
data-aos="fade-down"
|
||||||
@@ -25,8 +26,8 @@ const PaginationSimple = ({ page, showNext }) => {
|
|||||||
href={{
|
href={{
|
||||||
pathname:
|
pathname:
|
||||||
currentPage - 1 === 1
|
currentPage - 1 === 1
|
||||||
? `${BLOG.SUB_PATH || '/'}`
|
? `${pagePrefix}/`
|
||||||
: `/page/${currentPage - 1}`,
|
: `${pagePrefix}/page/${currentPage - 1}`,
|
||||||
query: router.query.s ? { s: router.query.s } : {}
|
query: router.query.s ? { s: router.query.s } : {}
|
||||||
}}
|
}}
|
||||||
passHref
|
passHref
|
||||||
|
|||||||
Reference in New Issue
Block a user