From cbac32697502b78e44678e0b32475b9b99bd3835 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Wed, 24 Feb 2021 21:27:31 +0800 Subject: [PATCH] update --- _config.yml | 24 ++++---------- layout/_partial/sidebar/header.ejs | 6 ++-- layout/_partial/sidebar/logo.ejs | 8 +++-- scripts/helpers/parse_config.js | 39 +++++++++++++++++++++++ source/css/_defines/base.styl | 5 +++ source/css/_layout/navbar.styl | 7 ++-- source/css/_layout/partial/lazyload.styl | 14 -------- source/css/_layout/partial/read_next.styl | 5 +-- source/css/_layout/post_list.styl | 6 ++-- source/css/_layout/sidebar.styl | 6 ++-- source/css/_plugins/index.styl | 2 ++ source/css/_plugins/lazyload.styl | 14 ++++++++ 12 files changed, 88 insertions(+), 48 deletions(-) create mode 100644 scripts/helpers/parse_config.js delete mode 100644 source/css/_layout/partial/lazyload.styl create mode 100644 source/css/_plugins/lazyload.styl diff --git a/_config.yml b/_config.yml index 4113be6..9795351 100755 --- a/_config.yml +++ b/_config.yml @@ -16,23 +16,13 @@ open_graph: ######## Sidebar ######## sidebar: logo: - avatar: - src: # default is config.avatar - href: # set your user center page like: '/about/' - title: # default is config.title, you can set html tag like: '' + avatar: '[config.avatar](/about/)' # you can set avatar link in _config.yml or '[https://xxx.png](/about/)' + title: '[config.title](/)' # you can set html tag like: '[](/)' menu: - post: - title: btn.blog - url: / - wiki: - title: btn.wiki - url: /wiki/ - friends: - title: 友链 - url: /friends/ - about: - title: 关于 - url: /about/ + post: '[btn.blog](/)' + wiki: '[btn.wiki](/wiki/)' + friends: # '[友链](/friends/)' + about: # '[关于](/about/)' # Sidebar widgets widgets: # default layout in home/wiki/categories/tags/archives pages @@ -151,7 +141,7 @@ plugins: # https://scrollrevealjs.org/api/reveal.html scrollreveal: - enable: true + enable: #true js: https://cdn.jsdelivr.net/npm/scrollreveal@4.0.7/dist/scrollreveal.min.js distance: 8px duration: 500 # ms diff --git a/layout/_partial/sidebar/header.ejs b/layout/_partial/sidebar/header.ejs index fb59f0e..5683cb7 100644 --- a/layout/_partial/sidebar/header.ejs +++ b/layout/_partial/sidebar/header.ejs @@ -4,15 +4,15 @@ function layoutMainMenu() { el += ''; diff --git a/layout/_partial/sidebar/logo.ejs b/layout/_partial/sidebar/logo.ejs index c4faf96..b913884 100644 --- a/layout/_partial/sidebar/logo.ejs +++ b/layout/_partial/sidebar/logo.ejs @@ -1,6 +1,8 @@
- <% if (theme.sidebar.logo.avatar.src || config.avatar) { %> - + <% if (md_text(theme.sidebar.logo.avatar)) { %> + + <% } %> + <% if (md_text(theme.sidebar.logo.title)) { %> + <%- md_text(theme.sidebar.logo.title) %> <% } %> - <%- theme.sidebar.logo.title || config.title %>
diff --git a/scripts/helpers/parse_config.js b/scripts/helpers/parse_config.js new file mode 100644 index 0000000..50e48f4 --- /dev/null +++ b/scripts/helpers/parse_config.js @@ -0,0 +1,39 @@ +/** + * md_link(theme.sidebar.menu['home']) is '/' + * md_text(theme.sidebar.menu['home']) is 'Home' + */ + +'use strict'; + +hexo.extend.helper.register('md_text', function(args) { + if (args == undefined) { + return ''; + } + let tmp = args.split(']('); + if (tmp.length > 1) { + tmp = tmp[0]; + if (tmp.length > 1) { + tmp = tmp.substring(1, tmp.length); + } + } + if (tmp == 'config.title') { + tmp = hexo.config.title; + } else if (tmp == 'config.avatar') { + tmp = hexo.config.avatar; + } + return tmp; +}); + +hexo.extend.helper.register('md_link', function(args) { + if (args == undefined) { + return ''; + } + let tmp = args.split(']('); + if (tmp.length > 1) { + tmp = tmp[1]; + if (tmp.length > 1) { + tmp = tmp.substring(0, tmp.length-1); + } + } + return tmp; +}); diff --git a/source/css/_defines/base.styl b/source/css/_defines/base.styl index 2833bdd..316b9c4 100644 --- a/source/css/_defines/base.styl +++ b/source/css/_defines/base.styl @@ -20,6 +20,11 @@ trans2($op1, $op2) -webkit-transition: $op1 0.2s ease-out, $op2 0.2s ease-out -o-transition: $op1 0.2s ease-out, $op2 0.2s ease-out +trans2pro($op1, $t1, $op2, $t2) + transition: $op1 $t1 ease-out, $op2 $t2 ease-out + -moz-transition: $op1 $t1 ease-out, $op2 $t2 ease-out + -webkit-transition: $op1 $t1 ease-out, $op2 $t2 ease-out + -o-transition: $op1 $t1 ease-out, $op2 $t2 ease-out txt-ellipsis() white-space: nowrap diff --git a/source/css/_layout/navbar.styl b/source/css/_layout/navbar.styl index 51ae334..78cbe92 100644 --- a/source/css/_layout/navbar.styl +++ b/source/css/_layout/navbar.styl @@ -38,14 +38,13 @@ nav.cap align-items: center flex-direction: row &:not([style]) a - color: var(--text-p1) + color: $color-link &[style] a color: inherit span.sep color: var(--text-p3) - // a.cap:hover - // color: $color-cat-hover - // text-decoration: underline + a.cap:hover + color: $color-hover div#post-meta margin-top: 2px diff --git a/source/css/_layout/partial/lazyload.styl b/source/css/_layout/partial/lazyload.styl deleted file mode 100644 index 8c284f5..0000000 --- a/source/css/_layout/partial/lazyload.styl +++ /dev/null @@ -1,14 +0,0 @@ -img - max-width 100% - &.lazyload:not(.placeholder) - transition opacity .5s ease-out 0s - &:not(.loaded) - opacity: 0 - &.loaded - opacity: 1 - if hexo-config('plugins.lazyload.blurIn') == true - transition filter .25s ease-out 0s - &:not(.loaded) - filter blur(8px) - &.loaded - filter none diff --git a/source/css/_layout/partial/read_next.styl b/source/css/_layout/partial/read_next.styl index 9476ae6..1ba4078 100644 --- a/source/css/_layout/partial/read_next.styl +++ b/source/css/_layout/partial/read_next.styl @@ -4,8 +4,6 @@ .post-title margin: 0.5rem 0 line-height: 1.2 - color: var(--text-p2) - font-weight: 500 a color: inherit &:hover @@ -13,5 +11,8 @@ &.read color: var(--text-p3) font-size: $fs14 + font-weight: 500 &.unread + color: var(--text-p1) font-size: 1.75rem + font-weight: 400 diff --git a/source/css/_layout/post_list.styl b/source/css/_layout/post_list.styl index d44512d..4420f61 100644 --- a/source/css/_layout/post_list.styl +++ b/source/css/_layout/post_list.styl @@ -70,7 +70,8 @@ height: 240px @media screen and (max-width: $device-mobile-m) height: 200px - trans1: transform 1s + &:not(.lazyload) + trans1: transform 1s .post-list .post-card.post:hover .post-title color: $color-hover @@ -92,7 +93,8 @@ align-items: center img object-fit: contain - trans1 transform 0.75s + img:not(.lazyload) + trans1: transform 0.75s .post-list .post-card.wiki article .excerpt margin: 1rem min-width: 220px diff --git a/source/css/_layout/sidebar.styl b/source/css/_layout/sidebar.styl index 6ea1141..9e22b63 100644 --- a/source/css/_layout/sidebar.styl +++ b/source/css/_layout/sidebar.styl @@ -30,6 +30,8 @@ background: $color-hover img object-fit: cover + width: 100% + height: 100% .title font-size: 1.75rem font-weight: 900 @@ -79,7 +81,7 @@ nav.menu margin: 1rem 0 2rem 0 .widget-header display: flex - font-size: 1rem + font-size: 1.25rem color: var(--text-meta) justify-content: space-between align-items: center @@ -90,8 +92,6 @@ nav.menu background: var(--site-bg) padding: 2px 0 z-index 1 - .name - font-size: 1rem .cap-action hover-block 4px 4px line-height: 0 diff --git a/source/css/_plugins/index.styl b/source/css/_plugins/index.styl index 3d6c905..0b59b01 100644 --- a/source/css/_plugins/index.styl +++ b/source/css/_plugins/index.styl @@ -2,6 +2,8 @@ @import "common/*" // 根据主题配置加载 +if hexo-config('plugins.lazyload.enable') + @import 'lazyload' if hexo-config('plugins.swiper.enable') @import 'swiper' if hexo-config('plugins.scrollreveal.enable') diff --git a/source/css/_plugins/lazyload.styl b/source/css/_plugins/lazyload.styl new file mode 100644 index 0000000..a23a1a2 --- /dev/null +++ b/source/css/_plugins/lazyload.styl @@ -0,0 +1,14 @@ +if hexo-config('plugins.lazyload.blurIn') == true + img.lazyload:not(.placeholder) + trans2pro: transform 0.75s filter 0.25s + &:not(.loaded) + filter blur(8px) + &.loaded + filter none +else + img.lazyload:not(.placeholder) + trans2pro: transform 0.75s opacity 0.5s + &:not(.loaded) + opacity: 0 + &.loaded + opacity: 1