diff --git a/snapshots.yml b/snapshots.yml index 15f309f..facb230 100644 --- a/snapshots.yml +++ b/snapshots.yml @@ -8,3 +8,8 @@ url: /posts/dont-use-aws-ses/ - name: Tag page url: /tags/aws +- name: Search page + url: /search/ +- name: Search results + url: /search/?q=aws + wait_for_selector: "pagefind-results a" diff --git a/src/components/Header/index.js b/src/components/Header/index.js index b0e0604..8d9b601 100644 --- a/src/components/Header/index.js +++ b/src/components/Header/index.js @@ -5,6 +5,7 @@ import Background from "./header.jpg"; const Header = () => (
{ script.onload = () => { // Insert the web components after the script loads containerRef.current.innerHTML = ` - + `; + + // Check for a ?q= query parameter and pre-fill the search + const params = new URLSearchParams(window.location.search); + const query = params.get("q"); + if (query) { + // Wait for the web component to render its internal input + setTimeout(() => { + const input = containerRef.current.querySelector("pagefind-input input"); + if (input) { + input.value = query; + input.dispatchEvent(new Event("input", { bubbles: true })); + } + }, 100); + } }; document.head.appendChild(script); diff --git a/src/templates/blog-post.js b/src/templates/blog-post.js index 8c8abd0..894848c 100644 --- a/src/templates/blog-post.js +++ b/src/templates/blog-post.js @@ -26,8 +26,8 @@ class BlogPost extends Component { return ( -
-

{title}

+
+

{title}