File tree Expand file tree Collapse file tree 1 file changed +19
-11
lines changed
Expand file tree Collapse file tree 1 file changed +19
-11
lines changed Original file line number Diff line number Diff line change 33import { useEffect } from "react" ;
44import { getBasePath } from "@/lib/utils" ;
55
6+ interface PagefindUIOptions {
7+ element : HTMLElement ;
8+ showSubResults : boolean ;
9+ showImages : boolean ;
10+ excerptLength : number ;
11+ placeholder : string ;
12+ basePath ?: string ;
13+ }
14+
615declare global {
716 interface Window {
8- PagefindUI ?: new ( options : {
9- element : HTMLElement ;
10- showSubResults : boolean ;
11- showImages : boolean ;
12- excerptLength : number ;
13- placeholder : string ;
14- basePath ?: string ;
15- } ) => void ;
17+ PagefindUI ?: new ( options : PagefindUIOptions ) => void ;
1618 }
1719}
1820
@@ -38,14 +40,20 @@ export default function SearchBar() {
3840 if ( window . PagefindUI ) {
3941 clearInterval ( checkPagefind ) ;
4042 loadPagefindCSS ( ) ;
41- new window . PagefindUI ( {
43+ const config : PagefindUIOptions = {
4244 element : heroSearchContainer ,
4345 showSubResults : true ,
4446 showImages : false ,
4547 excerptLength : 15 ,
4648 placeholder : "Search implementations..." ,
47- basePath : basePath || undefined ,
48- } ) ;
49+ } ;
50+
51+ // Only add basePath if it's not empty
52+ if ( basePath ) {
53+ config . basePath = basePath ;
54+ }
55+
56+ new window . PagefindUI ( config ) ;
4957 }
5058 } , 100 ) ;
5159
You can’t perform that action at this time.
0 commit comments