Skip to content

Commit

Permalink
fix: don't initialise pagefind ui twice
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed May 24, 2024
1 parent 6e48d0c commit 7c7cb42
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/search.astro
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ const { t } = await createI18n(Astro.currentLocale as Locale | undefined);
const closeButton = this.querySelector<HTMLButtonElement>("button[data-search-close]");
const dialog = this.querySelector<HTMLDialogElement>("dialog");
const dialogContent = this.querySelector<HTMLDivElement>("div[data-dialog-content]");
const dialogSearchResults = this.querySelector<HTMLDivElement>("div[data-search-results]");
assert(openButton);
assert(closeButton);
assert(dialog);
assert(dialogContent);
assert(dialogSearchResults);

function closeDialog() {
dialog?.close();
Expand Down Expand Up @@ -89,7 +91,7 @@ const { t } = await createI18n(Astro.currentLocale as Locale | undefined);
// @ts-expect-error — Missing types for @pagefind/default-ui package.
const { PagefindUI } = await import("@pagefind/default-ui");
new PagefindUI({
element: "[data-search-results]",
element: dialogSearchResults,
baseUrl: import.meta.env.BASE_URL,
bundlePath: import.meta.env.BASE_URL.replace(/\/$/, "") + "/pagefind/",
showImages: false,
Expand Down

0 comments on commit 7c7cb42

Please sign in to comment.