From a8909aac0635606d2ed6dfe1ea7ac37393dc8d37 Mon Sep 17 00:00:00 2001 From: XPoet Date: Tue, 31 Oct 2023 17:39:13 +0800 Subject: [PATCH] refactor: reconstructs the `scroll` configuration items --- _config.yml | 20 ++++++++++++-------- layout/_partial/progress-bar.ejs | 2 +- source/css/layout/_partial/progress-bar.styl | 2 +- source/js/utils.js | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/_config.yml b/_config.yml index a33a8fa1a..5cb2ef666 100644 --- a/_config.yml +++ b/_config.yml @@ -34,15 +34,9 @@ style: # Avatar (You can use local image or image external link) avatar: /images/avatar.svg - # Page scroll style settings - scroll: - # Show progress bar in top when page scroll - progress_bar: false # Option values: true | false - - # Show percent when page scroll - percent: false # Option values: true | false - +# --------------------------------------------------------------------------------------- # First screen style settings +# --------------------------------------------------------------------------------------- first_screen: enable: false # Option values: true | false @@ -59,6 +53,16 @@ first_screen: # If enable hitokoto, first screen description is different every time when you enter the site hitokoto: false # Option values: true | false +# --------------------------------------------------------------------------------------- +# Page scroll style settings +# --------------------------------------------------------------------------------------- +scroll: + # Show progress bar in top when page scroll + progress_bar: false # Option values: true | false + + # Show percent when page scroll + percent: false # Option values: true | false + # --------------------------------------------------------------------------------------- # Navigation menu # Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/menu.html diff --git a/layout/_partial/progress-bar.ejs b/layout/_partial/progress-bar.ejs index 8ff617add..447b8f8b9 100644 --- a/layout/_partial/progress-bar.ejs +++ b/layout/_partial/progress-bar.ejs @@ -1,5 +1,5 @@
- <% if (theme?.style?.scroll?.progress_bar === true) { %> + <% if (theme?.scroll?.progress_bar === true) { %> <% } %> diff --git a/source/css/layout/_partial/progress-bar.styl b/source/css/layout/_partial/progress-bar.styl index c257bec98..917c78a7c 100644 --- a/source/css/layout/_partial/progress-bar.styl +++ b/source/css/layout/_partial/progress-bar.styl @@ -48,7 +48,7 @@ } } - if (hexo-config('style') && hexo-config('style.scroll') && hexo-config('style.scroll.progress_bar') == true) { + if (hexo-config('scroll') && hexo-config('scroll.progress_bar') == true) { .scroll-progress-bar { position absolute top 0 diff --git a/source/js/utils.js b/source/js/utils.js index 02ab81a62..24ed06b2b 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -21,7 +21,7 @@ KEEP.initUtils = () => { // initialization data initData() { - const { scroll } = KEEP.theme_config?.style || {} + const scroll = KEEP.theme_config?.scroll || {} const first_screen = KEEP.theme_config?.first_screen || {} this.isHasScrollProgressBar = scroll?.progress_bar === true this.isHasScrollPercent = scroll?.percent === true