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 => {}) }