feat: 新增分页组件、归档页分类
This commit is contained in:
parent
8202cf3e48
commit
78472f90a4
|
@ -46,13 +46,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- //TODO 分页 -->
|
<!-- 分页 -->
|
||||||
<nav id="pagination">
|
<div th:replace="modules/widgets/page :: page('/archives',${archives})"></div>
|
||||||
<div class="pagination">
|
|
||||||
<span class="page-number current" th:if="${archives.page} == ${index}"
|
|
||||||
th:text="${archives.page}"></span>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- sidebar -->
|
<!-- sidebar -->
|
||||||
<div th:replace="modules/aside :: aside(${theme.config.sidebar.categoryWidgets})"></div>
|
<div th:replace="modules/aside :: aside(${theme.config.sidebar.categoryWidgets})"></div>
|
||||||
|
|
|
@ -62,10 +62,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<nav id="pagination">
|
<div th:replace="modules/widgets/page :: page(${'/categories/'+category.spec.slug},${posts})"></div>
|
||||||
<div class="pagination"><span class="page-number current">1</span></div>
|
|
||||||
</nav>
|
|
||||||
</div>
|
</div>
|
||||||
|
<!-- sidebar -->
|
||||||
<div th:replace="modules/aside :: aside(${theme.config.sidebar.categoryWidgets})"></div>
|
<div th:replace="modules/aside :: aside(${theme.config.sidebar.categoryWidgets})"></div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
|
@ -80,102 +80,11 @@
|
||||||
</time>
|
</time>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 分页 -->
|
||||||
<nav id="pagination" th:if="${posts.hasPrevious() || posts.hasNext()}"
|
<div th:replace="modules/widgets/page :: page('',${posts})"></div>
|
||||||
th:with="totalPages = ${posts.totalPages}, pageIndex = ${posts.page}">
|
|
||||||
<!-- 页面小于 7 -->
|
|
||||||
<div class="pagination" th:if="${(totalPages le 7) && (totalPages gt 0)}">
|
|
||||||
|
|
||||||
<!-- 上一页 -->
|
|
||||||
<a class="extend prev" rel="prev" th:href="@{${posts.prevUrl}}" th:if="${posts.hasPrevious()}">
|
|
||||||
<i class="iconfont icon-chevron-left"></i>
|
|
||||||
<div class="pagination_tips_prev">上页</div>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a class="page-number"
|
|
||||||
th:classappend="${index eq pageIndex} ? 'current'"
|
|
||||||
th:each="index : ${#numbers.sequence(1, totalPages)}"
|
|
||||||
th:href="@{'/page/' + ${index}}"
|
|
||||||
th:text="${index}">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<!-- 下一页 -->
|
|
||||||
<a class="extend next" rel="next" th:href="@{${posts.nextUrl}}" th:if="${posts.hasNext()}">
|
|
||||||
<div class="pagination_tips_next">下页</div>
|
|
||||||
<i class="iconfont icon-chevron-right"></i>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 页面大于 7 -->
|
|
||||||
<!-- https://blog.csdn.net/lizc_lizc/article/details/80215147 -->
|
|
||||||
<div class="pagination" th:if="${totalPages gt 7}">
|
|
||||||
|
|
||||||
<!-- 上一页 -->
|
|
||||||
<a class="extend prev" rel="prev" th:href="@{${posts.prevUrl}}" th:if="${posts.hasPrevious()}">
|
|
||||||
<i class="iconfont icon-chevron-left"></i>
|
|
||||||
<div class="pagination_tips_prev">上页</div>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<!-- 首页 -->
|
|
||||||
<a class="page-number" href="/">1</a>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 当前页面小于等于4 -->
|
|
||||||
<a class="page-number"
|
|
||||||
th:classappend="${index eq pageIndex} ? 'current'"
|
|
||||||
th:each="index : ${#numbers.sequence(2,5)}"
|
|
||||||
th:href="@{'/page/' + ${index}}"
|
|
||||||
th:if="${pageIndex le 4}"
|
|
||||||
th:text="${index}">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a class="page-number" th:if="${pageIndex le 4}">...</a>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 最后一页与当前页面之差小于等于3 -->
|
|
||||||
<a class="page-number" th:if="${totalPages - pageIndex le 3}">...</a>
|
|
||||||
<a class="page-number"
|
|
||||||
th:classappend="${index eq pageIndex} ? 'current'"
|
|
||||||
th:each="index : ${#numbers.sequence(totalPages - 4, totalPages - 1)}"
|
|
||||||
th:href="@{'/page/' + ${index}}"
|
|
||||||
th:if="${totalPages - pageIndex le 3}"
|
|
||||||
th:text="${index}">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 最后一页与当前页面之差大于3 且当前页面大于4 -->
|
|
||||||
<a class="page-number" th:if="${(pageIndex gt 4) && (totalPages - pageIndex gt 3)}">...</a>
|
|
||||||
<a class="page-number"
|
|
||||||
th:each="index : ${#numbers.sequence(pageIndex - 1,pageIndex + 1)}"
|
|
||||||
th:href="@{'/page/' + ${index}}"
|
|
||||||
th:if="${(pageIndex gt 4) && (totalPages - pageIndex gt 3)}"
|
|
||||||
th:text="${index}">
|
|
||||||
</a>
|
|
||||||
<!-- 需要添加 th:href 跳转地址 -->
|
|
||||||
<a class="page-number" th:if="${(pageIndex gt 4) && (totalPages - pageIndex gt 3)}">...</a>
|
|
||||||
|
|
||||||
<!-- 尾页 -->
|
|
||||||
<!-- 需要添加 th:href 跳转地址 -->
|
|
||||||
<a class="page-number"
|
|
||||||
th:classappend="${index eq pageIndex} ? 'current'"
|
|
||||||
th:text="${totalPages}">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<!-- 下一页 -->
|
|
||||||
<a class="extend next" rel="next" th:href="@{${posts.nextUrl}}" th:if="${posts.hasNext()}">
|
|
||||||
<div class="pagination_tips_next">下页</div>
|
|
||||||
<i class="iconfont icon-chevron-right"></i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
</th:block>
|
</th:block>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<!--
|
||||||
|
分页模块
|
||||||
|
|
||||||
|
@param path '/path/page/n' 中的 `/path` 需要保留 `/`
|
||||||
|
@param pageInfo Halo类型UrlContextListResult<ListedPostVo>
|
||||||
|
-->
|
||||||
|
<nav id="pagination" th:fragment="page(path,pageInfo)">
|
||||||
|
<div class="pagination">
|
||||||
|
|
||||||
|
<!-- 页码按钮 -->
|
||||||
|
<th:block th:if="${pageInfo.page > 3}">
|
||||||
|
<a class="page-number" th:href="${path+'/page/1'}" th:text="1"></a>
|
||||||
|
<span class="space" th:if="${pageInfo.page != 4}">…</span>
|
||||||
|
</th:block>
|
||||||
|
|
||||||
|
<th:block th:each="index:${#numbers.sequence(pageInfo.page-2,pageInfo.page+2)}">
|
||||||
|
<span class="page-number current" th:if="${pageInfo.page} == ${index}" th:text="${pageInfo.page}"></span>
|
||||||
|
<a class="page-number" th:unless="${pageInfo.page == index}" th:if="${index > 0 && index <= pageInfo.totalPages}"
|
||||||
|
th:href="${path+'/page/'+index}" th:text="${index}"></a>
|
||||||
|
</th:block>
|
||||||
|
|
||||||
|
<th:block th:if="${pageInfo.totalPages - pageInfo.page > 2}">
|
||||||
|
<span class="space" th:if="${pageInfo.totalPages - pageInfo.page != 3}">…</span>
|
||||||
|
<a class="page-number" th:href="${path+'/page/'+pageInfo.totalPages}" th:text="${pageInfo.totalPages}"></a>
|
||||||
|
</th:block>
|
||||||
|
|
||||||
|
<!-- 翻页按钮 -->
|
||||||
|
<a class="extend prev" rel="prev" th:if="${pageInfo.hasPrevious}" th:href="${pageInfo.prevUrl}" data-pjax-state="">
|
||||||
|
<i class="fas fa-chevron-left fa-fw"></i>
|
||||||
|
<div class="pagination_tips_prev">上页</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a class="extend next" rel="next" th:if="${pageInfo.hasNext}" th:href="${pageInfo.nextUrl}" data-pjax-state="">
|
||||||
|
<div class="pagination_tips_next">下页</div>
|
||||||
|
<i class="fas fa-chevron-right fa-fw"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</html>
|
|
@ -1,5 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" th:replace="modules/layouts/layout :: layout(content = ~{::content}, htmlType = 'tag')" xmlns:th="http://www.thymeleaf.org">
|
<html lang="en" th:replace="modules/layouts/layout :: layout(content = ~{::content}, htmlType = 'tag')"
|
||||||
|
xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
<th:block th:fragment="content">
|
<th:block th:fragment="content">
|
||||||
|
|
||||||
|
@ -26,7 +27,8 @@
|
||||||
th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"," : theme.config.layout.postRandomImg+"?"}'>
|
th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"," : theme.config.layout.postRandomImg+"?"}'>
|
||||||
<a class="article-sort-item-img" th:href="@{${post.status.permalink}}"
|
<a class="article-sort-item-img" th:href="@{${post.status.permalink}}"
|
||||||
th:title="${post.spec.title}">
|
th:title="${post.spec.title}">
|
||||||
<img loading="lazy" th:alt="${post.status.excerpt}" th:src="${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}">
|
<img loading="lazy" th:alt="${post.status.excerpt}"
|
||||||
|
th:src="${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}">
|
||||||
</a>
|
</a>
|
||||||
<div class="article-sort-item-info">
|
<div class="article-sort-item-info">
|
||||||
<div class="article-sort-item-time"><i class="far fa-calendar-alt"></i>
|
<div class="article-sort-item-time"><i class="far fa-calendar-alt"></i>
|
||||||
|
@ -48,10 +50,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<nav id="pagination">
|
<!-- 分页 -->
|
||||||
<div class="pagination"><span class="page-number current">1</span></div>
|
<div th:replace="modules/widgets/page :: page(${'/tags/'+tag.spec.slug},${posts})"></div>
|
||||||
</nav>
|
|
||||||
</div>
|
</div>
|
||||||
|
<!-- sidebar -->
|
||||||
<div th:replace="modules/aside :: aside(${theme.config.sidebar.tagWidgets})"></div>
|
<div th:replace="modules/aside :: aside(${theme.config.sidebar.tagWidgets})"></div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue