Skip to content

Commit 47d94ab

Browse files
committed
Fix search index path
1 parent 75b4375 commit 47d94ab

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

catalog/components/search-bar.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
import { useEffect } from "react";
44
import { 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+
615
declare 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

0 commit comments

Comments
 (0)