Skip to content
Discussion options

You must be logged in to vote

The Component UI can do this through its shared instance API; you do not need to render a filter control. Set the filter once on the same instance used by the searchbox.

With the generated script bundle:

<script src="/pagefind/pagefind-component-ui.js" type="module"></script>

<pagefind-searchbox instance="blog"></pagefind-searchbox>

<script type="module">
  await customElements.whenDefined("pagefind-searchbox");

  const manager = window.PagefindComponents.getInstanceManager();
  const instance = manager.getInstance("blog");

  // All later searches from the `blog` searchbox retain this filter.
  instance.triggerFilters({ type: ["blog"] });
</script>

With the npm package, the equivalent…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sceee
Comment options

Answer selected by sceee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants