From 09b3a4355398c701c58ad50cab7a4f8f26cf64f4 Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Tue, 12 Mar 2024 15:45:37 +0100 Subject: [PATCH 01/15] Added first config for algolia Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 9318b70..2e8ddd1 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -2,5 +2,19 @@ <script async src="{{{uiRootPath}}}/js/vendor/highlight.js"></script> <script async src="{{{uiRootPath}}}/js/vendor/highlightjs-line-numbers.js"></script> {{#if env.SITE_SEARCH_PROVIDER}} +{{#if eq (env.SITE_SEARCH_PROVIDER,"ALGOLIA")}} +<script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script> +<script> +docsearch({ + {{#with env.ALGOLIA_APPLICATION_ID}} + appId: '{{this}}', + {{/if}} + apiKey: '{{env.ALGOLIA_API_KEY}}', + indexName: '{{env.ALGOLIA_INDEX_NAME}}', + inputSelector: '#search-input', + algoliaOptions: { hitsPerPage: 10 } +}) +</script> +{{#else}} {{> search-scripts}} {{/if}} -- GitLab From 8157a711c550a0ca86e6d9f69bcb59c00ada7912 Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Tue, 12 Mar 2024 15:58:46 +0100 Subject: [PATCH 02/15] Test with different eq check Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 2e8ddd1..db644eb 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -2,7 +2,7 @@ <script async src="{{{uiRootPath}}}/js/vendor/highlight.js"></script> <script async src="{{{uiRootPath}}}/js/vendor/highlightjs-line-numbers.js"></script> {{#if env.SITE_SEARCH_PROVIDER}} -{{#if eq (env.SITE_SEARCH_PROVIDER,"ALGOLIA")}} +{{#if eq ('{{env.SITE_SEARCH_PROVIDER}}','ALGOLIA')}} <script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script> <script> docsearch({ -- GitLab From bb4333e0ee666d4fdaa74c45737cc42f840ea300 Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Tue, 12 Mar 2024 16:05:20 +0100 Subject: [PATCH 03/15] Fixes for use with eq and else Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index db644eb..303727b 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -2,7 +2,7 @@ <script async src="{{{uiRootPath}}}/js/vendor/highlight.js"></script> <script async src="{{{uiRootPath}}}/js/vendor/highlightjs-line-numbers.js"></script> {{#if env.SITE_SEARCH_PROVIDER}} -{{#if eq ('{{env.SITE_SEARCH_PROVIDER}}','ALGOLIA')}} +{{#if (eq env.SITE_SEARCH_PROVIDER 'ALGOLIA')}} <script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script> <script> docsearch({ @@ -15,6 +15,7 @@ docsearch({ algoliaOptions: { hitsPerPage: 10 } }) </script> -{{#else}} +{{else}} {{> search-scripts}} {{/if}} +{{/if}} -- GitLab From a5abe7f6531346ed93d7597477f8fc8f7ce5233d Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Tue, 12 Mar 2024 16:20:23 +0100 Subject: [PATCH 04/15] Fixed /if to /with Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 303727b..92cb83c 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -2,20 +2,20 @@ <script async src="{{{uiRootPath}}}/js/vendor/highlight.js"></script> <script async src="{{{uiRootPath}}}/js/vendor/highlightjs-line-numbers.js"></script> {{#if env.SITE_SEARCH_PROVIDER}} -{{#if (eq env.SITE_SEARCH_PROVIDER 'ALGOLIA')}} -<script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script> -<script> -docsearch({ - {{#with env.ALGOLIA_APPLICATION_ID}} - appId: '{{this}}', - {{/if}} - apiKey: '{{env.ALGOLIA_API_KEY}}', - indexName: '{{env.ALGOLIA_INDEX_NAME}}', - inputSelector: '#search-input', - algoliaOptions: { hitsPerPage: 10 } -}) -</script> -{{else}} -{{> search-scripts}} -{{/if}} + {{#if (eq env.SITE_SEARCH_PROVIDER 'ALGOLIA')}} + <script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script> + <script> + docsearch({ + {{#with env.ALGOLIA_APPLICATION_ID}} + appId: '{{this}}', + {{/with}} + apiKey: '{{env.ALGOLIA_API_KEY}}', + indexName: '{{env.ALGOLIA_INDEX_NAME}}', + inputSelector: '#search-input', + algoliaOptions: { hitsPerPage: 10 } + }) + </script> + {{else}} + {{> search-scripts}} + {{/if}} {{/if}} -- GitLab From 2ac3965a646cc8a9c5521bdd8b9c18dae257dcbb Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Tue, 12 Mar 2024 16:39:41 +0100 Subject: [PATCH 05/15] Added new search field for algolia Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/header-content.hbs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/partials/header-content.hbs b/src/partials/header-content.hbs index 50a158e..6fef3ba 100644 --- a/src/partials/header-content.hbs +++ b/src/partials/header-content.hbs @@ -12,11 +12,17 @@ <div class="navbar-item search hide-for-print"> {{#if env.SITE_SEARCH_PROVIDER}} <div id="search-field" class="field"> - <input id="search-input" type="text" placeholder="Search the docs"{{#if page.home}} autofocus{{/if}}> - {{#if page.attributes.limit-search-checkbox}} - <label class="filter checkbox"> - <input type="checkbox" data-facet-filter="component:{{page.component.name}}" {{#if page.attributes.search-checkbox-default-active}}checked{{/if}}> This doc only - </label> + {{#if (eq env.SITE_SEARCH_PROVIDER 'ALGOLIA')}} + <span class="algolia-autocomplete algolia-autocomplete-left" style="position: relative; display: inline-block; direction: ltr;"> + <input id="search-input" type="text" placeholder="Search the docs" {{#if page.home}} autofocus{{/if}} class="ds-input" autocomplete="off" spellcheck="false" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-label="search input" aria-owns="algolia-autocomplete-listbox-0" dir="auto" style="position: relative; vertical-align: top;"> + </span> + {{else}} + <input id="search-input" type="text" placeholder="Search the docs"{{#if page.home}} autofocus{{/if}}> + {{#if page.attributes.limit-search-checkbox}} + <label class="filter checkbox"> + <input type="checkbox" data-facet-filter="component:{{page.component.name}}" {{#if page.attributes.search-checkbox-default-active}}checked{{/if}}> This doc only + </label> + {{/if}} {{/if}} </div> {{/if}} -- GitLab From 691360b743b261f031a5994266ee712222d9bc99 Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Tue, 12 Mar 2024 16:47:08 +0100 Subject: [PATCH 06/15] Added conditional stylesheet for algolia Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/head-styles.hbs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/partials/head-styles.hbs b/src/partials/head-styles.hbs index d6839e5..d001801 100644 --- a/src/partials/head-styles.hbs +++ b/src/partials/head-styles.hbs @@ -1 +1,6 @@ <link rel="stylesheet" href="{{{uiRootPath}}}/css/site.css"> + {{#if env.SITE_SEARCH_PROVIDER}} + {{#if (eq env.SITE_SEARCH_PROVIDER 'ALGOLIA')}} + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" /> + {{/if}} + {{/if}} -- GitLab From 8375cad102f27ffadecb2743fefdc6c05f955b4a Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Tue, 12 Mar 2024 17:04:57 +0100 Subject: [PATCH 07/15] Added description on how to use algolia Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- .../modules/ROOT/pages/algolia-search.adoc | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 preview-src/modules/ROOT/pages/algolia-search.adoc diff --git a/preview-src/modules/ROOT/pages/algolia-search.adoc b/preview-src/modules/ROOT/pages/algolia-search.adoc new file mode 100644 index 0000000..80b7312 --- /dev/null +++ b/preview-src/modules/ROOT/pages/algolia-search.adoc @@ -0,0 +1,29 @@ += Algolia search +IMPORTANT: Algolia is used with a free account right now and only allows runs on publicly available urls. +For this reason, Algolia must only be integrated for releases on public urls, not for internal or local builds during development. +Make sure to update the algolia index (or that the respective pipeline job has completed) before testing the search function! + +Antora comes packed with a simple and locally run search engine called "Lunr". +However, this engine is somewhat limited in its abilities. +For this reason, the much more evolved engine "Algolia" is recommended for released documents. + +The switch is handled through environment variables during generation and applied through the UI. +It is strongly recommended to not build this feature manually. +Instead, the respective release pipeline should handle the correct setup of variables and the deactivation of the lunr extension. + +== Usage +Before a project can use Algolia for the first time, a new application has to be registered within Algolia. +Contact the ASAM CTO for more information. + +If the project has been set up, the following (environment) variables have to be specified (in the project's secrets): + +- ALGOLIA_APPLICATION_ID: The ID of the application in Algolia +- ALGOLIA_INDEX_NAME: The name of the application (index) in Algolia +- ALGOLIA_ADMIN_API_KEY: The key used to generate the index (not required for read-access) +- ALGOLIA_API_KEY: The read-access key for Algolia + +Additionally, the following configuration must be made for the respective release job that generates the Antora output: + +- SITE_SEARCH_PROVIDER=ALGOLIA + +Make sure that, when using Algolia, the Lunr extension is deactivated or removed from the site.yml (in the job). -- GitLab From 0fa763528de936da18c2b5de90a9b6e415d572aa Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Wed, 13 Mar 2024 15:33:45 +0100 Subject: [PATCH 08/15] Unified variable naming Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 92cb83c..f390aef 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -6,10 +6,10 @@ <script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script> <script> docsearch({ - {{#with env.ALGOLIA_APPLICATION_ID}} + {{#with env.ALGOLIA_APP_ID}} appId: '{{this}}', {{/with}} - apiKey: '{{env.ALGOLIA_API_KEY}}', + apiKey: '{{env.ALGOLIA_READ_API_KEY}}', indexName: '{{env.ALGOLIA_INDEX_NAME}}', inputSelector: '#search-input', algoliaOptions: { hitsPerPage: 10 } -- GitLab From 8b4c2af46002b1ba583c124b3f505149e7eb3f2f Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Wed, 20 Mar 2024 17:11:57 +0100 Subject: [PATCH 09/15] Updated to docsearch v3 Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 7 +++---- src/partials/head-styles.hbs | 2 +- src/partials/header-content.hbs | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index f390aef..59275e5 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -3,16 +3,15 @@ <script async src="{{{uiRootPath}}}/js/vendor/highlightjs-line-numbers.js"></script> {{#if env.SITE_SEARCH_PROVIDER}} {{#if (eq env.SITE_SEARCH_PROVIDER 'ALGOLIA')}} - <script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script> <script> docsearch({ + container: '#docsearch', {{#with env.ALGOLIA_APP_ID}} appId: '{{this}}', {{/with}} apiKey: '{{env.ALGOLIA_READ_API_KEY}}', - indexName: '{{env.ALGOLIA_INDEX_NAME}}', - inputSelector: '#search-input', - algoliaOptions: { hitsPerPage: 10 } + indexName: '{{env.ALGOLIA_INDEX_NAME}}' }) </script> {{else}} diff --git a/src/partials/head-styles.hbs b/src/partials/head-styles.hbs index d001801..047c84b 100644 --- a/src/partials/head-styles.hbs +++ b/src/partials/head-styles.hbs @@ -1,6 +1,6 @@ <link rel="stylesheet" href="{{{uiRootPath}}}/css/site.css"> {{#if env.SITE_SEARCH_PROVIDER}} {{#if (eq env.SITE_SEARCH_PROVIDER 'ALGOLIA')}} - <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" /> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3" > {{/if}} {{/if}} diff --git a/src/partials/header-content.hbs b/src/partials/header-content.hbs index 6fef3ba..915ca1c 100644 --- a/src/partials/header-content.hbs +++ b/src/partials/header-content.hbs @@ -13,9 +13,7 @@ {{#if env.SITE_SEARCH_PROVIDER}} <div id="search-field" class="field"> {{#if (eq env.SITE_SEARCH_PROVIDER 'ALGOLIA')}} - <span class="algolia-autocomplete algolia-autocomplete-left" style="position: relative; display: inline-block; direction: ltr;"> - <input id="search-input" type="text" placeholder="Search the docs" {{#if page.home}} autofocus{{/if}} class="ds-input" autocomplete="off" spellcheck="false" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-label="search input" aria-owns="algolia-autocomplete-listbox-0" dir="auto" style="position: relative; vertical-align: top;"> - </span> + <div id="docsearch"></div> {{else}} <input id="search-input" type="text" placeholder="Search the docs"{{#if page.home}} autofocus{{/if}}> {{#if page.attributes.limit-search-checkbox}} -- GitLab From e7c31033789420913516e02eaae67c250398c784 Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Wed, 20 Mar 2024 17:39:55 +0100 Subject: [PATCH 10/15] Added better placeholder text Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 59275e5..70790e6 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -11,7 +11,8 @@ appId: '{{this}}', {{/with}} apiKey: '{{env.ALGOLIA_READ_API_KEY}}', - indexName: '{{env.ALGOLIA_INDEX_NAME}}' + indexName: '{{env.ALGOLIA_INDEX_NAME}}', + placeholder: 'Search the docs', }) </script> {{else}} -- GitLab From d70ebeca03b8ae4a7172aa3b3cf17d68b5aa12d0 Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Thu, 21 Mar 2024 15:19:27 +0100 Subject: [PATCH 11/15] Added new look for faceted search Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/css/search.css | 13 +++++++++++++ src/partials/header-content.hbs | 9 ++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/css/search.css b/src/css/search.css index 1fb8f67..60f63fa 100644 --- a/src/css/search.css +++ b/src/css/search.css @@ -77,3 +77,16 @@ #search-field .filter { margin: 0; } + +#search-field #docsearch-container .filter { + border-width: 0; +} + +#docsearch-container { + width: 100%; + height: 100%; + display: flex; + border: 2px solid var(--color-asam-blue); + border-radius: 20px; + background: var(--color-smoke-50); +} diff --git a/src/partials/header-content.hbs b/src/partials/header-content.hbs index 915ca1c..341f215 100644 --- a/src/partials/header-content.hbs +++ b/src/partials/header-content.hbs @@ -13,7 +13,14 @@ {{#if env.SITE_SEARCH_PROVIDER}} <div id="search-field" class="field"> {{#if (eq env.SITE_SEARCH_PROVIDER 'ALGOLIA')}} - <div id="docsearch"></div> + <div id="docsearch-container"> + <div id="docsearch"></div> + {{#if page.attributes.limit-search-checkbox}} + <label class="filter checkbox"> + <input type="checkbox" data-facet-filter="component:{{page.component.name}}" {{#if page.attributes.search-checkbox-default-active}}checked{{/if}}> This doc only + </label> + {{/if}} + </div> {{else}} <input id="search-input" type="text" placeholder="Search the docs"{{#if page.home}} autofocus{{/if}}> {{#if page.attributes.limit-search-checkbox}} -- GitLab From fd33be47a7b4a1daf174055d99dbce7a1a5e3f6e Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Thu, 21 Mar 2024 17:52:19 +0100 Subject: [PATCH 12/15] Added filter options for algolia Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 32 +++++++++++++++++++++++--------- src/partials/header-content.hbs | 2 +- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 70790e6..94a3acf 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -5,15 +5,29 @@ {{#if (eq env.SITE_SEARCH_PROVIDER 'ALGOLIA')}} <script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script> <script> - docsearch({ - container: '#docsearch', - {{#with env.ALGOLIA_APP_ID}} - appId: '{{this}}', - {{/with}} - apiKey: '{{env.ALGOLIA_READ_API_KEY}}', - indexName: '{{env.ALGOLIA_INDEX_NAME}}', - placeholder: 'Search the docs', - }) + function createDocSearch() { + const filterInput = document.getElementById("data-facet-filter") + const facetFilters = filterInput.checked ? [filterInput.getAttribute('data-facet-filter')] : [] + const currentVersion = document.querySelector("span.version").innerHTML + docsearch({ + container: '#docsearch', + {{#with env.ALGOLIA_APP_ID}} + appId: '{{this}}', + {{/with}} + apiKey: '{{env.ALGOLIA_READ_API_KEY}}', + indexName: '{{env.ALGOLIA_INDEX_NAME}}', + placeholder: 'Search the docs', + maxResultsPerGroup: 10, + hitsPerPage: 100, + searchParameters: { + facetFilters: facetFilters, + optionalFilters: `componentversion:${filterInput.getAttribute('data-componentversion')}` + {{!-- the optionalFilter prioritizes the current componentversion, the facetFilters makes it possible to limit searching to the current component --}} + }, + insights: true + }) + } + createDocSearch() </script> {{else}} {{> search-scripts}} diff --git a/src/partials/header-content.hbs b/src/partials/header-content.hbs index 341f215..38e4aa6 100644 --- a/src/partials/header-content.hbs +++ b/src/partials/header-content.hbs @@ -17,7 +17,7 @@ <div id="docsearch"></div> {{#if page.attributes.limit-search-checkbox}} <label class="filter checkbox"> - <input type="checkbox" data-facet-filter="component:{{page.component.name}}" {{#if page.attributes.search-checkbox-default-active}}checked{{/if}}> This doc only + <input id="data-facet-filter" type="checkbox" onclick="createDocSearch()" data-facet-filter="component:{{page.component.title}}" data-componentversion="{{page.component.title}}{{page.componentVersion.displayVersion}}" data-component="{{page.component.title}}" data-version="{{page.componentVersion.displayVersion}}" {{#if page.attributes.search-checkbox-default-active}}checked{{/if}}> This doc only </label> {{/if}} </div> -- GitLab From 452ecd460c86b6494d7ec90b4ea2c26ec143bdc3 Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Tue, 9 Apr 2024 10:53:47 +0200 Subject: [PATCH 13/15] Changed settings on optionalFilters and pagination Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 94a3acf..caaf77c 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -17,14 +17,13 @@ apiKey: '{{env.ALGOLIA_READ_API_KEY}}', indexName: '{{env.ALGOLIA_INDEX_NAME}}', placeholder: 'Search the docs', - maxResultsPerGroup: 10, - hitsPerPage: 100, + maxResultsPerGroup: 8, searchParameters: { facetFilters: facetFilters, - optionalFilters: `componentversion:${filterInput.getAttribute('data-componentversion')}` - {{!-- the optionalFilter prioritizes the current componentversion, the facetFilters makes it possible to limit searching to the current component --}} - }, - insights: true + hitsPerPage: 1000, + sumOrFiltersScores: true, + optionalFilters: [`component:${filterInput.getAttribute('data-component')}`,`version:${filterInput.getAttribute('data-version')}`] + } }) } createDocSearch() -- GitLab From 89329a8edd5b493614499256914d3c7a971d9688 Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Tue, 9 Apr 2024 11:07:20 +0200 Subject: [PATCH 14/15] Added scoring to prioritize the component over the version Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index caaf77c..92d340e 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -22,7 +22,7 @@ facetFilters: facetFilters, hitsPerPage: 1000, sumOrFiltersScores: true, - optionalFilters: [`component:${filterInput.getAttribute('data-component')}`,`version:${filterInput.getAttribute('data-version')}`] + optionalFilters: [`component:${filterInput.getAttribute('data-component')}<score=2>`,`version:${filterInput.getAttribute('data-version')}`] } }) } -- GitLab From 71ca0c2b030955791317abff7bfe268ef5a4796b Mon Sep 17 00:00:00 2001 From: "Philip WINDECKER (AVENYR GmbH)" <philip.windecker@avenyr.de> Date: Tue, 9 Apr 2024 11:23:28 +0200 Subject: [PATCH 15/15] Generlized and optimized some of the docsearch Signed-off-by: Philip WINDECKER (AVENYR GmbH) <philip.windecker@avenyr.de> --- src/partials/footer-scripts.hbs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 92d340e..47c6e39 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -8,6 +8,9 @@ function createDocSearch() { const filterInput = document.getElementById("data-facet-filter") const facetFilters = filterInput.checked ? [filterInput.getAttribute('data-facet-filter')] : [] + const hitsPerPage = filterInput.checked ? 100 : 1000 + const maxResultsPerGroup = 8 + const optionalFilters = filterInput.checked ? [] : [`component:${filterInput.getAttribute('data-component')}<score=2>`,`version:${filterInput.getAttribute('data-version')}`] const currentVersion = document.querySelector("span.version").innerHTML docsearch({ container: '#docsearch', @@ -17,12 +20,12 @@ apiKey: '{{env.ALGOLIA_READ_API_KEY}}', indexName: '{{env.ALGOLIA_INDEX_NAME}}', placeholder: 'Search the docs', - maxResultsPerGroup: 8, + maxResultsPerGroup: maxResultsPerGroup, searchParameters: { facetFilters: facetFilters, - hitsPerPage: 1000, + hitsPerPage: hitsPerPage, sumOrFiltersScores: true, - optionalFilters: [`component:${filterInput.getAttribute('data-component')}<score=2>`,`version:${filterInput.getAttribute('data-version')}`] + optionalFilters: optionalFilters } }) } -- GitLab