1.5.0 • Published 2 months ago

astro-pagefind v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Astro-Pagefind

CI npm

Astro integration for Pagefind static site search.

Features

  • Build pagefind index upon static build
  • Serve previously prebuilt search index in astro dev mode
  • Search Astro component
  • Supports customized base URL path
  • Supports multiple instances of the component on a page
  • Supports pre-filled search query

Usage

Install:

npm i astro-pagefind

Add integration to the Astro config:

//astro.config.ts

import { defineConfig } from "astro/config";
import pagefind from "astro-pagefind";

export default defineConfig({
  build: {
    format: "file",
  },
  integrations: [pagefind()],
});

Add search component on a page:

---
import Search from "astro-pagefind/components/Search";
---

<Search />

See Main.layout for a usage example.

Pre-filled Search Query

In SSR mode Astro provides access to URL query parameters which can be used to pre-fill search query via a prop:

---
import Search from "astro-pagefind/components/Search";

export const prerender = false;

const q = Astro.url.searchParams.get("q") ?? undefined;
---

<Search query={q} />

See search.astro for a full example.

1.5.0

2 months ago

1.4.0

4 months ago

1.2.4

8 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.3.0

7 months ago

1.2.1

11 months ago

1.2.0

11 months ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago