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"> <div class="category-name">
<i class="fa fa-folder"></i> <%- __('category') %><%= page.category %> [<%= page.posts.length %>] <i class="fa fa-folder"></i> <%- __('category') %><%= page.category %> [<%= page.posts.length %>]
</div> </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>
</div> </div>

View File

@ -44,17 +44,7 @@
<% }) %> <% }) %>
</ul> </ul>
<div class="paginator"> <div class="home-paginator">
<% if (page.prev) { %> <%- partial('_partial/paginator', {pageObject: page}) %>
<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> </div>
</div> </div>

View File

@ -2,6 +2,12 @@
<div class="tag-container"> <div class="tag-container">
<div class="tag-name"><i class="fa fa-tag"></i> <%- __('tag') %><%= page.tag %> [<%= page.posts.length %>] <div class="tag-name"><i class="fa fa-tag"></i> <%- __('tag') %><%= page.tag %> [<%= page.posts.length %>]
</div> </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>
<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())); postList.forEach(item => item.postList.sort((a, b) => b.date.unix() - a.date.unix()));
return postList; 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 { &::-webkit-scrollbar-thumb {
border-radius: 1px; background: rgba(0, 0, 0, 0.2)
background: rgba(0, 0, 0, 0.28)
} }
&::-webkit-scrollbar-track { &::-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/tools.styl"
@import "layout/_partial/archive-list.styl" @import "layout/_partial/archive-list.styl"
@import "layout/_partial/footer.styl" @import "layout/_partial/footer.styl"
@import "layout/_partial/paginator.styl"
@import "layout/about.styl" @import "layout/about.styl"
@import "layout/links.styl" @import "layout/links.styl"
@import "layout/_partial/article-meta-info.styl" @import "layout/_partial/article-meta-info.styl"
@ -25,4 +26,4 @@
@import "layout/_partial/site-info.styl" @import "layout/_partial/site-info.styl"
@import "layout/_partial/sidebar-categories.styl" @import "layout/_partial/sidebar-categories.styl"
@import "layout/_partial/sidebar-tags.styl" @import "layout/_partial/sidebar-tags.styl"
@import "layout/_partial/sidebar-tagcloud.styl" @import "layout/_partial/sidebar-tagcloud.styl"