allow site owners to enable global-search #104
Signed-off-by: weru <fromweru@gmail.com>
| | |
| | | } |
| | | |
| | | function search(index, scope = null, passive = false) { |
| | | scope = search_scope_global ? null : scope; |
| | | if(search_term.length) { |
| | | let raw_results = index; |
| | | if(!algolia_config.on) { |
| | |
| | | |
| | | function liveSearch(index) { |
| | | if (search_field) { |
| | | const search_scope = search_field.dataset.scope; |
| | | let search_scope = search_field.dataset.scope; |
| | | search(index, search_scope); |
| | | search_scope = search_scope_global ? null : search_scope; |
| | | if(!search_page_element) { |
| | | search_field.addEventListener('search', function(){ |
| | | search_term = search_field.value.trim().toLowerCase(); |
| | |
| | | } |
| | | |
| | | const search_page_element = elem('#searchpage'); |
| | | let search_scope_global = `{{ trim site.Params.search.global " " }}`; |
| | | search_scope_global = search_scope_global == 'true' ? true : false; |
| | | |
| | | // Fuse specific |
| | | let search_keys = ['body', 'title', 'link', 'section', 'id',]; |
| | |
| | | # search |
| | | [search] |
| | | on = true |
| | | # Site logo |
| | | global = false # turn to `true` to enable global search |
| | | [search.algolia] |
| | | enable = false # if false search will default to fusejs |
| | | id = "Q40WQQX84U" # Application ID |
| | | index = "compose" # Index name |
| | | key = "da87401a458102ec6bbd6cc5e5cf8d95" # Search-Only API Key |
| | | |
| | | # Site logo |
| | | [logo] |
| | | lightMode = "images/compose.svg" |
| | | darkMode = "images/compose-light.svg" |
| | |
| | | # search |
| | | [search] |
| | | on = true |
| | | # Site logo |
| | | global = false |
| | | [search.algolia] |
| | | enable = false # if false search will default to fusejs |
| | | id = "Q40WQQX84U" # Application ID |
| | |
| | | |
| | | Algolia will require you to build and host your index. For those using Github, this theme ships with an [algolia github action](/docs/compose/github-actions/#algolia-ci). |
| | | |
| | | By default, search will return results from the current content section. Searches from the top level section e.g the homepage, will return global results. This way, the results are scoped. You can override this behaviour using this setting |
| | | |
| | | ```toml |
| | | ... |
| | | [search] |
| | | ... |
| | | global = false # turn to `true` to enable global search |
| | | ... |
| | | ``` |
| | | |
| | | |
| | | At the time of this writing, search on these theme takes either of this forms: |
| | | |
| | | ### 1. Passive search |