From 39dcb9bc329373132cef361c1e3d13602e9acf2c Mon Sep 17 00:00:00 2001 From: XPoet Date: Wed, 2 Sep 2020 13:11:09 +0800 Subject: [PATCH] feat: category pages and tag pages add paging --- layout/_partial/paginator.ejs | 13 +++++++++++++ layout/category-content.ejs | 7 ++++++- layout/home-content.ejs | 14 ++------------ layout/tag-content.ejs | 10 ++++++++-- scripts/helpers/helper.js | 2 +- source/css/layout/_partial/paginator.styl | 13 +++++++++++++ source/css/layout/common/basic.styl | 3 +-- source/css/layout/home-content.styl | 18 +----------------- source/css/style.styl | 3 ++- 9 files changed, 47 insertions(+), 36 deletions(-) create mode 100644 layout/_partial/paginator.ejs create mode 100644 source/css/layout/_partial/paginator.styl diff --git a/layout/_partial/paginator.ejs b/layout/_partial/paginator.ejs new file mode 100644 index 0000000..efa98fb --- /dev/null +++ b/layout/_partial/paginator.ejs @@ -0,0 +1,13 @@ +
+ <% if (pageObject.prev) { %> + + <% } %> + + <% if (pageObject.next) { %> + + <% } %> +
diff --git a/layout/category-content.ejs b/layout/category-content.ejs index 8fe604f..8e05849 100644 --- a/layout/category-content.ejs +++ b/layout/category-content.ejs @@ -3,6 +3,11 @@
<%- __('category') %>:<%= page.category %> [<%= page.posts.length %>]
- <%- partial('_partial/archive-list', {posts_new: page.posts}) %> +
+ <%- partial('_partial/archive-list', {posts_new: page.posts}) %> +
+ +
+ <%- partial('_partial/paginator', {pageObject: page}) %>
diff --git a/layout/home-content.ejs b/layout/home-content.ejs index d1a0b2c..d39c38e 100644 --- a/layout/home-content.ejs +++ b/layout/home-content.ejs @@ -44,17 +44,7 @@ <% }) %> -
- <% if (page.prev) { %> - - <% } %> - - <% if (page.next) { %> - - <% } %> +
+ <%- partial('_partial/paginator', {pageObject: page}) %>
diff --git a/layout/tag-content.ejs b/layout/tag-content.ejs index 441002f..e04f4dc 100644 --- a/layout/tag-content.ejs +++ b/layout/tag-content.ejs @@ -2,6 +2,12 @@
<%- __('tag') %>:<%= page.tag %> [<%= page.posts.length %>]
- <%- partial('_partial/archive-list', {posts_new: page.posts}) %> +
+ <%- partial('_partial/archive-list', {posts_new: page.posts}) %> +
- \ No newline at end of file + +
+ <%- partial('_partial/paginator', {pageObject: page}) %> +
+ diff --git a/scripts/helpers/helper.js b/scripts/helpers/helper.js index 0e900cb..2791024 100644 --- a/scripts/helpers/helper.js +++ b/scripts/helpers/helper.js @@ -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; -}); \ No newline at end of file +}); diff --git a/source/css/layout/_partial/paginator.styl b/source/css/layout/_partial/paginator.styl new file mode 100644 index 0000000..14c8f98 --- /dev/null +++ b/source/css/layout/_partial/paginator.styl @@ -0,0 +1,13 @@ +.paginator { + + margin-top: 30px; + + a.prev { + float: left; + } + + a.next { + float: right; + } + +} diff --git a/source/css/layout/common/basic.styl b/source/css/layout/common/basic.styl index 884a94f..71691cb 100644 --- a/source/css/layout/common/basic.styl +++ b/source/css/layout/common/basic.styl @@ -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 { diff --git a/source/css/layout/home-content.styl b/source/css/layout/home-content.styl index 21d2495..10867aa 100644 --- a/source/css/layout/home-content.styl +++ b/source/css/layout/home-content.styl @@ -111,20 +111,4 @@ } } - - - .paginator { - - padding-bottom: 40px; - - a.prev { - float: left; - } - - a.next { - float: right; - } - - } - -} \ No newline at end of file +} diff --git a/source/css/style.styl b/source/css/style.styl index 7ba6005..cc2176c 100644 --- a/source/css/style.styl +++ b/source/css/style.styl @@ -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" \ No newline at end of file +@import "layout/_partial/sidebar-tagcloud.styl"