fukasawa 搜索调整

This commit is contained in:
tangly1024
2022-03-03 12:36:11 +08:00
parent 10ede27671
commit 5711d85f0a
2 changed files with 17 additions and 2 deletions

View File

@@ -1,8 +1,23 @@
import LayoutBase from './LayoutBase'
import BlogListPage from './components/BlogListPage'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
export const LayoutSearch = (props) => {
return <LayoutBase {...props}>
const { keyword } = props
const router = useRouter()
const currentSearch = keyword || router?.query?.s
useEffect(() => {
setTimeout(() => {
const container = document.getElementById('container')
if (container && container.innerHTML) {
const re = new RegExp(`${currentSearch}`, 'gim')
container.innerHTML = container.innerHTML.replace(re, `<span class='text-red-500 border-b border-dashed'>${currentSearch}</span>`)
}
},
100)
})
return <LayoutBase {...props} currentSearch={currentSearch}>
<BlogListPage {...props}/>
</LayoutBase>
}

View File

@@ -19,7 +19,7 @@ function AsideLeft (props) {
<section className='flex flex-col text-gray-600'>
<hr className='w-12 my-8' />
<SearchInput/>
<SearchInput {...props}/>
</section>
<section className='flex flex-col'>