From 75d18040efbf30e965a4b9bae8a584107b28e6ec Mon Sep 17 00:00:00 2001 From: XPoet Date: Tue, 17 Mar 2020 17:58:18 +0800 Subject: [PATCH] =?UTF-8?q?Add:=20=E5=BD=92=E6=A1=A3=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=8C=89=E5=B9=B4=E4=BB=BD=E5=88=86=E7=B1=BB=EF=BC=8C=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=9F=BA=E7=A1=80=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/common/archive-post.ejs | 51 +++++++++++++++++++++++------ layout/page.ejs | 4 +-- scripts/helper.js | 9 +++++ source/css/common/archive-post.styl | 36 ++++++++++++++++++++ source/css/common/site-info.styl | 2 +- source/css/style.styl | 1 + source/js/main.js | 8 ++++- source/js/utils.js | 3 +- 8 files changed, 99 insertions(+), 15 deletions(-) create mode 100644 scripts/helper.js create mode 100644 source/css/common/archive-post.styl diff --git a/layout/common/archive-post.ejs b/layout/common/archive-post.ejs index b172eb5..c9353eb 100644 --- a/layout/common/archive-post.ejs +++ b/layout/common/archive-post.ejs @@ -1,11 +1,42 @@ - \ No newline at end of file +<% if (is_archive()) { %> + +
+ + + <% let last; %> + <% site.posts.each(function(post, i){ %> + <% let year = post.date.year(); %> + <% if (last != year) { %> + <% if (last != null){ %> +
+ <% } %> + <% last = year; %> +
+
+ <%= year %> +
+
+ <% } %> +
+ <%= post.title %> + +
+ <% }) %> + <% if (site.posts.length){ %> +
+
+ <% } %> + + + + +<% } %> + + + + + + + + diff --git a/layout/page.ejs b/layout/page.ejs index 7026f71..bfdb9b2 100644 --- a/layout/page.ejs +++ b/layout/page.ejs @@ -1,4 +1,4 @@ - +
<%- partial('left-side') %> @@ -6,4 +6,4 @@
<%- partial('right-side') %>
-
+
\ No newline at end of file diff --git a/scripts/helper.js b/scripts/helper.js new file mode 100644 index 0000000..a13c273 --- /dev/null +++ b/scripts/helper.js @@ -0,0 +1,9 @@ +/** + * Hexo 扩展:辅助函数(Helper) + * 补充复杂的业务逻辑 + * https://hexo.io/zh-cn/api/helper.html + * 用法:<%= helper_test('xxx') %> + */ +hexo.extend.helper.register('helper_test', function (character) { + return character + '😁'; +}); \ No newline at end of file diff --git a/source/css/common/archive-post.styl b/source/css/common/archive-post.styl new file mode 100644 index 0000000..77fd3af --- /dev/null +++ b/source/css/common/archive-post.styl @@ -0,0 +1,36 @@ +.archive-container { + background: #fff + padding 30px + + .archives-wrap { + margin-bottom 20px + + .archive-year { + font-size: 24px; + color: #666; + font-weight: 600; + } + + .archive-article-list { + + .archive-article-item { + margin 10px 0 + font-size 16px + + a.archive-article-title { + color #8f8f8f + + &:hover { + color: #4786D6; + } + } + + .archive-article-date { + float right + } + } + } + } +} + + diff --git a/source/css/common/site-info.styl b/source/css/common/site-info.styl index 2302ce8..6729106 100644 --- a/source/css/common/site-info.styl +++ b/source/css/common/site-info.styl @@ -3,7 +3,7 @@ .avatar { padding 2px - border-radius 50% + border-radius 10% border 1px solid #ddd width: 50%; } diff --git a/source/css/style.styl b/source/css/style.styl index f0a60cd..ecc3248 100644 --- a/source/css/style.styl +++ b/source/css/style.styl @@ -7,6 +7,7 @@ @import "footer.styl" @import "common/nav.styl" @import "common/article-post.styl" +@import "common/archive-post.styl" @import "common/site-info.styl" .header { diff --git a/source/js/main.js b/source/js/main.js index 97621a0..411c975 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -5,4 +5,10 @@ console.log('this is main.js'); e.classList.add('btn'); e.setAttribute('role', 'navigation'); }); -})(); \ No newline at end of file +})(); + +// app.locals.structureArchiveList = function (posts) { +// posts.forEach(post => { +// console.log('post: ', post); +// }); +// }; \ No newline at end of file diff --git a/source/js/utils.js b/source/js/utils.js index c201c97..9173cc7 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -1,3 +1,4 @@ export const addClass = (element, className) => { element.classList.add(className) -}; \ No newline at end of file +}; +