diff --git a/.gitignore b/.gitignore index d866945..8529875 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,6 @@ testem.log # System Files .DS_Store -Thumbs.db \ No newline at end of file +Thumbs.db + +_config-test.yml \ No newline at end of file diff --git a/_config.yml b/_config.yml index de7e08e..f6955d7 100644 --- a/_config.yml +++ b/_config.yml @@ -52,7 +52,7 @@ valine: appkey: # your leancloud application appkey notify: false # mail notifier, https://github.com/xCss/Valine/wiki verify: false # Verification code - placeholder: 评论一下再走吧~ + placeholder: Comment input placeholder # Show PV/UV of the website/page with busuanzi. diff --git a/layout/archive-post.ejs b/layout/archive-post.ejs index ebe414e..c4ca7d8 100644 --- a/layout/archive-post.ejs +++ b/layout/archive-post.ejs @@ -1,29 +1,20 @@ -<% const posts = is_archive() ? site.posts : page.posts %> +<% +const postList = createNewArchivePosts(is_archive() ? site.posts : page.posts) +%>
- <% let last; %> - <% posts.each(function(post, i){ %> - <% let year = post.date.year(); %> - <% if (last != year) { %> - <% if (last != null){ %> -
-<% } %> -<% last = year; %> -
-
- <%= year %> -
-
- <% } %> -
- <%= post.title %> - -
- <% }) %> - <% if (posts.length){ %> -
-
-<% } %> + <% postList.forEach(postYear => { %> +
+
<%= postYear.year %>
+ +
+ <% }) %> - - - diff --git a/scripts/helper.js b/scripts/helper.js index 963cca9..05a9734 100644 --- a/scripts/helper.js +++ b/scripts/helper.js @@ -1,7 +1,23 @@ hexo.extend.helper.register('isInHomePaging', function (pagePath, route) { - if (pagePath.length > 5 && route === '/' ) { + if (pagePath.length > 5 && route === '/') { return pagePath.slice(0, 5) === 'page/'; } else { return false; } +}); + +hexo.extend.helper.register('createNewArchivePosts', function (posts) { + const postList = [], postYearList = []; + posts.forEach(post => postYearList.push(post.date.year())); + Array.from(new Set(postYearList)).forEach(year => { + postList.push({ + year: year, + postList: [] + }) + }); + postList.forEach(item => { + posts.forEach(post => item.year === post.date.year() && item.postList.push(post)) + }); + postList.forEach(item => item.postList.sort((a, b) => a.date.unix() - b.date.unix())); + return postList; }); \ No newline at end of file diff --git a/source/css/layout/archive-post.styl b/source/css/layout/archive-post.styl index 2109028..d8dc25a 100644 --- a/source/css/layout/archive-post.styl +++ b/source/css/layout/archive-post.styl @@ -6,7 +6,7 @@ $archive-article-date-font-size = 14px; .archive-container { - .archives-wrap { + .archive-item { margin-bottom: 20px; .archive-year { @@ -15,14 +15,14 @@ $archive-article-date-font-size = 14px; font-weight: 600; } - .archive-article-list { + .article-list { padding-left: 10px; - .archive-article-item { + .article-item { margin: 10px 0; font-size: $archive-article-item-title-font-size; - a.archive-article-title { + a.article-title { color: $archive-article-title-color; &:hover { @@ -30,7 +30,7 @@ $archive-article-date-font-size = 14px; } } - .archive-article-date { + .article-date { font-size: $archive-article-date-font-size; float: right; } diff --git a/source/css/layout/basic.styl b/source/css/layout/basic.styl index 166f1f8..d64b5fa 100644 --- a/source/css/layout/basic.styl +++ b/source/css/layout/basic.styl @@ -84,4 +84,17 @@ a:hover, a:active { visibility: visible; transform: scaleX(1); } +} + + +// Clearfix. http://nicolasgallagher.com/micro-clearfix-hack/ +clearfix() { + &:before, + &:after { + content: " "; + display: table; + } + &:after { + clear: both; + } } \ No newline at end of file