From 82b3f1544391be82cb141efe2cb9ca03bcc886a8 Mon Sep 17 00:00:00 2001 From: Silvio Giebl <silvio.giebl@hivemq.com> Date: Sun, 29 Dec 2019 21:30:44 +0100 Subject: [PATCH] Added search.button configuration Improved documentation for search configurations --- _config.yml | 23 ++++++++++++++++++----- _layouts/default.html | 8 +++++--- assets/js/just-the-docs.js | 2 +- assets/js/zzzz-search-data.json | 2 +- docs/configuration.md | 23 ++++++++++++++++++----- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/_config.yml b/_config.yml index 7bd5727f..854aa4fe 100644 --- a/_config.yml +++ b/_config.yml @@ -27,11 +27,24 @@ exclude: ["node_modules/", "*.gemspec", "*.gem", "Gemfile", "Gemfile.lock", "pac # Enable or disable the site search search_enabled: true search: - heading_level: 2 # Split documents into sections that can be individually searched - preview_words_before: 5 # Maximum amount of words to display before a matched word in the preview - preview_words_after: 10 # Maximum amount of words to display after a matched word in the preview - rel_url: false # Include the relative url in the search: true (default) or false - tokenizer_separator: /[\s/]+/ # Enable support for hyphenated search words + # Split documents into sections that can be individually searched + # Supports 1 - 6, default: 2 + heading_level: 2 + # Maximum amount of words to display before a matched word in the preview + # Default: 5 + preview_words_before: 5 + # Maximum amount of words to display after a matched word in the preview + # Default: 10 + preview_words_after: 10 + # Include the relative url in the search + # Supports true (default) or false + rel_url: false + # Enable support for hyphenated search words + # Default: /[\s\-/]+/ + tokenizer_separator: /[\s/]+/ + # Enable or disable the search button + # Supports true or false (default) + button: true # Enable or disable heading anchors heading_anchors: true diff --git a/_layouts/default.html b/_layouts/default.html index 81dd721d..32a1c997 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -115,9 +115,11 @@ layout: table_wrappers </div> {% if site.search_enabled != false %} - <a href="#" id="search-button" class="search-button"> - <svg viewBox="0 0 24 24" class="icon"><use xlink:href="#svg-search"></use></svg> - </a> + {% if site.search.button %} + <a href="#" id="search-button" class="search-button"> + <svg viewBox="0 0 24 24" class="icon"><use xlink:href="#svg-search"></use></svg> + </a> + {% endif %} <div class="search-overlay"></div> {% endif %} diff --git a/assets/js/just-the-docs.js b/assets/js/just-the-docs.js index e9b497c9..343e261d 100644 --- a/assets/js/just-the-docs.js +++ b/assets/js/just-the-docs.js @@ -51,7 +51,7 @@ function initNav() { } }); - {% if site.search_enabled != false -%} + {% if site.search_enabled != false and site.search.button -%} const searchInput = document.getElementById('search-input'); const searchButton = document.getElementById('search-button'); diff --git a/assets/js/zzzz-search-data.json b/assets/js/zzzz-search-data.json index d336e8c5..60aa26e1 100644 --- a/assets/js/zzzz-search-data.json +++ b/assets/js/zzzz-search-data.json @@ -6,7 +6,7 @@ permalink: /assets/js/search-data.json {% for page in site.html_pages %} {%- if page.title and page.search_exclude != true -%} {%- assign page_content = page.content -%} - {%- assign heading_level = site.search.heading_level | default: 1 -%} + {%- assign heading_level = site.search.heading_level | default: 2 -%} {%- for j in (2..heading_level) -%} {%- assign tag = '<h' | append: j -%} {%- assign closing_tag = '</h' | append: j -%} diff --git a/docs/configuration.md b/docs/configuration.md index 4c175e85..d3facd2d 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -37,11 +37,24 @@ logo: "/assets/images/just-the-docs.png" search_enabled: true search: - heading_level: 2 # Split documents into sections that can be individually searched - preview_words_before: 5 # Maximum amount of words to display before a matched word in the preview - preview_words_after: 10 # Maximum amount of words to display after a matched word in the preview - rel_url: false # Include the relative url in the search: true (default) or false - tokenizer_separator: /[\s/]+/ # Enable support for hyphenated search words + # Split documents into sections that can be individually searched + # Supports 1 - 6, default: 2 + heading_level: 2 + # Maximum amount of words to display before a matched word in the preview + # Default: 5 + preview_words_before: 5 + # Maximum amount of words to display after a matched word in the preview + # Default: 10 + preview_words_after: 10 + # Include the relative url in the search + # Supports true (default) or false + rel_url: false + # Enable support for hyphenated search words + # Default: /[\s\-/]+/ + tokenizer_separator: /[\s/]+/ + # Enable or disable the search button + # Supports true or false (default) + button: true ``` ## Aux links -- GitLab