Skip to content

Commit

Permalink
chore: fix prefilled example
Browse files Browse the repository at this point in the history
  • Loading branch information
shishkin committed Sep 14, 2023
1 parent 40857b7 commit 56594c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ const q = Astro.url.searchParams.get("q") ?? undefined;
<Search query={q} />
```

See [search.astro](./src/pages/search.astro) for a full example.
See [prefilled.astro](./src/pages/prefilled.astro) for a full example.
2 changes: 1 addition & 1 deletion packages/example/src/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Original file line number Diff line number Diff line change
@@ -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";
---

<!doctype html>
Expand All @@ -16,6 +22,6 @@ const q = Astro.url.searchParams.get("q") ?? undefined;
<body>
<h1>Pre-filled Search</h1>
<p>Searching for: {q}</p>
<SearchComponent id="search" query={q} />
<Search id="search" query={q} />
</body>
</html>

0 comments on commit 56594c2

Please sign in to comment.