搜索效果微调

This commit is contained in:
tangly1024
2022-04-13 15:20:24 +08:00
parent 11ff500763
commit 15ef58a854
2 changed files with 2 additions and 4 deletions

View File

@@ -13,14 +13,13 @@ export const LayoutSearch = props => {
const { locale } = useGlobal()
const router = useRouter()
const currentSearch = keyword || router?.query?.s
let handleTextColor = false
const cRef = useRef(null)
useEffect(() => {
setTimeout(() => {
// 自动聚焦到搜索框
cRef?.current?.focus()
if (currentSearch && !handleTextColor) {
if (currentSearch) {
const targets = document.getElementsByClassName('replace')
for (const container of targets) {
if (container && container.innerHTML) {
@@ -29,7 +28,6 @@ export const LayoutSearch = props => {
re,
`<span class='text-red-500 border-b border-dashed'>${currentSearch}</span>`
)
handleTextColor = true
}
}
}

View File

@@ -78,7 +78,7 @@ const BlogPostCard = ({ post, showSummary }) => {
</div>
</div>
{CONFIG_HEXO.POST_LIST_COVER && !showPreview && post?.page_cover && (
{CONFIG_HEXO.POST_LIST_COVER && !showPreview && post?.page_cover && !post.results && (
<Link href={`${BLOG.SUB_PATH}/article/${post.slug}`} passHref>
<div className="flex w-full relative duration-200 rounded-t-xl lg:rounded-r-xl lg:rounded-t-none cursor-pointer transform overflow-hidden">
{/* eslint-disable-next-line @next/next/no-img-element */}