Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting options before initialising the Pagefind search JS #400

Merged
merged 2 commits into from
Sep 1, 2023

Conversation

bglw
Copy link
Contributor

@bglw bglw commented Sep 1, 2023

Addresses #129

Adds a new step to the flow of initializing Pagefind via the JavaScript API:

const pagefind = await import("/pagefind/pagefind.js");
await pagefind.options({ /* . . . */ });
await pagefind.init(); // <------ 🆕 and optional
await pagefind.search( /* . . . */ );

Previously the import itself would init and start loading assets, which meant the options() call could not affect this by changing the basePath or language.

Now, Pagefind will initialize when init() is called, or when any call to search or filters is made. As such, this change won't break any existing implementations, but may delay the loading of Pagefind until a search is made.

@bglw bglw merged commit 0fb38b8 into main Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant