refactor: 重写filter页面 更新为search
This commit is contained in:
60
src/components/Post/Pagination.astro
Normal file
60
src/components/Post/Pagination.astro
Normal file
@@ -0,0 +1,60 @@
|
||||
---
|
||||
interface Props {
|
||||
page: number
|
||||
totalPage: number
|
||||
}
|
||||
|
||||
const {page, totalPage} = Astro.props
|
||||
---
|
||||
|
||||
<!--分页器-->
|
||||
{totalPage > 1 &&
|
||||
<nav class="pagination" aria-label="分页">
|
||||
{page > 1 ? <a href={`/page/${page - 1}`} class="link">« 上一页</a> : <span class="link disabled">« 上一页</span>}
|
||||
{Array.from({length: totalPage}).map((_, index) => {
|
||||
if (page === index + 1) {
|
||||
return <span class="link current">{index + 1}</span>
|
||||
}
|
||||
return <a class="link" href={`/page/${index + 1}`}>{index + 1}</a>
|
||||
})}
|
||||
{page < totalPage ? <a href={`/page/${page + 1}`} class="link">下一页 »</a> :
|
||||
<span class="link disabled">下一页 »</span>}
|
||||
</nav>}
|
||||
|
||||
<style>
|
||||
/* ========== 分页 ========== */
|
||||
.pagination {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 38px;
|
||||
height: 38px;
|
||||
padding: 0 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border);
|
||||
font-size: 14px;
|
||||
color: var(--text-secondary);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.link:hover,
|
||||
.link.current {
|
||||
background: var(--primary);
|
||||
border-color: var(--primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.link.disabled {
|
||||
color: var(--text-secondary);
|
||||
background: var(--card-bg);
|
||||
border-color: var(--border);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user