diff --git a/themes/hexo/LayoutSearch.js b/themes/hexo/LayoutSearch.js
index 22abf034..b4dab8a2 100644
--- a/themes/hexo/LayoutSearch.js
+++ b/themes/hexo/LayoutSearch.js
@@ -1,34 +1,89 @@
-
import { useRouter } from 'next/router'
-import { useEffect } from 'react'
+import { useEffect, useRef } from 'react'
import BlogPostListPage from './components/BlogPostListPage'
import LayoutBase from './LayoutBase'
import SearchInput from './components/SearchInput'
-export const LayoutSearch = (props) => {
- const { keyword } = props
+import { useGlobal } from '@/lib/global'
+import TagItemMini from './components/TagItemMini'
+import Card from './components/Card'
+import Link from 'next/link'
+
+export const LayoutSearch = props => {
+ const { keyword, tags, categories } = 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) {
const container = document.getElementById('container')
if (container && container.innerHTML) {
const re = new RegExp(`${currentSearch}`, 'gim')
- container.innerHTML = container.innerHTML.replace(re, `${currentSearch}`)
+ container.innerHTML = container.innerHTML.replace(
+ re,
+ `${currentSearch}`
+ )
handleTextColor = true
}
}
- },
- 100)
+ }, 100)
})
- return