diff options
author | Sarah German <sgerman@gitlab.com> | 2023-06-30 12:53:42 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2023-06-30 12:53:42 +0300 |
commit | 5274c4174aff1796205b2ff797b53db787ac9b06 (patch) | |
tree | 72cb2dd7dd9ddc1472cd79325297fef222bd11e5 | |
parent | 4ac2098b05545f9eaa7c205ee74772bfb4da2c12 (diff) |
Add context to Lunr search page
-rw-r--r-- | content/frontend/search/components/lunr_results.vue | 12 | ||||
-rw-r--r-- | doc/search.md | 4 | ||||
-rw-r--r-- | spec/frontend/search/lunr_search_spec.js | 12 |
3 files changed, 24 insertions, 4 deletions
diff --git a/content/frontend/search/components/lunr_results.vue b/content/frontend/search/components/lunr_results.vue index c9d5f912..7d147127 100644 --- a/content/frontend/search/components/lunr_results.vue +++ b/content/frontend/search/components/lunr_results.vue @@ -23,6 +23,9 @@ export default { noResults() { return this.submitted && !this.results.length && !this.error; }, + version() { + return document.querySelector('meta[name="gitlab-docs-version"]').content; + }, }, async created() { try { @@ -93,9 +96,14 @@ export default { <template> <div class="lunr-search gl-mb-9"> - <h1>Search</h1> + <h1 data-testid="version-header">Search the {{ version }} docs</h1> <gl-search-box-by-click v-model="query" :value="query" @submit="onSubmit" /> - <div v-if="results.length" class="gl-font-sm gl-mb-6">{{ results.length }} results found</div> + <div v-if="results.length" class="gl-font-sm gl-mb-6"> + {{ results.length }} results found via + <a href="https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/search.md#lunrjs-search"> + Lunr.js + </a> + </div> <ul v-if="results.length"> <li v-for="result in results" :key="result.ref"> diff --git a/doc/search.md b/doc/search.md index b29c956f..5dbf92c8 100644 --- a/doc/search.md +++ b/doc/search.md @@ -59,9 +59,9 @@ As this API key is used in frontend code, it is a public key, but storing it as ## Lunr.js Search -Lunr.js is available as an alternative search backend for self-hosted GitLab Docs installations. Lunr search can also be used in offline or air-gapped environments. Lunr search requires an additional build step to create a search index. +[Lunr.js](https://lunrjs.com/) is available as an alternative search backend for archived and self-hosted GitLab Docs installations. Lunr search can also be used in offline or air-gapped environments. Lunr search requires an additional build step to create a search index. -Documentation review apps use Lunr search by default. +Documentation review apps and versions of the site running on [https://archives.docs.gitlab.com](archives.docs.gitlab.com) use Lunr search by default. ## Development diff --git a/spec/frontend/search/lunr_search_spec.js b/spec/frontend/search/lunr_search_spec.js index 9f890b35..e45b2ee3 100644 --- a/spec/frontend/search/lunr_search_spec.js +++ b/spec/frontend/search/lunr_search_spec.js @@ -4,8 +4,20 @@ import { shallowMount } from '@vue/test-utils'; import SearchPage from '../../../content/frontend/search/components/lunr_results.vue'; +import { setVersionMetatag } from '../default/components/helpers/versions_menu_helper'; describe('content/frontend/search/components/lunr_results.vue', () => { + const mockVersion = '16.2'; + beforeEach(() => { + setVersionMetatag(mockVersion); + }); + + it('Page title includes the site version', () => { + const wrapper = shallowMount(SearchPage); + const version = wrapper.find('[data-testid="version-header"]').text(); + expect(version).toContain(mockVersion); + }); + it('Search form renders', () => { const wrapper = shallowMount(SearchPage); expect(wrapper.findComponent(SearchPage).isVisible()).toBe(true); |