mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 16:51:37 +00:00
* add dark mode switch button * modify footer * fix nav menu opening issue * add paging number * remove post card a link focus shadow * add _document * remove archive card border on last child * add post image zoom margin on desktop * add post index image * remove TOC scroll bar on firefox
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
import { useRouter } from 'next/router';
|
|
import { FC } from 'react';
|
|
import { Button, Flex, Text } from '@chakra-ui/react';
|
|
import useGetColors from '../lib/hooks/useGetColors';
|
|
|
|
interface Props {
|
|
allPages: number;
|
|
num: string;
|
|
}
|
|
|
|
const paging: FC<Props> = ({ allPages, num }) => {
|
|
const router = useRouter();
|
|
const startIndex = Number(num);
|
|
|
|
const { textColor } = useGetColors();
|
|
|
|
const goPrev = () => {
|
|
startIndex == 2 ? router.push('/') : router.push(`/page/${startIndex - 1}`);
|
|
};
|
|
const goNext = () => {
|
|
router.push(`/page/${startIndex + 1}`);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Flex alignItems="center">
|
|
{startIndex > 1 ? (
|
|
<Button onClick={goPrev} mr={'auto'} size="lg">
|
|
上一页
|
|
</Button>
|
|
) : (
|
|
void 0
|
|
)}
|
|
|
|
<Text fontSize="xl" fontWeight="bold" color={textColor}>
|
|
{num} / {allPages}
|
|
</Text>
|
|
|
|
{startIndex != allPages ? (
|
|
<Button onClick={goNext} ml={'auto'} size="lg">
|
|
下一页
|
|
</Button>
|
|
) : (
|
|
void 0
|
|
)}
|
|
</Flex>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default paging;
|