From 7ff99a7abd103a723cc066656740f8cde1ad897d Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Thu, 4 Apr 2019 11:30:14 +0800 Subject: [PATCH] update --- _config.yml | 7 ++ layout/_meta/author.ejs | 8 ++ layout/_meta/categories.ejs | 16 ++++ layout/_meta/counter.ejs | 12 +++ layout/_meta/date.ejs | 6 ++ layout/_meta/music.ejs | 6 ++ layout/_meta/share.ejs | 3 + layout/_meta/tags.ejs | 9 ++ layout/_meta/thumbnail.ejs | 3 + layout/_meta/title.ejs | 11 +++ layout/_meta/topping.ejs | 8 ++ layout/_meta/updated.ejs | 6 ++ layout/_partial/article.ejs | 156 ++++++++++++++-------------------- layout/_partial/meta.ejs | 138 ++++++++++++------------------ layout/_partial/post.ejs | 2 +- layout/_partial/side.ejs | 2 +- layout/_third-party/share.ejs | 54 ++++++------ layout/links.ejs | 3 +- 18 files changed, 241 insertions(+), 209 deletions(-) create mode 100755 layout/_meta/author.ejs create mode 100755 layout/_meta/categories.ejs create mode 100644 layout/_meta/counter.ejs create mode 100755 layout/_meta/date.ejs create mode 100644 layout/_meta/music.ejs create mode 100644 layout/_meta/share.ejs create mode 100644 layout/_meta/tags.ejs create mode 100644 layout/_meta/thumbnail.ejs create mode 100644 layout/_meta/title.ejs create mode 100644 layout/_meta/topping.ejs create mode 100644 layout/_meta/updated.ejs diff --git a/_config.yml b/_config.yml index d6ed9b4..9edcd55 100755 --- a/_config.yml +++ b/_config.yml @@ -102,6 +102,13 @@ menu_mobile: icon: fas fa-info-circle url: about/ +# 默认的meta信息,文章中没有配置则按照这里的配置来显示,设置为false则不显示 +# 其中,title只在top中有效,music和thumbnail无需在这里设置,文章中有则显示 +# 如果tags放置在meta.header中,那么在post列表中不显示(因为卡片下方已经有了) +meta: + header: [title, author, date, categories, counter] + footer: [updated, tags, share] + # 侧边栏小部件,默认按下面给定的顺序全部显示,文章中还可以自定义显示一部分以及顺序 sidebar: diff --git a/layout/_meta/author.ejs b/layout/_meta/author.ejs new file mode 100755 index 0000000..39f0641 --- /dev/null +++ b/layout/_meta/author.ejs @@ -0,0 +1,8 @@ +<% if(post.author || config.author){ %> +
+ + + <%- post.author || config.author %> + +
+<% } %> diff --git a/layout/_meta/categories.ejs b/layout/_meta/categories.ejs new file mode 100755 index 0000000..0a1f5f8 --- /dev/null +++ b/layout/_meta/categories.ejs @@ -0,0 +1,16 @@ +<% if (post.categories && post.categories.length && post.categories.forEach){ %> + <% + var cats = []; + var path; + post.categories.forEach(function(cat){ + cats.push(cat.name); + path = cat.path; + }); + %> +
+ + + <%- cats.join(' / ') %> + +
+<% } %> diff --git a/layout/_meta/counter.ejs b/layout/_meta/counter.ejs new file mode 100644 index 0000000..d023ba7 --- /dev/null +++ b/layout/_meta/counter.ejs @@ -0,0 +1,12 @@ +<% if(!isPostList){ %> + <% if (theme.busuanzi == true) { %> +
+ + + + + + +
+ <% } %> +<% } %> diff --git a/layout/_meta/date.ejs b/layout/_meta/date.ejs new file mode 100755 index 0000000..1ebb93a --- /dev/null +++ b/layout/_meta/date.ejs @@ -0,0 +1,6 @@ +
+ + + <%= date(post.date, theme.date_format) %> + +
diff --git a/layout/_meta/music.ejs b/layout/_meta/music.ejs new file mode 100644 index 0000000..71268fe --- /dev/null +++ b/layout/_meta/music.ejs @@ -0,0 +1,6 @@ +<% if(post.music && post.music.enable != false){ %> + <%- partial('../_third-party/aplayer', + {aplayer_theme: '', aplayer_mini: true, aplayer_mode: 'circulation', + aplayer_server: post.music.server, aplayer_type: post.music.type, aplayer_id: post.music.id, + aplayer_volume: post.music.volume?post.music.volume:'0.7', aplayer_autoplay: post.music.autoplay?true:false }) %> +<% } %> diff --git a/layout/_meta/share.ejs b/layout/_meta/share.ejs new file mode 100644 index 0000000..cb515b3 --- /dev/null +++ b/layout/_meta/share.ejs @@ -0,0 +1,3 @@ +<% if (theme.share) { %> + <%- partial('../_third-party/share') %> +<% } %> diff --git a/layout/_meta/tags.ejs b/layout/_meta/tags.ejs new file mode 100644 index 0000000..5b4d646 --- /dev/null +++ b/layout/_meta/tags.ejs @@ -0,0 +1,9 @@ +<% if (!isPostList && post.tags && post.tags.length) { %> + <% + var items = []; + post.tags.each(function(item){ + items.push('
 ' + item.name + '
'); + }); + %> + <%- items.join(' ') %> +<% } %> diff --git a/layout/_meta/thumbnail.ejs b/layout/_meta/thumbnail.ejs new file mode 100644 index 0000000..8cd4762 --- /dev/null +++ b/layout/_meta/thumbnail.ejs @@ -0,0 +1,3 @@ +<% if(post.thumbnail && post.thumbnail.length){ %> + +<% } %> diff --git a/layout/_meta/title.ejs b/layout/_meta/title.ejs new file mode 100644 index 0000000..a51126c --- /dev/null +++ b/layout/_meta/title.ejs @@ -0,0 +1,11 @@ +<% if(isPostList){ %> +

+ + <%- post.title ? post.title : date(post.date, theme.date_format) %> + +

+<% } else { %> + <% if (post.title || page.title || config.title) { %> +

<%- post.title ? post.title : date(post.date, theme.date_format) %>

+ <% } %> +<% } %> diff --git a/layout/_meta/topping.ejs b/layout/_meta/topping.ejs new file mode 100644 index 0000000..e4b36c3 --- /dev/null +++ b/layout/_meta/topping.ejs @@ -0,0 +1,8 @@ +<% if(isPostList && post.top){ %> +
+ + + <%- post.top != true ? post.top : __('post.top') %> + +
+<% } %> diff --git a/layout/_meta/updated.ejs b/layout/_meta/updated.ejs new file mode 100644 index 0000000..12559e6 --- /dev/null +++ b/layout/_meta/updated.ejs @@ -0,0 +1,6 @@ +
+ + + <%- __('post.updated') + ' ' + date(post.updated, theme.updated_date_format) %> + +
diff --git a/layout/_partial/article.ejs b/layout/_partial/article.ejs index a82a563..68f5589 100755 --- a/layout/_partial/article.ejs +++ b/layout/_partial/article.ejs @@ -1,98 +1,72 @@
- <%- partial('meta',{post:post}) %> -
-
- <%- post.content %> -
- <% if(post.layout == 'post'){ %> - + + + <% if (post.next.tags && post.next.tags.length && post.next.tags.each) { %> + <% + var items = []; + post.next.tags.each(function(item){ + items.push('' + item.name + ''); + }); + %> +
+ <%- items.join(' ') %> +
+ <% } %> + +
+ <%} %> + + <%} %> +
diff --git a/layout/_partial/meta.ejs b/layout/_partial/meta.ejs index 0e6cea3..ae2ee89 100644 --- a/layout/_partial/meta.ejs +++ b/layout/_partial/meta.ejs @@ -3,94 +3,60 @@ } else { var isPostList = false; } -var hasMeta = false; - %> -
- <% if(post.music && post.music.enable != false){ %> - <%- partial('../_third-party/aplayer', - {aplayer_theme: '', aplayer_mini: true, aplayer_mode: 'circulation', - aplayer_server: post.music.server, aplayer_type: post.music.type, aplayer_id: post.music.id, - aplayer_volume: post.music.volume?post.music.volume:'0.7', aplayer_autoplay: post.music.autoplay?true:false }) %> - <% } %> - <% if(post.thumbnail && post.thumbnail.length){ %> - - <% } %> -
- <% if(isPostList){ %> -

- - <% if(post.title){ %> - <%- post.title %> - <% } else if (post.date) { %> - <%= date(post.date, config.date_format) %> - <% } %> - -

- <% } else { %> - <% if(page.title && (!page.meta || page.meta.title != false)){ %> -

<%- page.title %>

- <% hasMeta = true %> - <% } %> - <% } %> +var topMetas = (theme.meta && theme.meta.header) || []; +if (post.meta && (post.meta.header !== undefined && post.meta.header !== null)) { + if (post.meta.header.length) { + topMetas = post.meta.header; + } else { + topMetas = []; + } +} +var bottomMetas = (theme.meta && theme.meta.footer) || []; +if (post.meta && (post.meta.footer !== undefined && post.meta.footer !== null)) { + if (post.meta.footer.length) { + bottomMetas = post.meta.footer; + } else { + bottomMetas = []; + } +} +%> -
- <% if(config.author && (!post.meta || post.meta.author != false)){ %> - - <% } %> - <% if(post.date && (!post.meta || post.meta.date != false)){ %> - +<% if (position == 'header') { %> +
+ <% if (post.music && post.music.enable != false) { %> + <%- partial('../_third-party/aplayer', + {aplayer_theme: '', aplayer_mini: true, aplayer_mode: 'circulation', + aplayer_server: post.music.server, aplayer_type: post.music.type, aplayer_id: post.music.id, + aplayer_volume: post.music.volume?post.music.volume:'0.7', aplayer_autoplay: post.music.autoplay?true:false }) %> + <% } %> + <% if(post.thumbnail && post.thumbnail.length){ %> + + <% } %> +
+ <% if((topMetas).indexOf('title') > -1){ %> + <%- partial('../_meta/' + 'title', {post: post, isPostList: isPostList}) %> <% } %> - <% if(post.categories && (!post.meta || post.meta.categories != false)){ %> - <% if (post.categories && post.categories.length && post.categories.forEach){ %> - <% - var cats = []; - var path; - post.categories.forEach(function(cat){ - cats.push(cat.name); - path = cat.path; - }); - %> - - <% } %> +
+ <% (topMetas).forEach(function(meta){ %> + <% if(meta != 'title'){ %> + <%- partial('../_meta/' + meta, {post: post, isPostList: isPostList}) %> + <% } %> + <% }) %> +
+ <% if ((topMetas).length > 0){ %> +
<% } %> - <% if(!isPostList && (!post.meta || post.meta.counter != false)){ %> - <% if (theme.busuanzi == true) { %> - +
+
+<% } else if (position == 'footer') { %> +
-
+ +<% } %> diff --git a/layout/_partial/post.ejs b/layout/_partial/post.ejs index c1e8250..3e1c7db 100755 --- a/layout/_partial/post.ejs +++ b/layout/_partial/post.ejs @@ -1,5 +1,5 @@
"> - <%- partial('meta',{post:post}) %> + <%- partial('meta',{post:post, position:'header'}) %>
<%- post.excerpt || post.description || post.content %> diff --git a/layout/_partial/side.ejs b/layout/_partial/side.ejs index 0a3aa4e..348dc5c 100755 --- a/layout/_partial/side.ejs +++ b/layout/_partial/side.ejs @@ -3,7 +3,7 @@ <% let supportWidgets = ['author', 'category', 'list', 'music', 'tagcloud', 'toc', 'plain', 'related_posts', 'grid']; %> - <% if (page.sidebar){ %> + <% if (page.sidebar) { %> <% page.sidebar.forEach(function(name){ %> <% theme.sidebar.forEach(function(item){ %> <% let widget_name = item.widget ? item.widget : 'plain'; %> diff --git a/layout/_third-party/share.ejs b/layout/_third-party/share.ejs index db00229..7afb3b8 100644 --- a/layout/_third-party/share.ejs +++ b/layout/_third-party/share.ejs @@ -1,34 +1,32 @@ -<% if (theme.share && page.layout == 'post' && page.share != false) { %> -