From e56f5718d283f7d85e8650a41e0260b8eae762cd Mon Sep 17 00:00:00 2001 From: XPoet Date: Mon, 17 Oct 2022 21:54:21 +0800 Subject: [PATCH] build: rename `code-block-tools` -> `code-block` --- _config.yml | 4 +- layout/_partial/scripts.ejs | 6 +- scripts/helpers/export-config.js | 2 +- ...{code-block-tools.styl => code-block.styl} | 2 +- source/css/common/code-block/code-theme.styl | 60 +++++++++---------- source/css/style.styl | 2 +- .../js/{code-block-tools.js => code-block.js} | 2 +- source/js/main.js | 4 +- 8 files changed, 41 insertions(+), 41 deletions(-) rename source/css/common/code-block/{code-block-tools.styl => code-block.styl} (95%) rename source/js/{code-block-tools.js => code-block.js} (99%) diff --git a/_config.yml b/_config.yml index 6390661..9d2b585 100644 --- a/_config.yml +++ b/_config.yml @@ -153,10 +153,10 @@ post: custom_label_list: ["Trainee", "Engineer", "Architect"] # --------------------------------------------------------------------------------------- -# Code block tools +# Code block # Support code copy and code block collapse # --------------------------------------------------------------------------------------- -code_block_tools: +code_block: enable: false # Option values: true | false style: default # Option values: default | mac diff --git a/layout/_partial/scripts.ejs b/layout/_partial/scripts.ejs index f9e69b0..638cf95 100644 --- a/layout/_partial/scripts.ejs +++ b/layout/_partial/scripts.ejs @@ -10,7 +10,7 @@ const { local_search: t_local_search, code_copy: t_code_copy, - code_block_tools: t_code_block_tools, + code_block: t_code_block, lazyload: t_lazyload, toc: t_toc, pjax: t_pjax @@ -21,8 +21,8 @@ const { <%- __js('js/local-search.js') %> <% } %> -<% if (t_code_block_tools?.enable === true || t_code_copy?.enable === true) { %> - <%- __js('js/code-block-tools.js') %> +<% if (t_code_block?.enable === true || t_code_copy?.enable === true) { %> + <%- __js('js/code-block.js') %> <% } %> <% if (t_lazyload?.enable === true) { %> diff --git a/scripts/helpers/export-config.js b/scripts/helpers/export-config.js index eb1e47b..9b5770f 100644 --- a/scripts/helpers/export-config.js +++ b/scripts/helpers/export-config.js @@ -40,7 +40,7 @@ hexo.extend.helper.register('export_config', function () { style: theme.style || {}, local_search: theme.local_search || {}, code_copy: theme.code_copy || {}, - code_block_tools: theme.code_block_tools || {}, + code_block: theme.code_block || {}, side_tools: theme.side_tools || {}, pjax: theme.pjax || {}, lazyload: theme.lazyload || {}, diff --git a/source/css/common/code-block/code-block-tools.styl b/source/css/common/code-block/code-block.styl similarity index 95% rename from source/css/common/code-block/code-block-tools.styl rename to source/css/common/code-block/code-block.styl index b442a96..66f546e 100644 --- a/source/css/common/code-block/code-block-tools.styl +++ b/source/css/common/code-block/code-block.styl @@ -54,7 +54,7 @@ } - if (hexo-config('code_block_tools.style') == 'mac' || hexo-config('code_copy.style') == 'mac') { + if (hexo-config('code_block.style') == 'mac' || hexo-config('code_copy.style') == 'mac') { margin 1.4rem 0 1.8rem 0 box-shadow 0 0.8rem 2rem 0 rgba(0, 0, 0, 0.4) diff --git a/source/css/common/code-block/code-theme.styl b/source/css/common/code-block/code-theme.styl index aad0bdf..04698de 100644 --- a/source/css/common/code-block/code-theme.styl +++ b/source/css/common/code-block/code-theme.styl @@ -17,38 +17,38 @@ $highlight-purple = #8959a8 $highlight-deletion = #fdd $highlight-addition = #dfd -$night-code-foreground = lighten($dark-text-color-3, 2%) -$night-code-background = darken($dark-background-color-1, 10%) -$night-highlight-foreground = lighten($dark-text-color-3, 2%) -$night-highlight-background = darken($dark-background-color-1, 8%) -$night-highlight-gutter-color = lighten($dark-text-color-3, 5%) -$night-highlight-gutter-bg-color = darken($dark-background-color-1, 10%) -$night-highlight-comment = #969896 -$night-highlight-red = #cc6666 -$night-highlight-orange = #de935f -$night-highlight-yellow = #f0c674 -$night-highlight-green = #b5bd68 -$night-highlight-aqua = #8abeb7 -$night-highlight-blue = #81a2be -$night-highlight-purple = #b294bb -$night-highlight-deletion = #008000 -$night-highlight-addition = #800000 +$dark-code-foreground = lighten($dark-text-color-3, 2%) +$dark-code-background = darken($dark-background-color-1, 10%) +$dark-highlight-foreground = lighten($dark-text-color-3, 2%) +$dark-highlight-background = darken($dark-background-color-1, 8%) +$dark-highlight-gutter-color = lighten($dark-text-color-3, 5%) +$dark-highlight-gutter-bg-color = darken($dark-background-color-1, 10%) +$dark-highlight-comment = #969896 +$dark-highlight-red = #cc6666 +$dark-highlight-orange = #de935f +$dark-highlight-yellow = #f0c674 +$dark-highlight-green = #b5bd68 +$dark-highlight-aqua = #8abeb7 +$dark-highlight-blue = #81a2be +$dark-highlight-purple = #b294bb +$dark-highlight-deletion = #008000 +$dark-highlight-addition = #800000 code-theme(mode) { - --code-foreground mode == 'light' ? $code-foreground : $night-code-foreground - --code-background mode == 'light' ? $code-background : $night-code-background - --highlight-background mode == 'light' ? $highlight-background : $night-highlight-background - --highlight-foreground mode == 'light' ? $highlight-foreground : $night-highlight-foreground - --highlight-comment mode == 'light' ? $highlight-comment : $night-highlight-comment - --highlight-red mode == 'light' ? $highlight-red : $night-highlight-red - --highlight-orange mode == 'light' ? $highlight-orange : $night-highlight-orange - --highlight-yellow mode == 'light' ? $highlight-yellow : $night-highlight-yellow - --highlight-green mode == 'light' ? $highlight-green : $night-highlight-green - --highlight-aqua mode == 'light' ? $highlight-aqua : $night-highlight-aqua - --highlight-blue mode == 'light' ? $highlight-blue : $night-highlight-blue - --highlight-purple mode == 'light' ? $highlight-purple : $night-highlight-purple - --highlight-gutter-color mode == 'light' ? $highlight-gutter-color : $night-highlight-gutter-color - --highlight-gutter-bg-color mode == 'light' ? $highlight-gutter-bg-color : $night-highlight-gutter-bg-color + --code-foreground mode == 'light' ? $code-foreground : $dark-code-foreground + --code-background mode == 'light' ? $code-background : $dark-code-background + --highlight-background mode == 'light' ? $highlight-background : $dark-highlight-background + --highlight-foreground mode == 'light' ? $highlight-foreground : $dark-highlight-foreground + --highlight-comment mode == 'light' ? $highlight-comment : $dark-highlight-comment + --highlight-red mode == 'light' ? $highlight-red : $dark-highlight-red + --highlight-orange mode == 'light' ? $highlight-orange : $dark-highlight-orange + --highlight-yellow mode == 'light' ? $highlight-yellow : $dark-highlight-yellow + --highlight-green mode == 'light' ? $highlight-green : $dark-highlight-green + --highlight-aqua mode == 'light' ? $highlight-aqua : $dark-highlight-aqua + --highlight-blue mode == 'light' ? $highlight-blue : $dark-highlight-blue + --highlight-purple mode == 'light' ? $highlight-purple : $dark-highlight-purple + --highlight-gutter-color mode == 'light' ? $highlight-gutter-color : $dark-highlight-gutter-color + --highlight-gutter-bg-color mode == 'light' ? $highlight-gutter-bg-color : $dark-highlight-gutter-bg-color } diff --git a/source/css/style.styl b/source/css/style.styl index 2f56545..8c4f126 100644 --- a/source/css/style.styl +++ b/source/css/style.styl @@ -1,7 +1,7 @@ @import "common/basic.styl" @import "common/markdown.styl" @import "common/code-block/highlight.styl" -@import "common/code-block/code-block-tools.styl" +@import "common/code-block/code-block.styl" @import "common/code-block/code-theme.styl" @import "layout/page.styl" @import "layout/_partial/local-search.styl" diff --git a/source/js/code-block-tools.js b/source/js/code-block.js similarity index 99% rename from source/js/code-block-tools.js rename to source/js/code-block.js index 1830ec8..7c679d7 100644 --- a/source/js/code-block-tools.js +++ b/source/js/code-block.js @@ -8,7 +8,7 @@ KEEP.initCodeBlockTools = () => { } const { style: codeCopyStyle } = KEEP.theme_config?.code_copy - const { style: codeBlockStyle } = KEEP.theme_config?.code_block_tools + const { style: codeBlockStyle } = KEEP.theme_config?.code_block const isMac = (codeBlockStyle || codeCopyStyle || 'default') === 'mac' const foldedIconClassName = isMac ? 'fas fa-chevron-left' : 'fas fa-chevron-right' const { diff --git a/source/js/main.js b/source/js/main.js index f068836..c1c6b00 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -1,7 +1,7 @@ /* global KEEP */ window.addEventListener('DOMContentLoaded', () => { - const { version, local_search, code_block_tools, code_copy, lazyload } = KEEP.theme_config + const { version, local_search, code_block, code_copy, lazyload } = KEEP.theme_config KEEP.themeInfo = { theme: `Keep v${version}`, @@ -56,7 +56,7 @@ window.addEventListener('DOMContentLoaded', () => { KEEP.initLocalSearch() } - if (code_block_tools?.enable === true || code_copy?.enable === true) { + if (code_block?.enable === true || code_copy?.enable === true) { KEEP.initCodeBlockTools() }