From 97a68b77d2d5db930836e585f4829131c280ecde Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Sat, 5 Nov 2022 00:13:32 +0800 Subject: [PATCH] cover --- layout/_partial/main/post_list/post_card.ejs | 33 +++++++++++--------- layout/index.ejs | 2 +- source/css/_layout/list.styl | 9 ++++-- source/css/_plugins/lazyload.styl | 2 +- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/layout/_partial/main/post_list/post_card.ejs b/layout/_partial/main/post_list/post_card.ejs index 80f6de7..50b50b5 100755 --- a/layout/_partial/main/post_list/post_card.ejs +++ b/layout/_partial/main/post_list/post_card.ejs @@ -1,11 +1,14 @@ <% -const obj = { - image: post['cover'], - title: post['cover-title'], - cat: post['cover-cat'], - subtitle: post['cover-subtitle'], - color: post['cover-text-color'] +const poster = post.poster; +var obj = { + image: post.cover }; +if (poster) { + obj.headline = poster.headline; + obj.topic = poster.topic; + obj.caption = poster.caption; + obj.color = poster.color; +} function div_default() { var el = ''; el += '
'; @@ -97,24 +100,24 @@ function div_photo() { var el = ''; el += '
'; el += ''; - if (obj.title || obj.cat || obj.subtitle) { + if (obj.headline || obj.topic || obj.caption) { el += '
'; + if (obj.topic) { + el += '
' + obj.topic + '
'; } - if (obj.title) { - el += '
' + obj.title + '
'; + if (obj.headline) { + el += '
' + obj.headline + '
'; } - if (obj.subtitle) { - el += '
' + obj.subtitle + '
'; + if (obj.caption) { + el += '
' + obj.caption + '
'; } el += '
'; @@ -123,7 +126,7 @@ function div_photo() { return el; } function div() { - if (obj.image && obj.image.length > 0 && obj.title != undefined) { + if (obj.image && obj.image.length > 0 && obj.headline != undefined) { return div_photo(); } return div_default(); diff --git a/layout/index.ejs b/layout/index.ejs index 0e46860..68cbc71 100755 --- a/layout/index.ejs +++ b/layout/index.ejs @@ -13,7 +13,7 @@ if (page.title && page.wiki) { function layout_post_card(layout, post, content) { var el = ''; var layout = layout; - if (layout == 'post' && post['cover'] != undefined && post['cover-title'] != undefined) { + if (layout == 'post' && post.cover != undefined && post.poster != undefined) { layout += ' photo'; } el += ''; diff --git a/source/css/_layout/list.styl b/source/css/_layout/list.styl index d3465c2..f47050d 100644 --- a/source/css/_layout/list.styl +++ b/source/css/_layout/list.styl @@ -1,15 +1,13 @@ // list .post-list margin: 1rem - .post-title - margin-top: 1.5rem .post-title:first-child margin-top: .5rem .post-list .post-title font-weight: 500 - margin: .75rem 0 + margin: 1.25rem 0 .75rem 0 line-height: 1.2 font-size: $fs-h3 border-bottom: none @@ -29,6 +27,7 @@ box-shadow: 0 2px 8px 0px rgba(0, 0, 0, 0.02) trans1 box-shadow overflow: hidden + z-index: 0 background: var(--card) position: relative .excerpt @@ -53,8 +52,12 @@ img object-fit: contain height: 1.5em + .post-list .post-card:hover box-shadow: 0 1px 4px 0px rgba(0, 0, 0, 0.1), 0 4px 16px 0px rgba(0, 0, 0, 0.1) + img + transform: scale(1.02) + filter: brightness(80%) // common article diff --git a/source/css/_plugins/lazyload.styl b/source/css/_plugins/lazyload.styl index d78b8f5..f6481d6 100644 --- a/source/css/_plugins/lazyload.styl +++ b/source/css/_plugins/lazyload.styl @@ -1,5 +1,5 @@ trans-cover($p, $t = 0.28s) - trans2pro: transform 1s $p $t + trans2pro: transform 0.5s $p $t trans-site($p) trans2: box-shadow transform $p trans-user($p)