From 1adbcec56fb2f7f09c7ad7f0924e247893590da4 Mon Sep 17 00:00:00 2001 From: Pontus Horn Date: Fri, 14 Jun 2019 23:08:36 +0200 Subject: [PATCH] Clarify search form example Addresses #6, which highlights some confusion about the example search form. This updates it to use the `link` filter used in Pico templates to render URLs appropriate for the value of the `rewrite_url` config variable. --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index aa6599f..d7a3eec 100644 --- a/README.md +++ b/README.md @@ -61,11 +61,11 @@ in a sub-folder) and see the search results for "foobar" listed. ## The search form -How to design your search form is up to you, but here's a very rudimentary example which you can put either in a -template file or on a specific page. +How to design your search form is up to you, but here's a very rudimentary example which you can put in a +template file: ```html -
+ @@ -74,12 +74,14 @@ template file or on a specific page. // Intercept form submit and go to the search results page directly, avoiding a redirect document.getElementById('search_form').addEventListener('submit', function (e) { var search_terms = document.getElementById('search_input').value; - location.href = '/search/' + encodeURIComponent(search_terms); + location.href = '{{ "search"|link }}/' + encodeURIComponent(search_terms); e.preventDefault(); }); ``` +If you want to put it in a content file, you'll have to adjust the template variables accordingly, ie. instead of `{{ "search"|link }}` you'd use something like `%base_url%?search`. + ## Configuration options You can exclude certain pages from being included in the search results by using the configuration option `search_excludes`.