From e4f31cc860daa0d2e1ad41e8b3e34c1f493030e8 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 17 Mar 2022 14:58:34 +0800 Subject: [PATCH] =?UTF-8?q?hexo=20=E6=90=9C=E7=B4=A2=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=A0=87=E7=BA=A2=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/LayoutSearch.js | 16 +++++++++------- themes/hexo/components/BlogPostCard.js | 6 +++--- themes/hexo/components/BlogPostListPage.js | 3 ++- themes/hexo/components/SearchInput.js | 5 ++++- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/themes/hexo/LayoutSearch.js b/themes/hexo/LayoutSearch.js index b4dab8a2..0d4a7c64 100644 --- a/themes/hexo/LayoutSearch.js +++ b/themes/hexo/LayoutSearch.js @@ -21,14 +21,16 @@ export const LayoutSearch = props => { // 自动聚焦到搜索框 cRef.current.focus() if (currentSearch && !handleTextColor) { - const container = document.getElementById('container') - if (container && container.innerHTML) { - const re = new RegExp(`${currentSearch}`, 'gim') - container.innerHTML = container.innerHTML.replace( - re, + const targets = document.getElementsByClassName('replace') + for (const container of targets) { + if (container && container.innerHTML) { + const re = new RegExp(`${currentSearch}`, 'gim') + container.innerHTML = container.innerHTML.replace( + re, `${currentSearch}` - ) - handleTextColor = true + ) + handleTextColor = true + } } } }, 100) diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js index 1937a355..1e60f68a 100644 --- a/themes/hexo/components/BlogPostCard.js +++ b/themes/hexo/components/BlogPostCard.js @@ -10,11 +10,11 @@ const BlogPostCard = ({ post, showSummary }) => { const showPreview = CONFIG_HEXO.POST_LIST_PREVIEW && post.blockMap return (
-
+
- + {post.title} @@ -27,7 +27,7 @@ const BlogPostCard = ({ post, showSummary }) => {
- {(!showPreview || showSummary) &&

+ {(!showPreview || showSummary) &&

{post.summary}

} diff --git a/themes/hexo/components/BlogPostListPage.js b/themes/hexo/components/BlogPostListPage.js index a9ba1289..038bb322 100644 --- a/themes/hexo/components/BlogPostListPage.js +++ b/themes/hexo/components/BlogPostListPage.js @@ -13,6 +13,7 @@ import BlogPostListEmpty from './BlogPostListEmpty' */ const BlogPostListPage = ({ page = 1, posts = [], postCount }) => { const totalPage = Math.ceil(postCount / BLOG.POSTS_PER_PAGE) + const showPagination = posts.length === BLOG.POSTS_PER_PAGE if (!posts || posts.length === 0) { return @@ -25,7 +26,7 @@ const BlogPostListPage = ({ page = 1, posts = [], postCount }) => { ))}
- + {showPagination && }
) } diff --git a/themes/hexo/components/SearchInput.js b/themes/hexo/components/SearchInput.js index 0f29a3a7..fefca73a 100644 --- a/themes/hexo/components/SearchInput.js +++ b/themes/hexo/components/SearchInput.js @@ -21,7 +21,10 @@ const SearchInput = props => { const key = searchInputRef.current.value if (key && key !== '') { setLoadingState(true) - location.href = '/search/' + key + router.push({ pathname: '/search/' + key }).then(r => { + setLoadingState(false) + }) + // location.href = '/search/' + key } else { router.push({ pathname: '/' }).then(r => {}) }