diff --git a/CHANGELOG.md b/CHANGELOG.md index a0d1f6f1c534..d194056c0d79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Unreleased + +### Enhancements + +* Add support for [Algolia](https://www.algolia.com/) search provider. [#1416](https://github.com/mmistakes/minimal-mistakes/issues/1416) + ## [4.9.1](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.9.1) ### Enhancements diff --git a/_config.yml b/_config.yml index 1a2694a1f812..ae4fe9779f26 100644 --- a/_config.yml +++ b/_config.yml @@ -53,6 +53,12 @@ atom_feed: path : # blank (default) uses feed.xml search : # true, false (default) search_full_content : # true, false (default) +search_provider : # lunr (default), algolia +algolia: + application_id : # YOUR_APPLICATION_ID + index_name : # YOUR_INDEX_NAME + search_only_api_key : # YOUR_SEARCH_ONLY_API_KEY + powered_by : # true (default), false # SEO Related google_site_verification : diff --git a/_includes/scripts.html b/_includes/scripts.html index 45113e09090f..ded8e7ba599f 100644 --- a/_includes/scripts.html +++ b/_includes/scripts.html @@ -13,16 +13,13 @@ {% endif %} {% if site.search == true or page.layout == "search" %} - {% assign lang = site.locale | slice: 0,2 | default: "en" %} - {% case lang %} - {% when "gr" %} - {% assign lang = "gr" %} - {% else %} - {% assign lang = "en" %} - {% endcase %} - - - + {%- assign search_provider = site.search_provider | default: "lunr" -%} + {%- case search_provider -%} + {%- when "lunr" -%} + {% include search/lunr-search-scripts.html %} + {%- when "algolia" -%} + {% include search/algolia-search-scripts.html %} + {%- endcase -%} {% endif %} {% include analytics.html %} diff --git a/_includes/search/algolia-search-scripts.html b/_includes/search/algolia-search-scripts.html new file mode 100644 index 000000000000..1ec021df257e --- /dev/null +++ b/_includes/search/algolia-search-scripts.html @@ -0,0 +1,54 @@ + + + + + + diff --git a/_includes/search/lunr-search-scripts.html b/_includes/search/lunr-search-scripts.html new file mode 100644 index 000000000000..b8ffc23162ba --- /dev/null +++ b/_includes/search/lunr-search-scripts.html @@ -0,0 +1,10 @@ +{% assign lang = site.locale | slice: 0,2 | default: "en" %} +{% case lang %} +{% when "gr" %} + {% assign lang = "gr" %} +{% else %} + {% assign lang = "en" %} +{% endcase %} + + + \ No newline at end of file diff --git a/_includes/search/search_form.html b/_includes/search/search_form.html new file mode 100644 index 000000000000..3058f6b14c7e --- /dev/null +++ b/_includes/search/search_form.html @@ -0,0 +1,11 @@ +