From 82f5a688344ee03b773a8ce03d9bbab5f5a2cfaa Mon Sep 17 00:00:00 2001 From: zkqiang Date: Thu, 6 Jul 2023 16:52:12 +0800 Subject: [PATCH 1/5] =?UTF-8?q?:bug:=20=E5=AD=97=E6=95=B0=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E9=80=82=E9=85=8D=E5=8A=A0=E5=AF=86=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#939?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/index.ejs | 2 +- scripts/helpers/wordcount.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/layout/index.ejs b/layout/index.ejs index 0fd8d115..ec2dd091 100644 --- a/layout/index.ejs +++ b/layout/index.ejs @@ -27,7 +27,7 @@ page.banner_mask_alpha = theme.index.banner_mask_alpha - <% var excerpt = post.description || post.excerpt || (theme.index.auto_excerpt.enable && post.content) %> + <% var excerpt = post.description || post.excerpt || (theme.index.auto_excerpt.enable && !post.encrypt && post.content) %>
<%- strip_html(excerpt).substring(0, 200).trim().replace(/\n/g, ' ') %> diff --git a/scripts/helpers/wordcount.js b/scripts/helpers/wordcount.js index 1d8acea6..47f4b4be 100644 --- a/scripts/helpers/wordcount.js +++ b/scripts/helpers/wordcount.js @@ -6,7 +6,8 @@ const { stripHTML } = require('hexo-util'); const getWordCount = (post) => { if (!post.wordcount) { - post.wordcount = stripHTML(post.content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length; + // post.origin is the original post content of hexo-blog-encrypt + post.wordcount = stripHTML(post.origin || post.content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length; } return post.wordcount; }; From 595c22a36f1299fa6804f4252bdb629fcb9265f7 Mon Sep 17 00:00:00 2001 From: hunsh Date: Sat, 12 Aug 2023 23:44:31 +0800 Subject: [PATCH 2/5] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E7=A9=BA=E7=99=BD=E6=91=98=E8=A6=81=E5=9C=A8=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E4=BB=8D=E7=84=B6=E5=8D=A0=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/css/_pages/_index/index.styl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/css/_pages/_index/index.styl b/source/css/_pages/_index/index.styl index 174791bc..c3d17cc1 100644 --- a/source/css/_pages/_index/index.styl +++ b/source/css/_pages/_index/index.styl @@ -41,7 +41,7 @@ .index-excerpt color var(--sec-text-color) - margin 0.5rem 0 0.5rem 0 + margin 0.5rem 0 height calc(1.4rem * 3) overflow hidden display flex @@ -73,3 +73,8 @@ .index-pin font-size 1.25rem + + .index-excerpt + height auto + max-height calc(1.4rem * 3) + margin 0.25rem 0 From d16197545679f4018919b3319ccd09da6717247e Mon Sep 17 00:00:00 2001 From: Asuka Date: Fri, 21 Jul 2023 18:27:03 +0800 Subject: [PATCH 3/5] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=20giscus=20?= =?UTF-8?q?=E6=9A=97=E8=89=B2=E6=A8=A1=E5=BC=8F=E5=87=BA=E7=8E=B0=E7=99=BD?= =?UTF-8?q?=E8=89=B2=E8=83=8C=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/js/color-schema.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/js/color-schema.js b/source/js/color-schema.js index 93924ca8..5b1b75c2 100644 --- a/source/js/color-schema.js +++ b/source/js/color-schema.js @@ -11,6 +11,7 @@ var defaultColorSchemaAttributeName = 'data-default-color-scheme'; var colorToggleButtonSelector = '#color-toggle-btn'; var colorToggleIconSelector = '#color-toggle-icon'; + var iframeSelector = 'iframe'; function setLS(k, v) { try { @@ -247,6 +248,7 @@ theme: giscusTheme, } }; + giscus.style.cssText += 'color-scheme: normal;'; giscus.contentWindow.postMessage({ 'giscus': message }, 'https://giscus.app'); } } @@ -276,4 +278,9 @@ } } }); + + Fluid.utils.waitElementLoaded(iframeSelector, function() { + applyCustomColorSchemaSettings(); + }); + })(window, document); From d6831010eb5f278069e0f17f00ed314f7576d8f1 Mon Sep 17 00:00:00 2001 From: TimonPeng Date: Wed, 20 Sep 2023 13:17:57 +0800 Subject: [PATCH 4/5] =?UTF-8?q?:zap:=20=E6=A0=B9=E6=8D=AE=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E8=AF=AD=E8=A8=80=E7=BB=9F=E8=AE=A1=E5=AD=97=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/wordcount.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/helpers/wordcount.js b/scripts/helpers/wordcount.js index 47f4b4be..b4230947 100644 --- a/scripts/helpers/wordcount.js +++ b/scripts/helpers/wordcount.js @@ -5,9 +5,16 @@ const { stripHTML } = require('hexo-util'); const getWordCount = (post) => { + const lang = post.lang.toLowerCase(); + // post.origin is the original post content of hexo-blog-encrypt + const content = stripHTML(post.origin || post.content).replace(/\r?\n|\r/g, '').replace(/\s+/g, ''); + if (!post.wordcount) { - // post.origin is the original post content of hexo-blog-encrypt - post.wordcount = stripHTML(post.origin || post.content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length; + if (['zh-cn', 'zh-hk', 'zh-tw'].includes(lang)) { + post.wordcount = (content.match(/[\u4E00-\u9FA5]/g) || []).length; + } else { + post.wordcount = (content.replace(/[\u4E00-\u9FA5]/g, '').match(/[a-zA-Z0-9_\u0392-\u03c9\u0400-\u04FF]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|[\u00E4\u00C4\u00E5\u00C5\u00F6\u00D6]+|\w+/g) || []).length; + } } return post.wordcount; }; From 9164884db997f7a6c10e8dcf41ba88e21dfa3dea Mon Sep 17 00:00:00 2001 From: AimTao Date: Sun, 6 Aug 2023 18:16:02 +0800 Subject: [PATCH 5/5] =?UTF-8?q?:sparkles:=20=E5=A2=9E=E5=8A=A0=E6=8A=98?= =?UTF-8?q?=E5=8F=A0=E5=9D=97=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/utils.js | 4 +- scripts/tags/fold.js | 20 +++++++++ scripts/utils/crypto.js | 9 ++++ source/css/_pages/_base/color-schema.styl | 4 ++ source/css/_pages/_post/post-tag.styl | 50 +++++++++++++++++++++++ 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 scripts/tags/fold.js create mode 100644 scripts/utils/crypto.js diff --git a/scripts/helpers/utils.js b/scripts/helpers/utils.js index aed604c1..7581d62e 100644 --- a/scripts/helpers/utils.js +++ b/scripts/helpers/utils.js @@ -2,12 +2,12 @@ 'use strict'; -const crypto = require('crypto'); +const md5 = require('../utils/crypto'); const { decodeURL } = require('hexo-util'); const compareVersions = require('../../scripts/utils/compare-versions'); hexo.extend.helper.register('md5', function(string) { - return crypto.createHash('md5').update(string).digest('hex'); + return md5(string); }); hexo.extend.helper.register('require_version', function(current, require) { diff --git a/scripts/tags/fold.js b/scripts/tags/fold.js new file mode 100644 index 00000000..bbddbf8f --- /dev/null +++ b/scripts/tags/fold.js @@ -0,0 +1,20 @@ +const md5 = require('../utils/crypto'); + +hexo.extend.tag.register('fold', (args, content) => { + args = args.join(' ').split('@'); + const classes = args[0] || 'default'; + const text = args[1] || ''; + const id = 'collapse-' + md5(content).slice(0, 8); + + return ` +
+ +
+ ${hexo.render.renderSync({ text: content, engine: 'markdown' }).split('\n').join('')} +
+
`; +}, { + ends: true +}); diff --git a/scripts/utils/crypto.js b/scripts/utils/crypto.js new file mode 100644 index 00000000..9f1007a0 --- /dev/null +++ b/scripts/utils/crypto.js @@ -0,0 +1,9 @@ +'use strict'; + +const crypto = require('crypto'); + +const md5 = (content) => { + return crypto.createHash('md5').update(content).digest('hex'); +} + +module.exports = md5; diff --git a/source/css/_pages/_base/color-schema.styl b/source/css/_pages/_base/color-schema.styl index 0d3ec1f9..b4bf8c44 100644 --- a/source/css/_pages/_base/color-schema.styl +++ b/source/css/_pages/_base/color-schema.styl @@ -19,6 +19,8 @@ --button-hover-bg-color $button-hover-bg-color --highlight-bg-color $highlight-bg-color --inlinecode-bg-color $inlinecode-bg-color + --fold-title-color $text-color + --fold-border-color $line-color dark-colors() --body-bg-color $body-bg-color-dark @@ -40,6 +42,8 @@ dark-colors() --button-hover-bg-color $button-hover-bg-color-dark --highlight-bg-color $highlight-bg-color-dark --inlinecode-bg-color $inlinecode-bg-color-dark + --fold-title-color $text-color + --fold-border-color $line-color img -webkit-filter brightness(.9) diff --git a/source/css/_pages/_post/post-tag.styl b/source/css/_pages/_post/post-tag.styl index e06819d9..5be46992 100644 --- a/source/css/_pages/_post/post-tag.styl +++ b/source/css/_pages/_post/post-tag.styl @@ -1,3 +1,53 @@ +// fold +.fold + margin 1rem 0 + border 0.5px solid var(--fold-border-color) + position relative + clear both + border-radius 0.125rem + + .fold-title + color var(--fold-title-color) + padding 0.5rem 0.75rem + font-size 0.9rem + font-weight bold + border-radius 0.125rem + + &:not(.collapsed) > .fold-arrow + transform rotate(90deg) + transform-origin center center + + .fold-arrow + display inline-block + margin-right 0.35rem + transition transform .3s ease-out + + .fold-content + & > * + margin 0 + + & > p + padding 1rem 1rem + +.fold-default + background rgba(#bbbbbb, 0.25) + +.fold-primary + background rgba(#b7a0e0, 0.25) + +.fold-info + background rgba(#a0c5e4, 0.25) + +.fold-success + background rgba(#aedcae, 0.25) + +.fold-warning + background rgba(#f8d6a6, 0.25) + +.fold-danger + background rgba(#eca9a7, 0.25) + + // note .note padding 0.75rem