mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-15 23:16:48 +00:00
Hexo 主题搜索调整
This commit is contained in:
@@ -4,6 +4,11 @@ import BLOG from '@/blog.config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { getDataFromCache } from '@/lib/cache/cache_manager'
|
||||
|
||||
/**
|
||||
* 服务端搜索
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
export async function getServerSideProps ({ params: { keyword } }) {
|
||||
const {
|
||||
allPosts,
|
||||
|
||||
@@ -4,6 +4,9 @@ import BLOG from '@/blog.config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
/**
|
||||
* 浏览器前端搜索
|
||||
*/
|
||||
export async function getStaticProps () {
|
||||
const {
|
||||
allPosts,
|
||||
|
||||
@@ -1,9 +1,26 @@
|
||||
|
||||
import { useRouter } from 'next/router'
|
||||
import { useEffect } from 'react'
|
||||
import BlogPostListPage from './components/BlogPostListPage'
|
||||
import LayoutBase from './LayoutBase'
|
||||
|
||||
export const LayoutSearch = (props) => {
|
||||
return <LayoutBase {...props}>
|
||||
<BlogPostListPage {...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}>
|
||||
<div ic='container'>
|
||||
<BlogPostListPage {...props}/>
|
||||
</div>
|
||||
</LayoutBase>
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function SideRight (props) {
|
||||
</Card>
|
||||
<Card>
|
||||
<MenuButtonGroup {...props}/>
|
||||
<SearchInput />
|
||||
<SearchInput {...props}/>
|
||||
</Card>
|
||||
<Card>
|
||||
<div className='ml-2 mb-3 font-sans'>
|
||||
|
||||
Reference in New Issue
Block a user