From 150cac9bb193afff7339bfb867b81b0c0d3e2aa1 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Sun, 12 Dec 2021 16:24:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E6=96=87=E7=AB=A0=E5=B0=81=E9=9D=A2+?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=A8=AA=E5=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/_partial/cover/index.ejs | 12 ++++ layout/_partial/cover/post_cover.ejs | 26 +++++++++ .../{main/article => cover}/wiki_cover.ejs | 5 +- layout/_partial/main/post_list/post_card.ejs | 34 +++++++++-- layout/_partial/main/post_list/wiki_card.ejs | 2 + layout/index.ejs | 7 ++- layout/layout.ejs | 2 +- layout/post.ejs | 3 + source/css/_custom.styl | 6 +- source/css/_layout/list.styl | 57 +++++++++---------- source/css/_layout/md.styl | 11 ++-- source/css/_layout/partial/cover.styl | 46 +++++++++++---- 12 files changed, 150 insertions(+), 61 deletions(-) create mode 100644 layout/_partial/cover/index.ejs create mode 100644 layout/_partial/cover/post_cover.ejs rename layout/_partial/{main/article => cover}/wiki_cover.ejs (92%) diff --git a/layout/_partial/cover/index.ejs b/layout/_partial/cover/index.ejs new file mode 100644 index 0000000..b63c82b --- /dev/null +++ b/layout/_partial/cover/index.ejs @@ -0,0 +1,12 @@ +<% +function layoutCover() { + if (page.layout == 'wiki') { + return partial('wiki_cover'); + } + if (page.layout == 'post') { + return partial('post_cover'); + } + return ''; +} +%> +<%- layoutCover() %> diff --git a/layout/_partial/cover/post_cover.ejs b/layout/_partial/cover/post_cover.ejs new file mode 100644 index 0000000..425c214 --- /dev/null +++ b/layout/_partial/cover/post_cover.ejs @@ -0,0 +1,26 @@ +<% +function div() { + var el = ''; + if (page.banner == undefined || page.banner == false) { + return el; + } + el += '
'; + el += '
'; + if (theme.plugins.lazyload && theme.plugins.lazyload.enable) { + el += '
'; + } else { + el += '
'; + } + el += '
'; + if (page.title) { + el += '
'; + el += '

'; + el += page.title; + el += '

'; + el += '
'; + } + el += '
'; + return el; +} +%> +<%- div() %> diff --git a/layout/_partial/main/article/wiki_cover.ejs b/layout/_partial/cover/wiki_cover.ejs similarity index 92% rename from layout/_partial/main/article/wiki_cover.ejs rename to layout/_partial/cover/wiki_cover.ejs index a4c30bc..cc399f6 100644 --- a/layout/_partial/main/article/wiki_cover.ejs +++ b/layout/_partial/cover/wiki_cover.ejs @@ -1,9 +1,6 @@ <% function layoutWikiCover() { var el = ''; - if (page.layout !== 'wiki') { - return el; - } let proj = theme.wiki.projects[page.wiki]; if (proj == undefined) { return el; @@ -21,7 +18,7 @@ function layoutWikiCover() { if (cover === true) { cover = ['logo', 'title', 'description']; } - el += '
'; + el += '
'; el += '
'; if (logo && logo.src && cover.includes('logo')) { diff --git a/layout/_partial/main/post_list/post_card.ejs b/layout/_partial/main/post_list/post_card.ejs index 5d32216..416e4fc 100755 --- a/layout/_partial/main/post_list/post_card.ejs +++ b/layout/_partial/main/post_list/post_card.ejs @@ -1,7 +1,7 @@ <% -function layoutDiv() { +function div_default() { var el = ''; - + el += '
'; // 标题 el += '

'; el += (post.title || post.seo_title) ? (post.title || post.seo_title) : date(post.date, config.date_format); @@ -43,12 +43,36 @@ function layoutDiv() { } } } + el += '

'; if (post.pin) { el += ''; } - el += '
'; - + el += ''; return el; } +function div_photo() { + var el = ''; + el += '
'; + el += ''; + el += '
'; + el += ''; + el += __("meta.created") + ' ' + ''; + el += ''; + el += '
'; + el += '
'; + + el += '
'; + el += '

'; + el += post.title; + el += '

'; + el += '
'; + return el; +} +function div() { + if (post.cover && post.cover.length > 0) { + return div_photo(); + } + return div_default(); +} %> -<%- layoutDiv() %> +<%- div() %> diff --git a/layout/_partial/main/post_list/wiki_card.ejs b/layout/_partial/main/post_list/wiki_card.ejs index 96303af..456f33b 100644 --- a/layout/_partial/main/post_list/wiki_card.ejs +++ b/layout/_partial/main/post_list/wiki_card.ejs @@ -1,6 +1,7 @@ <% function layoutDiv() { var el = ''; + el += '
'; if (proj.logo && proj.logo.src) { el += '
'; el += 'logo'; } el += '
'; + el += '
'; return el; } %> diff --git a/layout/index.ejs b/layout/index.ejs index 33c6424..3e6373c 100755 --- a/layout/index.ejs +++ b/layout/index.ejs @@ -12,10 +12,13 @@ if (page.title && page.wiki) { function layout_post_card(layout, post, content) { var el = ''; + var layout = layout; + if (layout == 'post' && post.cover != undefined) { + layout += ' photo'; + } el += ''; - el += '
'; el += content; - el += '
'; + el += ''; return el; } diff --git a/layout/layout.ejs b/layout/layout.ejs index 5e7199c..1e1e36b 100755 --- a/layout/layout.ejs +++ b/layout/layout.ejs @@ -2,7 +2,7 @@ <%- partial('_partial/head') %> - <%- partial('_partial/main/article/wiki_cover') %> + <%- partial('_partial/cover/index') %>