diff --git a/README.md b/README.md index 1935139..9ef5ee1 100644 --- a/README.md +++ b/README.md @@ -66,4 +66,4 @@ const q = Astro.url.searchParams.get("q") ?? undefined; ``` -See [search.astro](./src/pages/search.astro) for a full example. +See [prefilled.astro](./src/pages/prefilled.astro) for a full example. diff --git a/packages/example/src/pages/index.md b/packages/example/src/pages/index.md index bfaeec1..12553b7 100644 --- a/packages/example/src/pages/index.md +++ b/packages/example/src/pages/index.md @@ -6,4 +6,4 @@ layout: ~/layouts/Main.astro [Astro](https://astro.build) integration for [Pagefind](https://pagefind.app/) static site search. -Example of [Pre-filled Search](search?q=page). +Example of [Pre-filled Search](prefilled). diff --git a/packages/example/src/pages/search.astro b/packages/example/src/pages/prefilled.astro similarity index 50% rename from packages/example/src/pages/search.astro rename to packages/example/src/pages/prefilled.astro index 4b55b91..8ab56ba 100644 --- a/packages/example/src/pages/search.astro +++ b/packages/example/src/pages/prefilled.astro @@ -1,9 +1,15 @@ --- -import SearchComponent from "astro-pagefind/components/Search"; +import Search from "astro-pagefind/components/Search"; -export const prerender = false; - -const q = Astro.url.searchParams.get("q") ?? undefined; +/** + * In SSR mode use this instead: + * + * ```ts + * export const prerender = false; + * const q = Astro.url.searchParams.get("q") ?? undefined; + * ``` + */ +const q = "astro"; --- @@ -16,6 +22,6 @@ const q = Astro.url.searchParams.get("q") ?? undefined;

Pre-filled Search

Searching for: {q}

- +