diff --git a/themes/hexo-theme-xups/_config.yml b/themes/hexo-theme-xups/_config.yml index 41d13ab..a38783c 100644 --- a/themes/hexo-theme-xups/_config.yml +++ b/themes/hexo-theme-xups/_config.yml @@ -64,14 +64,13 @@ avatar: https://i.loli.net/2018/05/04/5aeb37415a0dc.jpg #---------------------------- # 是否开启分享 #---------------------------- -share: true - -#---------------------------- -# 侧栏是否显示微博秀 -#---------------------------- -weibo_show: - enable: false - code: +share: + enable: true + list: + 1: weibo + 2: qqzone + 3: qq + 4: douban #---------------------------- # 是否开启评论 @@ -86,7 +85,17 @@ comment: #---------------------------- # 是否开启云标签 #---------------------------- -tagcloud: true +tagcloud: + enable: true + start_color: e87474 + end_color: 524ac5 + +#---------------------------- +# 是否开启文章归档 +#---------------------------- +archives: + enable: true + date_format: YYYY年MM月 #---------------------------- # 友情链接 diff --git a/themes/hexo-theme-xups/layout/_partial/after-footer.ejs b/themes/hexo-theme-xups/layout/_partial/after-footer.ejs index 22f88d1..63dcad3 100644 --- a/themes/hexo-theme-xups/layout/_partial/after-footer.ejs +++ b/themes/hexo-theme-xups/layout/_partial/after-footer.ejs @@ -1,4 +1,3 @@ - <%- js('js/main') %> <%- js('js/lib/polyfill.min') %> <%- js('js/lib/vue.min') %> diff --git a/themes/hexo-theme-xups/layout/_partial/archive-post.ejs b/themes/hexo-theme-xups/layout/_partial/archive-post.ejs index b94f50c..5649075 100644 --- a/themes/hexo-theme-xups/layout/_partial/archive-post.ejs +++ b/themes/hexo-theme-xups/layout/_partial/archive-post.ejs @@ -1,7 +1,7 @@
- + <% if (post.categories && post.categories.length) { %> <%- list_categories(post.categories, { @@ -9,7 +9,7 @@ class: 'cat', style: 'none', separator: '|' - }).split('|')[0] + }) %> <% } else { %> 未分类 @@ -18,7 +18,7 @@ <%- partial('post/title', { class_name: 'post-title' }) %>

- <%- post.author || '柠烟夏季' %> 发表于 + <%- post.author || config.author %> 发表于 <%- partial('post/date', { date_format: 'YYYY-MM-DD' }) %>   

- - <% if (pagination == 2) { %> - 最近动态 - <% } else if (pagination == 3) { %> - 文章归档 - <% } else if (pagination == 4) { %> - `<%- page.category %>`分类下的文章 - <% } else if (pagination == 5) { %> - `<%- page.tag %>`标签下的文章 - <% } %> - -

- <% page.posts.each(function(post) { %> - <%- partial('archive-post', { post: post }) %> - <% }) %> - - <% if (page.total >= 1){ %> - +

+ + <% if (pagination == 1) { %> + 最近动态 + <% } else if (pagination == 2) { %> + <%- page.category %> 分类下的文章 + <% } else if (pagination == 3) { %> + <%- page.tag %> 标签下的文章 + <% } else { %> + 文章归档 <% } %> + +

+<% +if(pagination) { + page.posts.each(function(post) { + %> + <%-partial('archive-post', { post: post }) %> + <% + }) +} else { + let lastYear, lastMonth; + + let currentPosts = []; + site.posts.each(function(post) { + if(post.date.year() == page.year && (post.date.month()+1 == page.month || !page.month)) { + currentPosts.push(post) + } + }) + currentPosts.sort(function(a, b){ return b.date - a.date;}); + currentPosts.forEach(function(post) { + if(post.date.year() !== lastYear || post.date.month()+1 !== lastMonth) { + if(lastYear && lastMonth) { %> <% } + %> +

+ <%= post.date.year() %>年<%= post.date.month()+1 %>月 +

+ <% +} +%> + +<% if (pagination && page.total >= 1){ %> + <% } %> diff --git a/themes/hexo-theme-xups/layout/_partial/post/share.ejs b/themes/hexo-theme-xups/layout/_partial/post/share.ejs index af26c43..c162d92 100644 --- a/themes/hexo-theme-xups/layout/_partial/post/share.ejs +++ b/themes/hexo-theme-xups/layout/_partial/post/share.ejs @@ -1,11 +1,10 @@ -<% if (theme.share) { %> +<% if (theme.share.enable) { %>
<% } %> \ No newline at end of file diff --git a/themes/hexo-theme-xups/layout/_partial/sidebar.ejs b/themes/hexo-theme-xups/layout/_partial/sidebar.ejs index 2b7b192..343b78a 100644 --- a/themes/hexo-theme-xups/layout/_partial/sidebar.ejs +++ b/themes/hexo-theme-xups/layout/_partial/sidebar.ejs @@ -5,18 +5,17 @@ <%- partial('_widget/categorys') %> - <% if (theme.tagcloud) { %> + <% if (theme.tagcloud.enable) { %>

热门标签

<%- partial('_widget/tags_cloud') %>
<% } %> - <% if (theme.weibo_show.enable) { %> - + <% if (theme.archives.enable) { %>
-

我的微博

- <%- partial('_widget/weibo') %> +

文章归档

+ <%- list_archives({format: theme.archives.date_format}) %>
<% } %> diff --git a/themes/hexo-theme-xups/layout/_widget/categorys.ejs b/themes/hexo-theme-xups/layout/_widget/categorys.ejs index 59c1032..2d255f0 100644 --- a/themes/hexo-theme-xups/layout/_widget/categorys.ejs +++ b/themes/hexo-theme-xups/layout/_widget/categorys.ejs @@ -3,7 +3,7 @@ <% site.categories.forEach(function(cat){ %>
  • <%= cat.name %> - (<%= cat.length %>) + <%= cat.length %>
  • <% }); %> \ No newline at end of file diff --git a/themes/hexo-theme-xups/layout/_widget/friend_links.ejs b/themes/hexo-theme-xups/layout/_widget/friend_links.ejs index 61fa60a..710941b 100644 --- a/themes/hexo-theme-xups/layout/_widget/friend_links.ejs +++ b/themes/hexo-theme-xups/layout/_widget/friend_links.ejs @@ -1,11 +1,8 @@ - + \ No newline at end of file diff --git a/themes/hexo-theme-xups/layout/_widget/tags_cloud.ejs b/themes/hexo-theme-xups/layout/_widget/tags_cloud.ejs index ed9536e..56b01ea 100644 --- a/themes/hexo-theme-xups/layout/_widget/tags_cloud.ejs +++ b/themes/hexo-theme-xups/layout/_widget/tags_cloud.ejs @@ -5,7 +5,7 @@ max_font: 30, amount: 999, color: true, - start_color: '#e87474', - end_color: '#524ac5', + start_color: '#'+theme.tagcloud.start_color, + end_color: '#'+theme.tagcloud.end_color }) %> \ No newline at end of file diff --git a/themes/hexo-theme-xups/layout/_widget/weibo.ejs b/themes/hexo-theme-xups/layout/_widget/weibo.ejs deleted file mode 100644 index a95f4bf..0000000 --- a/themes/hexo-theme-xups/layout/_widget/weibo.ejs +++ /dev/null @@ -1,29 +0,0 @@ -
    -
    微博加载中...
    - <%- theme.weibo_show.code %> - -
    \ No newline at end of file diff --git a/themes/hexo-theme-xups/layout/archive.ejs b/themes/hexo-theme-xups/layout/archive.ejs index 091b806..63553a4 100644 --- a/themes/hexo-theme-xups/layout/archive.ejs +++ b/themes/hexo-theme-xups/layout/archive.ejs @@ -1,2 +1,2 @@ -<%- partial('_partial/archive', { pagination: 3, index: true }) %> \ No newline at end of file +<%- partial('_partial/archive', { pagination: false, index: true }) %> \ No newline at end of file diff --git a/themes/hexo-theme-xups/layout/category.ejs b/themes/hexo-theme-xups/layout/category.ejs index 27cc348..ce7388c 100644 --- a/themes/hexo-theme-xups/layout/category.ejs +++ b/themes/hexo-theme-xups/layout/category.ejs @@ -1,2 +1,2 @@ -<%- partial('_partial/archive', { pagination: 4, index: true }) %> \ No newline at end of file +<%- partial('_partial/archive', { pagination: 2, index: true }) %> \ No newline at end of file diff --git a/themes/hexo-theme-xups/layout/index.ejs b/themes/hexo-theme-xups/layout/index.ejs index f286030..14dd6db 100644 --- a/themes/hexo-theme-xups/layout/index.ejs +++ b/themes/hexo-theme-xups/layout/index.ejs @@ -2,5 +2,5 @@ <% if (page.content) { %> <%- page.content %> <% } else { %> - <%- partial('_partial/archive', { pagination: 2, index: true }) %> + <%- partial('_partial/archive', { pagination: 1, index: true }) %> <% } %> diff --git a/themes/hexo-theme-xups/layout/tag.ejs b/themes/hexo-theme-xups/layout/tag.ejs index d4b86c8..774d56c 100644 --- a/themes/hexo-theme-xups/layout/tag.ejs +++ b/themes/hexo-theme-xups/layout/tag.ejs @@ -1,2 +1,2 @@ -<%- partial('_partial/archive', { pagination: 5, index: true }) %> \ No newline at end of file +<%- partial('_partial/archive', { pagination: 3, index: true }) %> \ No newline at end of file diff --git a/themes/hexo-theme-xups/source/css/_partial/post.styl b/themes/hexo-theme-xups/source/css/_partial/post.styl index c7e7f14..57d8970 100644 --- a/themes/hexo-theme-xups/source/css/_partial/post.styl +++ b/themes/hexo-theme-xups/source/css/_partial/post.styl @@ -117,3 +117,20 @@ border-left 4px solid c-eee p margin 0 + +.archive-wapper + list-style none + display flex + flex-wrap wrap + justify-content space-between + .archive-item + display inline-block + height 50px + padding 5px + width 30% + > a > .archive-div + border 1px solid #a7a7a7 + border-radius 5px + height 100% + padding 5px + box-sizing border-box diff --git a/themes/hexo-theme-xups/source/css/_partial/sidebar.styl b/themes/hexo-theme-xups/source/css/_partial/sidebar.styl index 2a4d02e..db90783 100644 --- a/themes/hexo-theme-xups/source/css/_partial/sidebar.styl +++ b/themes/hexo-theme-xups/source/css/_partial/sidebar.styl @@ -15,7 +15,7 @@ ul margin 0 padding 0 - .widget-hd + .widget-hd, .widget-date margin 0 padding 0 border-bottom 2px solid c-eee @@ -34,7 +34,12 @@ text-decoration underline &:hover text-decoration none - .widget-bd + .widget-date + text-align center + border-bottom none + strong + border-bottom none + .widget-bd, .archive-list margin 0 padding 0 list-style none @@ -43,10 +48,17 @@ padding 10px 0 line-height 1.5 border-bottom 1px solid c-eee - font-size 12px + font-size 14px overflow hidden text-overflow ellipsis white-space nowrap + .badge, .archive-list-count + &::before + content "(" + &::after + content ")" + color #a4a4a4 + padding .2em .5em a .avatar float left width 36px