feat: category pages and tag pages add paging

This commit is contained in:
XPoet 2020-09-02 13:11:09 +08:00
parent 1cf2122620
commit 39dcb9bc32
9 changed files with 47 additions and 36 deletions

View File

@ -0,0 +1,13 @@
<div class="paginator">
<% if (pageObject.prev) { %>
<a class="prev btn"
href="<%- url_for(pageObject.prev_link) %>"
><%- __('prev') %></a>
<% } %>
<% if (pageObject.next) { %>
<a class="next btn"
href="<%- url_for(pageObject.next_link) %>"
><%- __('next') %></a>
<% } %>
</div>

View File

@ -3,6 +3,11 @@
<div class="category-name">
<i class="fa fa-folder"></i> <%- __('category') %><%= page.category %> [<%= page.posts.length %>]
</div>
<%- partial('_partial/archive-list', {posts_new: page.posts}) %>
<div class="category-post-list">
<%- partial('_partial/archive-list', {posts_new: page.posts}) %>
</div>
</div>
<div class="category-paginator">
<%- partial('_partial/paginator', {pageObject: page}) %>
</div>
</div>

View File

@ -44,17 +44,7 @@
<% }) %>
</ul>
<div class="paginator">
<% if (page.prev) { %>
<a class="prev btn"
href="<%- url_for(page.prev == 1 ? '' : '/page/' + page.prev) %>"
><%- __('prev') %></a>
<% } %>
<% if (page.next) { %>
<a class="next btn"
href="<%- url_for('/page/' + page.next) %>"
><%- __('next') %></a>
<% } %>
<div class="home-paginator">
<%- partial('_partial/paginator', {pageObject: page}) %>
</div>
</div>

View File

@ -2,6 +2,12 @@
<div class="tag-container">
<div class="tag-name"><i class="fa fa-tag"></i> <%- __('tag') %><%= page.tag %> [<%= page.posts.length %>]
</div>
<%- partial('_partial/archive-list', {posts_new: page.posts}) %>
<div class="tag--post-list">
<%- partial('_partial/archive-list', {posts_new: page.posts}) %>
</div>
</div>
</div>
<div class="tag-paginator">
<%- partial('_partial/paginator', {pageObject: page}) %>
</div>
</div>

View File

@ -21,4 +21,4 @@ hexo.extend.helper.register('createNewArchivePosts', function (posts) {
});
postList.forEach(item => item.postList.sort((a, b) => b.date.unix() - a.date.unix()));
return postList;
});
});

View File

@ -0,0 +1,13 @@
.paginator {
margin-top: 30px;
a.prev {
float: left;
}
a.next {
float: right;
}
}

View File

@ -29,8 +29,7 @@ html, body {
}
&::-webkit-scrollbar-thumb {
border-radius: 1px;
background: rgba(0, 0, 0, 0.28)
background: rgba(0, 0, 0, 0.2)
}
&::-webkit-scrollbar-track {

View File

@ -111,20 +111,4 @@
}
}
.paginator {
padding-bottom: 40px;
a.prev {
float: left;
}
a.next {
float: right;
}
}
}
}

View File

@ -10,6 +10,7 @@
@import "layout/_partial/tools.styl"
@import "layout/_partial/archive-list.styl"
@import "layout/_partial/footer.styl"
@import "layout/_partial/paginator.styl"
@import "layout/about.styl"
@import "layout/links.styl"
@import "layout/_partial/article-meta-info.styl"
@ -25,4 +26,4 @@
@import "layout/_partial/site-info.styl"
@import "layout/_partial/sidebar-categories.styl"
@import "layout/_partial/sidebar-tags.styl"
@import "layout/_partial/sidebar-tagcloud.styl"
@import "layout/_partial/sidebar-tagcloud.styl"