- <% if (bsz_enable === true) { %> - -
- <% if (bsz_site_uv) { %> - <%- __('site_uv') %>   +
+ <% if (f_style === 'shields') { %> +
+ <% const since_date = f_since ? f_since + '_--_' + date(new Date(), 'YYYY') : date(new Date(), 'YYYY') %> + + <% if (web_master) { %> + + + <% } %> - <% if (bsz_site_pv) { %> - <%- __('site_pv') %>  + <% if (f_icp) { %> + + + <% } %>
- <% } %> -
- <%- __('powered_by', 'Hexo') %> | <%- __('theme') %> Keep v3.6.1 -
- <% if (f_icp) { %> -
- - <%= f_icp %> +
+ + + + + + <% if (f_site_deploy?.enable === true && f_site_deploy?.provider !== '') { %> + <% if (f_site_deploy?.url) { %> + + <% } %> + + <% if (f_site_deploy?.url) { %> + + <% } %> + <% } %>
- <% } %> - <% if (f_site_deploy?.enable === true && f_site_deploy?.provider !== '') { %> -
- <% if (f_site_deploy?.url) { %> - + <% } else { %> + - <% } %> - <% if (f_shields?.enable === true) { %> -
- <% for (var i in f_shields?.data){ %> - <% if (f_shields?.data[i].img_url) { %> - - - + +
+ <%- __('powered_by', 'Hexo') %> | <%- __('theme') %> +  Keep + v3.6.1 +
+ + <% if (f_icp) { %> + + <% } %> + + <% if (f_site_deploy?.enable === true && f_site_deploy?.provider !== '') { %> + + <% } %> + <% } %> + <% if (bsz_enable === true) { %> + +
+ <% if (bsz_site_uv) { %> + + <%- __('site_uv') %> + + <% } %> + <% if (bsz_site_pv) { %> + + <%- __('site_pv') %> + + <% } %>
<% } %> diff --git a/source/css/common/basic.styl b/source/css/common/basic.styl index 882b9495..1802ee82 100644 --- a/source/css/common/basic.styl +++ b/source/css/common/basic.styl @@ -217,6 +217,15 @@ button { } +// ====================================================================== +// flex center +// ====================================================================== +.border-box { + position relative + box-sizing border-box +} + + // ====================================================================== // clear float // ====================================================================== diff --git a/source/css/layout/_partial/footer.styl b/source/css/layout/_partial/footer.styl index 55eaac9d..97703a4d 100644 --- a/source/css/layout/_partial/footer.styl +++ b/source/css/layout/_partial/footer.styl @@ -1,3 +1,5 @@ +$shields-style-height = 22px + .footer { color var(--text-color-4) font-size 1rem @@ -17,24 +19,85 @@ justify-content center padding-bottom 1rem + &.shields { + img { + height $shields-style-height !important + } + } + .info-item { margin 0.2rem 0 color var(--text-color-4) - &.deploy-info { - display flex + &.website-count { - a - .tooltip { + &.shields { display flex - align-items center + justify-content flex-start + + + .count-box { + height $shields-style-height + font-size 12.6px + display flex + justify-content flex-start + color #f2f2f2 + + + .count-item { + height 100% + display flex + align-items center + padding 0 7px + } + + + .item-type { + margin-right 0 + background: #555555 + } + + .item-value { + + &.uv { + background: coral + } + + &.pv { + background: orange + } + } + + } + } + + .uv { + &.has-pv { + margin-right 8px + } } - img { - height 1.2rem - margin 0 0.4rem + .item-type { + margin-right 4px } } + + &.deploy-info { + + display flex + + a.tooltip { + display flex + align-items center + } + + img { + height 1.2rem + margin 0 0.4rem + } + + + } } } From 0c4998c2c5533743efb90ddb7c07001c01ab4369 Mon Sep 17 00:00:00 2001 From: XPoet Date: Wed, 26 Jul 2023 23:34:23 +0800 Subject: [PATCH 017/206] perf(footer): optimize busuanzi initialize --- layout/_partial/footer.ejs | 3 --- scripts/helpers/export-config.js | 2 +- source/css/layout/_partial/footer.styl | 6 +++--- source/js/utils.js | 24 ++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/layout/_partial/footer.ejs b/layout/_partial/footer.ejs index 3c106a0d..073be4fb 100644 --- a/layout/_partial/footer.ejs +++ b/layout/_partial/footer.ejs @@ -94,9 +94,6 @@ const web_master = bi_author || hexo_author <% } %> <% } %> <% if (bsz_enable === true) { %> -
<% if (bsz_site_uv) { %> diff --git a/scripts/helpers/export-config.js b/scripts/helpers/export-config.js index 04f866d5..b07c2fb5 100644 --- a/scripts/helpers/export-config.js +++ b/scripts/helpers/export-config.js @@ -39,13 +39,13 @@ hexo.extend.helper.register('exportConfig', function () { toc: theme.toc || {}, style: theme.style || {}, local_search: theme.local_search || {}, - code_copy: theme.code_copy || {}, code_block: theme.code_block || {}, side_tools: theme.side_tools || {}, pjax: theme.pjax || {}, lazyload: theme.lazyload || {}, comment: theme.comment || {}, post: theme.post || {}, + website_count: theme.website_count || {}, version: require('../../package.json').version } diff --git a/source/css/layout/_partial/footer.styl b/source/css/layout/_partial/footer.styl index 97703a4d..dd30dec1 100644 --- a/source/css/layout/_partial/footer.styl +++ b/source/css/layout/_partial/footer.styl @@ -1,4 +1,4 @@ -$shields-style-height = 22px +$shields-style-height = 1.4rem .footer { color var(--text-color-4) @@ -30,9 +30,9 @@ $shields-style-height = 22px color var(--text-color-4) &.website-count { + display none &.shields { - display flex justify-content flex-start @@ -48,7 +48,7 @@ $shields-style-height = 22px height 100% display flex align-items center - padding 0 7px + padding 0 6px } diff --git a/source/js/utils.js b/source/js/utils.js index b519ea49..3ea26a8c 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -427,6 +427,27 @@ KEEP.initUtils = () => { setTimeout(() => { init() }, 1000) + }, + + siteCountInitialize() { + if (KEEP.theme_config?.website_count?.busuanzi_count.enable === true) { + const script = document.createElement('script') + script.async = true + script.src = '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js' + document.body.appendChild(script) + const websiteCountBoxDom = document.querySelector('.footer .website-count') + script.onload = () => { + setTimeout(() => { + if ( + document.querySelector('#busuanzi_value_site_uv').innerText || + document.querySelector('#busuanzi_value_site_pv').innerText || + document.querySelector('#busuanzi_value_page_pv').innerText + ) { + websiteCountBoxDom.style.display = 'flex' + } + }, 1000) + } + } } } @@ -456,4 +477,7 @@ KEEP.initUtils = () => { // insert tooltip content dom KEEP.utils.insertTooltipContent() + + // busuanzi initialize + KEEP.utils.siteCountInitialize() } From 2bfacc0b828249cd46e0d308f7c6384d2312407b Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 27 Jul 2023 00:05:16 +0800 Subject: [PATCH 018/206] ui(footer): optimize shields style --- layout/_partial/footer.ejs | 30 +++++++++++--------------- source/css/layout/_partial/footer.styl | 22 +++++++++++++++---- source/js/utils.js | 6 +++--- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/layout/_partial/footer.ejs b/layout/_partial/footer.ejs index 073be4fb..6e0880fc 100644 --- a/layout/_partial/footer.ejs +++ b/layout/_partial/footer.ejs @@ -10,43 +10,39 @@ const { author: bi_author } = theme.base_info const { author: hexo_author } = config const { site_uv: bsz_site_uv, site_pv: bsz_site_pv, enable: bsz_enable } = theme.website_count.busuanzi_count const shields_style = 'flat-square' -const shields_color_list = ['blue', 'blue', 'blue', 'dodgerblue', 'dodgerblue', 'dodgerblue'] +const shields_color_list = ['dodgerblue', 'dodgerblue', 'dodgerblue', 'dodgerblue', 'dodgerblue', 'dodgerblue'] const web_master = bi_author || hexo_author %> -
-
+
+
<% if (f_style === 'shields') { %>
<% const since_date = f_since ? f_since + '_--_' + date(new Date(), 'YYYY') : date(new Date(), 'YYYY') %> - + + + <% if (web_master) { %> - + <% } %> <% if (f_icp) { %> - <% } %> -
-
- + - + <% if (f_site_deploy?.enable === true && f_site_deploy?.provider !== '') { %> - <% if (f_site_deploy?.url) { %> - - <% } %> - - <% if (f_site_deploy?.url) { %> - - <% } %> + + + <% } %>
<% } else { %> diff --git a/source/css/layout/_partial/footer.styl b/source/css/layout/_partial/footer.styl index dd30dec1..36ed3173 100644 --- a/source/css/layout/_partial/footer.styl +++ b/source/css/layout/_partial/footer.styl @@ -1,6 +1,7 @@ -$shields-style-height = 1.4rem +$shields-style-height = 22px .footer { + padding 1rem 0 color var(--text-color-4) font-size 1rem @@ -12,17 +13,31 @@ $shields-style-height = 1.4rem } } - .info-container { + .website-info-box { display flex flex-direction column align-items center justify-content center - padding-bottom 1rem &.shields { img { height $shields-style-height !important } + + a { + position: relative; + text-decoration: none; + display inline-flex + box-sizing border-box + } + + .shields-item { + margin 0 2px + + &.no-pointer { + pointer-events none + } + } } .info-item { @@ -35,7 +50,6 @@ $shields-style-height = 1.4rem &.shields { justify-content flex-start - .count-box { height $shields-style-height font-size 12.6px diff --git a/source/js/utils.js b/source/js/utils.js index 3ea26a8c..cfaf29bd 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -439,9 +439,9 @@ KEEP.initUtils = () => { script.onload = () => { setTimeout(() => { if ( - document.querySelector('#busuanzi_value_site_uv').innerText || - document.querySelector('#busuanzi_value_site_pv').innerText || - document.querySelector('#busuanzi_value_page_pv').innerText + document.querySelector('#busuanzi_value_site_uv')?.innerText || + document.querySelector('#busuanzi_value_site_pv')?.innerText || + document.querySelector('#busuanzi_value_page_pv')?.innerText ) { websiteCountBoxDom.style.display = 'flex' } From 69f6c58d1212b8de972b34663baa2fc1c060a20e Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 27 Jul 2023 11:12:21 +0800 Subject: [PATCH 019/206] feat(footer): add custom configuration shields --- _config.yml | 14 ++++++++++++++ layout/_partial/footer.ejs | 18 ++++++++++++++++-- source/css/layout/_partial/footer.styl | 20 ++++++++++++-------- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/_config.yml b/_config.yml index 6dbf80f2..8038d5cc 100644 --- a/_config.yml +++ b/_config.yml @@ -295,3 +295,17 @@ footer: enable: false # Option values: true | false provider: github # Option values: github | vercel | netlify | gitee | aliyun | tencent_cloud | upyun url: # Your deployment provider url, Can be null + + # When the footer style is shields, you can customize the shields configuration + # See: https://shields.io + custom_shields: + enable: true # Option values: true | false + data: + shields_1: + link_url: # Your link url, Can be null + img_url: # Shields image url + # For example + shields_2: + link_url: https://github.com/XPoet/hexo-theme-keep + img_url: https://img.shields.io/badge/Hexo-Keep%20v3.6.1-blue?style=flat-square&logo=hexo + # Can add more ... diff --git a/layout/_partial/footer.ejs b/layout/_partial/footer.ejs index 6e0880fc..8291c3a0 100644 --- a/layout/_partial/footer.ejs +++ b/layout/_partial/footer.ejs @@ -3,7 +3,7 @@ const { since: f_since, icp: f_icp, site_deploy: f_site_deploy, - shields: f_shields, + custom_shields: f_custom_shields, style: f_style } = theme.footer const { author: bi_author } = theme.base_info @@ -40,11 +40,25 @@ const web_master = bi_author || hexo_author <% if (f_site_deploy?.enable === true && f_site_deploy?.provider !== '') { %> - + <% } %>
+ <% if (f_custom_shields?.enable === true) { %> +
+ <% for (const i in f_custom_shields?.data) { %> + <% if (f_custom_shields?.data[i].img_url) { %> + + + + <% } %> + <% } %> +
+ <% } %> <% } else { %> - <% if (f_icp) { %> + <% if (f_icp?.enable && f_icp?.record_code) { %> <% } %> diff --git a/source/css/layout/_partial/footer.styl b/source/css/layout/_partial/footer.styl index a0fb5349..788eaaf8 100644 --- a/source/css/layout/_partial/footer.styl +++ b/source/css/layout/_partial/footer.styl @@ -11,6 +11,10 @@ $shields-style-height = 22px &:hover { color var(--primary-color) } + + &.no-pointer { + pointer-events none + } } .website-info-box { @@ -34,10 +38,6 @@ $shields-style-height = 22px .shields-item { margin 0 2px user-select none - - &.no-pointer { - pointer-events none - } } } From d1607af348b1ee4bc82ce93525e85facaf2aea94 Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 27 Jul 2023 14:08:31 +0800 Subject: [PATCH 021/206] perf(article-meta-info): optimize article pv show --- source/css/layout/_partial/article-meta-info.styl | 4 ++++ source/js/utils.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/css/layout/_partial/article-meta-info.styl b/source/css/layout/_partial/article-meta-info.styl index 31d4768b..a6608dac 100644 --- a/source/css/layout/_partial/article-meta-info.styl +++ b/source/css/layout/_partial/article-meta-info.styl @@ -8,6 +8,10 @@ &:last-child { margin-right 0 } + + &.article-pv { + display none + } } .article-date { diff --git a/source/js/utils.js b/source/js/utils.js index cfaf29bd..6cc4150d 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -435,7 +435,6 @@ KEEP.initUtils = () => { script.async = true script.src = '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js' document.body.appendChild(script) - const websiteCountBoxDom = document.querySelector('.footer .website-count') script.onload = () => { setTimeout(() => { if ( @@ -443,7 +442,8 @@ KEEP.initUtils = () => { document.querySelector('#busuanzi_value_site_pv')?.innerText || document.querySelector('#busuanzi_value_page_pv')?.innerText ) { - websiteCountBoxDom.style.display = 'flex' + document.querySelector('.footer .website-count').style.display = 'flex' + document.querySelector('.article-meta-info .article-pv').style.display = 'inline-block' } }, 1000) } From 89203bbe98ea749a9f54ecd57c3e0bbcd3f8939a Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 27 Jul 2023 17:19:00 +0800 Subject: [PATCH 022/206] feat: add giscus comments plugin (#201) --- _config.yml | 20 +++-- layout/_partial/comment/giscus.ejs | 120 +++++++++++++++-------------- source/js/utils.js | 6 +- 3 files changed, 74 insertions(+), 72 deletions(-) diff --git a/_config.yml b/_config.yml index eb25203f..8770db8c 100644 --- a/_config.yml +++ b/_config.yml @@ -214,7 +214,7 @@ local_search: # --------------------------------------------------------------------------------------- comment: enable: false # Option values: true | false - use: valine # Option values: valine | gitalk | twikoo | waline + use: valine # Option values: valine | gitalk | twikoo | waline | giscus # Valine # See: https://github.com/xCss/Valine @@ -253,17 +253,15 @@ comment: version: 2 # Waline version, default use v2 # Giscus - # See: https://giscus.app, in which you can finish your settings + # See: https://github.com/giscus/giscus + # https://giscus.app + # Please generate your configuration items in https://giscus.app giscus: - repo: # Open https://giscus.app/ to finish it and below. - repo_id: - category: - category_id: - position: top # Comments input position, Options values: top | bottom - lang: zh-CN # Language, Options see: https://github.com/giscus/giscus/tree/main/locales - reactions_enabled: true # Reactions - light_theme: light # Light theme, Options: light | light_high_contrast | light_protanopia | light_tritanopia - dark_theme: dark # Dark theme, Options: dark | dark_high_contrast | dark_protanopia | dark_tritanopia | dark_dimmed | transparent_dark + repo: + repo_id: + category: Announcements # Recommend use Announcements + category_id: + reactions_enabled: false # Option values: true | false # --------------------------------------------------------------------------------------- # RSS diff --git a/layout/_partial/comment/giscus.ejs b/layout/_partial/comment/giscus.ejs index a0f6f011..b57e4746 100644 --- a/layout/_partial/comment/giscus.ejs +++ b/layout/_partial/comment/giscus.ejs @@ -1,69 +1,71 @@ <% const { enable: pjax_enable } = theme?.pjax const { - repo, - repo_id, - category, - category_id, - position, - lang, - reactions_enabled, - dark_theme, - light_theme + repo: giscus_repo, + repo_id: giscus_repo_id, + category: giscus_category, + category_id: giscus_category_id, + reactions_enabled: giscus_reactions_enabled, } = theme.comment?.giscus -let cdn_js = 'https://giscus.app/client.js' +const giscus_language = config?.language || 'zh-CN' %> -<% if(repo && repo_id && category && category_id) { %> -
- + if ('<%= pjax_enable %>' === "true") { + setTimeout(() => { + loadGiscus(); + }, 1000); + } else { + window.addEventListener("DOMContentLoaded", () => { + setTimeout(() => { + loadGiscus(); + }, 1000); + }); + } + +
+<% } else { %> +
Please fill in Giscus complete configuration items.
<% } %> diff --git a/source/js/utils.js b/source/js/utils.js index 6cc4150d..ced78bb1 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -442,8 +442,10 @@ KEEP.initUtils = () => { document.querySelector('#busuanzi_value_site_pv')?.innerText || document.querySelector('#busuanzi_value_page_pv')?.innerText ) { - document.querySelector('.footer .website-count').style.display = 'flex' - document.querySelector('.article-meta-info .article-pv').style.display = 'inline-block' + const tmpDom1 = document.querySelector('.footer .website-count') + const tmpDom2 = document.querySelector('.article-meta-info .article-pv') + tmpDom1 && (tmpDom1.style.display = 'flex') + tmpDom2 && (tmpDom2.style.display = 'inline-block') } }, 1000) } From 4e10bdcb8d393b8377086325b2c502130f5a8cfb Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 27 Jul 2023 18:29:35 +0800 Subject: [PATCH 023/206] perf(post): optimize article header avatar setting --- _config.yml | 3 ++- layout/article-content.ejs | 25 ++++++++++++++----------- source/css/layout/article-content.styl | 22 +++++++--------------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/_config.yml b/_config.yml index 4f43ddae..d82df225 100644 --- a/_config.yml +++ b/_config.yml @@ -135,7 +135,8 @@ home_article: post: # Author avatar in the post author_avatar: - enable: true # Option values: true | false + enable: true # Option values: true | false + # Author label in the post author_label: enable: true # Option values: true | false diff --git a/layout/article-content.ejs b/layout/article-content.ejs index 5b277ef6..9abda2b5 100644 --- a/layout/article-content.ejs +++ b/layout/article-content.ejs @@ -7,13 +7,13 @@
<% if (theme.base_info.author || config.author) { %> -
- <% if (theme.hasOwnProperty('post') && theme.post.author_avatar.enable === true) { %> -
- <%- image_tag(theme.style.avatar) %> -
- <% } %> -
+
+ <% if (theme.hasOwnProperty('post') && theme.post?.author_avatar.enable === true) { %> +
+ <%- image_tag(theme.style.avatar) %> +
+ <% } %> +
<%= theme.base_info.author || config.author %> <% if (theme.hasOwnProperty('post') && theme.post.author_label.enable === true) { %> @@ -21,21 +21,24 @@ <% } %>
- <%- partial('_partial/article-meta-info', {articleObject: page, index: true}) %> + <%- partial('_partial/article-meta-info', { articleObject: page, index: true }) %>
<% } else { %>
- <%- partial('_partial/article-meta-info', {articleObject: page, index: true}) %> + <%- partial('_partial/article-meta-info', { articleObject: page, index: true }) %>
<% } %>
<% if (page?.aging === true) { %> -
+
<%- __('article-aging', '0') %>
<% } %> @@ -44,7 +47,7 @@
<% if ( - (theme.post?.copyright_info === true || theme?.copyright_info?.enable === true) && page?.copyright_info !== false + (theme.post?.copyright_info === true || theme?.copyright_info?.enable === true) && page?.copyright_info !== false ) { %>
<%- partial('_partial/article-copyright-info') %> diff --git a/source/css/layout/article-content.styl b/source/css/layout/article-content.styl index feab5f71..e4477e28 100644 --- a/source/css/layout/article-content.styl +++ b/source/css/layout/article-content.styl @@ -1,5 +1,4 @@ -$avatarWidth = (hexo-config('post.author_avatar.enable') == true) ? 3rem : 0 -$headerHeight = 3rem +$avatarWidth = 3rem $arrow-icon-width = 1rem $post-nav-max-width = 14rem $article-title-font-size = 1.6rem @@ -70,22 +69,18 @@ $toc-container-width = 15rem .article-header { - position relative - box-sizing border-box width 100% - height $headerHeight - padding-left $avatarWidth + display flex + justify-content flex-start - .avatar { - position absolute - top 0 - left 0 - box-sizing border-box + .avatar-box { width $avatarWidth height $avatarWidth + flex-shrink 0 padding 0.1rem border 1px solid var(--border-color) border-radius 50% + margin-right 0.8rem img { width 100% @@ -96,16 +91,13 @@ $toc-container-width = 15rem } - .info { + .info-box { display flex flex-direction column justify-content space-between box-sizing border-box width 100% height 100% - if (hexo-config('post.author_avatar.enable') == true) { - margin-left 0.8rem - } padding 0.2rem 0 .author { From 1036e27842727e0dc64a55a7fd0cc83f0e20a62a Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 27 Jul 2023 23:07:52 +0800 Subject: [PATCH 024/206] perf(footer): optimize total words settings --- _config.yml | 24 +++---- languages/en.yml | 2 + languages/zh-CN.yml | 2 + languages/zh-TW.yml | 2 + layout/_partial/footer.ejs | 60 ++++++++++------ source/css/layout/_partial/footer.styl | 98 +++++++++++++++++--------- source/css/layout/article-content.styl | 6 +- source/js/utils.js | 24 ++++--- 8 files changed, 137 insertions(+), 81 deletions(-) diff --git a/_config.yml b/_config.yml index 3c3119e1..7b27aea9 100644 --- a/_config.yml +++ b/_config.yml @@ -303,28 +303,28 @@ pjax: # Docs: https://keep-docs.xpoet.cn/tutorial/configuration-guide/footer.html # --------------------------------------------------------------------------------------- footer: - style: default # Option values: default | shields - since: 2020 # The starting year of your website, Can be null - word_count: false + style: default # Option values: default | shields + since: 2020 # The starting year of your website, Can be null + word_count: false # Option values: true | false icp: - enable: true # Option values: true | false - record_code: # ICP record code of your website - url: https://beian.miit.gov.cn # Your ICP link url, Can be null + enable: false # Option values: true | false + record_code: # ICP record code of your website + url: https://beian.miit.gov.cn # Your ICP link url, Can be null site_deploy: - enable: false # Option values: true | false - provider: github # Option values: github | vercel | netlify | gitee | aliyun | tencent_cloud | upyun - url: # Your deployment provider url, Can be null + enable: false # Option values: true | false + provider: github # Option values: github | vercel | netlify | gitee | aliyun | tencent_cloud | upyun + url: # Your deployment provider url, Can be null # When the footer style is shields, you can customize the shields configuration # See: https://shields.io custom_shields: - enable: true # Option values: true | false + enable: false # Option values: true | false data: shields_1: - link_url: # Your link url, Can be null - img_url: # Shields image url + link_url: # Your link url, Can be null + img_url: # Shields image url # For example shields_2: link_url: https://github.com/XPoet/hexo-theme-keep diff --git a/languages/en.yml b/languages/en.yml index 5449013e..126ea701 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -81,3 +81,5 @@ deploy_provider: aliyun: Alibaba Cloud tencent_cloud: Tencent Cloud upyun: UPYUN +footer: + total_words: Total words diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index ea08b1a6..ca6a2349 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -81,3 +81,5 @@ deploy_provider: aliyun: 阿里云 tencent_cloud: 腾讯云 upyun: 又拍云 +footer: + total_words: 全站总字数 diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index 0befba6c..34266ad8 100644 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -81,3 +81,5 @@ deploy_provider: aliyun: 阿裏雲 tencent_cloud: 騰訊雲 upyun: 又拍雲 +footer: + total_words: 全站總字數 diff --git a/layout/_partial/footer.ejs b/layout/_partial/footer.ejs index 9b0973a1..a14e724a 100644 --- a/layout/_partial/footer.ejs +++ b/layout/_partial/footer.ejs @@ -22,7 +22,7 @@ const web_master = bi_author || hexo_author <% if (web_master) { %> - + <% } %> @@ -41,8 +41,12 @@ const web_master = bi_author || hexo_author <% if (f_site_deploy?.enable === true && f_site_deploy?.provider !== '') { %> - - + + <% } %>
@@ -74,9 +78,7 @@ const web_master = bi_author || hexo_author
- <%- __('powered_by', 'Hexo') %> | <%- __('theme') %> -  Keep - v3.6.1 + <%- __('powered_by', 'Hexo') %> | <%- __('theme') %> Keep v3.6.1
<% if (f_icp?.enable && f_icp?.record_code) { %> @@ -105,21 +107,35 @@ const web_master = bi_author || hexo_author
<% } %> <% } %> - <% if (bsz_enable === true) { %> -
- <% if (bsz_site_uv) { %> - - <%- __('site_uv') %> - - <% } %> - <% if (bsz_site_pv) { %> - - <%- __('site_pv') %> - - - <% } %> -
- <% } %> + +
+ <% + let f_temp_total_word; + try { + f_temp_total_word = totalcount(site); + } catch (e) { + f_temp_total_word = 0; + } + if (theme.footer?.word_count === true && f_temp_total_word !== 0) { %> + + <%- __('footer.total_words') %> + <%= totalcount(site) %> + + <% } %> + + <% if (bsz_enable === true && bsz_site_uv === true) { %> + + <%- __('site_uv') %> + + + <% } %> + + <% if (bsz_enable === true && bsz_site_pv === true) { %> + + <%- __('site_pv') %> + + + <% } %> +
diff --git a/source/css/layout/_partial/footer.styl b/source/css/layout/_partial/footer.styl index 788eaaf8..796758cf 100644 --- a/source/css/layout/_partial/footer.styl +++ b/source/css/layout/_partial/footer.styl @@ -29,10 +29,10 @@ $shields-style-height = 22px } a { - position: relative; - text-decoration: none; + position relative display inline-flex box-sizing border-box + text-decoration none } .shields-item { @@ -46,55 +46,89 @@ $shields-style-height = 22px margin 0.2rem 0 color var(--text-color-4) - &.website-count { - display none + &.shields { + justify-content flex-start - &.shields { + .count-box { + display flex justify-content flex-start + height $shields-style-height + margin-right 8px + color #f2f2f2 + font-size 12.6px + - .count-box { - height $shields-style-height - font-size 12.6px + .item-type + .item-value { display flex - justify-content flex-start - color #f2f2f2 + align-items center + height 100% + padding 0 6px + } + + + .item-type { + margin-right 0 + background #555555 + } + .item-value { - .count-item { - height 100% - display flex - align-items center - padding 0 6px + &.uv { + background coral } + &.pv { + background orange + } - .item-type { - margin-right 0 - background: #555555 + &.word { + background indianred } + } + } + } + - .item-value { + &.default { + .count-box { + margin-right 15px - &.uv { - background: coral - } + &::before { + position absolute + top 50% + left -10px + box-sizing border-box + transform translateY(-55%) + content '|' + } - &.pv { - background: orange - } + &:first-child { + &::before { + display none } + } + .item-type { + margin-right 4px } } + } + + + &.count-item { + display flex - .uv { - &.has-pv { - margin-right 8px + .count-box { + + &:last-child { + margin-right 0 } - } - .item-type { - margin-right 4px + &.uv + &.pv { + display none + } } } @@ -113,8 +147,6 @@ $shields-style-height = 22px height 1.08rem margin 0 0.4rem } - - } } } diff --git a/source/css/layout/article-content.styl b/source/css/layout/article-content.styl index e4477e28..8d1f1c7e 100644 --- a/source/css/layout/article-content.styl +++ b/source/css/layout/article-content.styl @@ -69,18 +69,18 @@ $toc-container-width = 15rem .article-header { - width 100% display flex justify-content flex-start + width 100% .avatar-box { + flex-shrink 0 width $avatarWidth height $avatarWidth - flex-shrink 0 + margin-right 0.8rem padding 0.1rem border 1px solid var(--border-color) border-radius 50% - margin-right 0.8rem img { width 100% diff --git a/source/js/utils.js b/source/js/utils.js index ced78bb1..2bf5a607 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -436,17 +436,19 @@ KEEP.initUtils = () => { script.src = '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js' document.body.appendChild(script) script.onload = () => { - setTimeout(() => { - if ( - document.querySelector('#busuanzi_value_site_uv')?.innerText || - document.querySelector('#busuanzi_value_site_pv')?.innerText || - document.querySelector('#busuanzi_value_page_pv')?.innerText - ) { - const tmpDom1 = document.querySelector('.footer .website-count') - const tmpDom2 = document.querySelector('.article-meta-info .article-pv') - tmpDom1 && (tmpDom1.style.display = 'flex') - tmpDom2 && (tmpDom2.style.display = 'inline-block') - } + setTimeout(() => { + if ( + document.querySelector('#busuanzi_value_site_uv')?.innerText || + document.querySelector('#busuanzi_value_site_pv')?.innerText || + document.querySelector('#busuanzi_value_page_pv')?.innerText + ) { + const tmpDom1 = document.querySelector('.footer .count-item .uv') + const tmpDom2 = document.querySelector('.footer .count-item .pv') + const tmpDom3 = document.querySelector('.article-meta-info .article-pv') + tmpDom1 && (tmpDom1.style.display = 'flex') + tmpDom2 && (tmpDom2.style.display = 'flex') + tmpDom3 && (tmpDom3.style.display = 'inline-block') + } }, 1000) } } From 67c73b87780f872c4205c6fdc095aa3260cdb5b9 Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 27 Jul 2023 23:27:13 +0800 Subject: [PATCH 025/206] perf(languages): optimize i18n settings --- languages/en.yml | 24 ++++++++++++------------ languages/zh-CN.yml | 24 ++++++++++++------------ languages/zh-TW.yml | 24 ++++++++++++------------ layout/_partial/footer.ejs | 14 +++++++------- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/languages/en.yml b/languages/en.yml index 126ea701..c3ed6a8e 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -9,7 +9,6 @@ next_posts: Next posts page: Page %d recent_posts: Recent Posts share: Share -powered_by: "Powered by %s" theme: Theme rss_feed: RSS Feed category: Category @@ -23,8 +22,6 @@ home: Home archive: Archive archives: Archives about: About -site_uv: Visitor Count -site_pv: Totalview links: Links link: Link top: TOP @@ -72,14 +69,17 @@ ago: week: "%s weeks ago" month: "%s months ago" year: "%s years ago" -footer_deploy: "This site is provided with deployment services by %s" -deploy_provider: - github: GitHub Pages - vercel: Vercel - netlify: Netlify - gitee: Gitee Pages - aliyun: Alibaba Cloud - tencent_cloud: Tencent Cloud - upyun: UPYUN footer: + powered_by: "Powered by %s" + site_uv: Visitor count + site_pv: Totalview + footer_deploy: "This site is provided with deployment services by %s" + deploy_provider: + github: GitHub Pages + vercel: Vercel + netlify: Netlify + gitee: Gitee Pages + aliyun: Alibaba Cloud + tencent_cloud: Tencent Cloud + upyun: UPYUN total_words: Total words diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index ca6a2349..454dd91d 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -9,7 +9,6 @@ next_posts: 下一篇 page: 第 %d 页 recent_posts: 最新文章 share: 分享 -powered_by: "由 %s 驱动" theme: 主题 rss_feed: RSS Feed category: 分类 @@ -23,8 +22,6 @@ home: 首页 archive: 归档 archives: 归档 about: 关于 -site_uv: 访问人数 -site_pv: 总访问量 links: 友链 link: 友链 top: 顶置 @@ -72,14 +69,17 @@ ago: week: "%s 周前" month: "%s 个月前" year: "%s 年前" -footer_deploy: "本站由 %s 提供部署服务" -deploy_provider: - github: GitHub Pages - vercel: Vercel - netlify: Netlify - gitee: Gitee Pages - aliyun: 阿里云 - tencent_cloud: 腾讯云 - upyun: 又拍云 footer: + powered_by: "由 %s 驱动" + site_uv: 访问人数 + site_pv: 总访问量 + deploy: "本站由 %s 提供部署服务" + deploy_provider: + github: GitHub Pages + vercel: Vercel + netlify: Netlify + gitee: Gitee Pages + aliyun: 阿里云 + tencent_cloud: 腾讯云 + upyun: 又拍云 total_words: 全站总字数 diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index 34266ad8..6301d672 100644 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -9,7 +9,6 @@ next_posts: 下一篇 page: 第 %d 頁 recent_posts: 之前的文章 share: 分享 -powered_by: "%s 框架" theme: 主題 rss_feed: RSS 訂閱 category: 分類 @@ -23,8 +22,6 @@ home: 首頁 archive: 歸檔 archives: 歸檔 about: 關於 -site_uv: 讀者 -site_pv: 閱覽 links: 友鏈 link: 友鏈 top: 頂端 @@ -72,14 +69,17 @@ ago: week: "%s 周前" month: "%s 個月前" year: "%s 年前" -footer_deploy: "本站由 %s 提供部署服務" -deploy_provider: - github: GitHub Pages - vercel: Vercel - netlify: Netlify - gitee: Gitee Pages - aliyun: 阿裏雲 - tencent_cloud: 騰訊雲 - upyun: 又拍雲 footer: + powered_by: "%s 框架" + site_uv: 讀者 + site_pv: 閱覽 + deploy: "本站由 %s 提供部署服務" + deploy_provider: + github: GitHub Pages + vercel: Vercel + netlify: Netlify + gitee: Gitee Pages + aliyun: 阿裏雲 + tencent_cloud: 騰訊雲 + upyun: 又拍雲 total_words: 全站總字數 diff --git a/layout/_partial/footer.ejs b/layout/_partial/footer.ejs index a14e724a..47f041da 100644 --- a/layout/_partial/footer.ejs +++ b/layout/_partial/footer.ejs @@ -46,7 +46,7 @@ const web_master = bi_author || hexo_author rel="nofollow" href="<%= f_site_deploy?.url %>" > - + <% } %>