diff --git a/README.md b/README.md index 7f57319..1fdb54c 100644 --- a/README.md +++ b/README.md @@ -314,7 +314,7 @@ Here is the three steps needed to create a search page. outputs: home: ["HTML", "SearchIndex", "[other formats you need]"] ``` -3. Add the shortcode `{{< search >}}` to a page. Also set `searchform: true` in the front matter for that page so the search and flexsearch js files gets loaded. +3. Add the shortcode `{{< search >}}` to a page. The search and flexsearch js files gets loaded automatically on pages that use the shortcode. Your search page will now have a search field where all the posts of the site can be searched. @@ -327,7 +327,7 @@ If your server support php with the mail() command (very common) you can use the 1. Copy the file `themes/zen/php/contact.php.example` to `static/php/contact.php`. 2. Edit the contact.php file so it has your own e-mail address. You may also change the mail subject prefix. -3. Add the shortcode `{{< contact >}}` to a page. Also set `contactform: true` in the front matter for that page so the contact.js file gets loaded. +3. Add the shortcode `{{< contact >}}` to a page. The contact.js file gets loaded automatically on pages that use the shortcode. If you have a SPF record for your domain, make sure the web server is listed or other mail server may mark the mail as spam. diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 33fbe19..14377e2 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -10,11 +10,11 @@ {{ $mobilemenu := resources.Get "js/mobile.js" | minify | fingerprint -}} {{ end -}} -{{ if $.Param "contactform" -}} +{{ if .HasShortcode "contact" -}} {{ $contact := resources.Get "js/contact.js" | minify | fingerprint -}} {{ end -}} -{{ if $.Param "searchform" -}} +{{ if .HasShortcode "search" -}} {{ $flexsearch := resources.Get "js/lib/flexsearch.min.js" | fingerprint -}} {{ $search := resources.Get "js/search.js" | resources.ExecuteAsTemplate "js/search.js" . | minify | fingerprint -}}