-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6563890
commit 0bec0a1
Showing
9 changed files
with
171 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Post } from "./../../.contentlayer/generated"; | ||
import React, { memo, useEffect } from "react"; | ||
import ArticleItem from "./ArticleItem"; | ||
interface Props { | ||
posts: Post[]; | ||
} | ||
const ArticleList = ({ posts }: Props) => { | ||
return ( | ||
<> | ||
{posts.map((item) => ( | ||
<ArticleItem articleInfo={item} key={item.key} /> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default ArticleList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from "react"; | ||
|
||
interface Props { | ||
totalPages: number; | ||
currentPage: number; | ||
pageChange: (num: number) => void; | ||
} | ||
|
||
export default function Pagination({ | ||
totalPages, | ||
currentPage, | ||
pageChange, | ||
}: Props) { | ||
const prevPage = currentPage - 1 > 0; | ||
const nextPage = currentPage + 1 <= totalPages; | ||
|
||
return ( | ||
<div className="space-y-2 md:space-y-5"> | ||
<nav className="flex justify-between"> | ||
{!prevPage && ( | ||
<button | ||
className="cursor-auto disabled:opacity-50" | ||
disabled={!prevPage} | ||
> | ||
上一页 | ||
</button> | ||
)} | ||
{prevPage && ( | ||
<button | ||
onClick={() => pageChange(currentPage > 1 ? currentPage - 1 : 1)} | ||
> | ||
{" "} | ||
上一页 | ||
</button> | ||
)} | ||
<span> | ||
{currentPage} of {totalPages} | ||
</span> | ||
{!nextPage && ( | ||
<button | ||
className="cursor-auto disabled:opacity-50" | ||
disabled={!nextPage} | ||
> | ||
下一页 | ||
</button> | ||
)} | ||
{nextPage && ( | ||
<button | ||
onClick={() => | ||
pageChange( | ||
currentPage < totalPages ? currentPage + 1 : totalPages | ||
) | ||
} | ||
> | ||
下一页 | ||
</button> | ||
)} | ||
</nav> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters