File tree Expand file tree Collapse file tree 4 files changed +25
-13
lines changed
docs/components/Docsearch Expand file tree Collapse file tree 4 files changed +25
-13
lines changed Original file line number Diff line number Diff line change 1
- import { Highlight } from "react-instantsearch"
1
+ import { Highlight , useInstantSearch } from "react-instantsearch"
2
2
import Link from "next/link"
3
3
4
4
export default function Hit ( { hit } ) {
5
+ const { setIndexUiState } = useInstantSearch ( )
5
6
const hierarchy = Object . values ( hit . hierarchy ) ?. filter ( Boolean )
6
7
const path = new URL ( hit . url_without_anchor ) . pathname
7
8
9
+ const onClick = ( ) => {
10
+ setIndexUiState ( ( prevIndexUiState ) => ( {
11
+ ...prevIndexUiState ,
12
+ query : "" ,
13
+ } ) )
14
+ }
15
+
8
16
return (
9
17
< Link
10
18
key = { hit . objectID }
11
19
href = { hit . url }
20
+ onClick = { onClick }
12
21
className = "flex flex-col gap-2 p-4 px-2 rounded-md text-neutral-800 group dark:text-neutral-100 hover:dark:bg-neutral-900 hover:bg-neutral-200"
13
22
>
14
23
< h3 className = "flex items-center text-sm font-semibold after:content-[''] whitespace-nowrap after:absolute after:bg-gradient-to-r after:h-6 after:right-0 after:w-12 after:from-transparent after:to-neutral-100 after:dark:to-neutral-800 relative overflow-hidden group-hover:dark:after:to-neutral-900 group-hover:after:to-neutral-200" >
Original file line number Diff line number Diff line change 1
1
import dynamic from "next/dynamic"
2
2
3
- const DocSearch = dynamic ( ( ) => import ( "./search" ) . then ( ( mod ) => mod . default ) , {
4
- ssr : false ,
5
- loading : ( ) => (
6
- < div className = "relative max-md:ml-6 h-8 appearance-none rounded-lg px-3 py-1.5 transition-colors text-base leading-tight md:text-sm bg-black/[.05] dark:bg-gray-50/10 focus:!bg-transparent pr-2 w-48 text-gray-500 dark:text-gray-400" >
7
- Search...
8
- < kbd className = "flex absolute top-0 right-0 gap-1 items-center px-1.5 my-1.5 h-5 font-mono font-medium text-gray-500 bg-white rounded border transition-opacity pointer-events-none select-none ltr:right-1.5 rtl:left-1.5 text-[10px] contrast-more:border-current contrast-more:text-current contrast-more:dark:border-current max-sm:hidden dark:border-gray-100/20 dark:bg-black/50" >
9
- CTRL K
10
- </ kbd >
11
- </ div >
12
- ) ,
13
- } )
3
+ const DocSearch = dynamic (
4
+ ( ) => import ( "./wrapper" ) . then ( ( mod ) => mod . default ) ,
5
+ {
6
+ ssr : false ,
7
+ loading : ( ) => (
8
+ < div className = "relative max-md:ml-6 h-8 appearance-none rounded-lg px-3 py-1.5 transition-colors text-base leading-tight md:text-sm bg-black/[.05] dark:bg-gray-50/10 focus:!bg-transparent pr-2 w-48 text-gray-500 dark:text-gray-400" >
9
+ Search...
10
+ < kbd className = "flex absolute top-0 right-0 gap-1 items-center px-1.5 my-1.5 h-5 font-mono font-medium text-gray-500 bg-white rounded border transition-opacity pointer-events-none select-none ltr:right-1.5 rtl:left-1.5 text-[10px] contrast-more:border-current contrast-more:text-current contrast-more:dark:border-current max-sm:hidden dark:border-gray-100/20 dark:bg-black/50" >
11
+ CTRL K
12
+ </ kbd >
13
+ </ div >
14
+ ) ,
15
+ }
16
+ )
14
17
15
18
export default DocSearch
File renamed without changes.
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { useEffect } from "react"
2
2
import algoliasearch from "algoliasearch/lite"
3
3
import { Hits , useInstantSearch } from "react-instantsearch"
4
4
import { InstantSearchNext } from "react-instantsearch-nextjs"
5
- import { CustomSearchBox } from "./searchbox "
5
+ import { CustomSearchBox } from "./searchInput "
6
6
import Hit from "./hit"
7
7
8
8
const algoliaClient = algoliasearch (
You can’t perform that action at this time.
0 commit comments