Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid O'Regan <doregan@gitlab.com>2021-07-09 01:00:22 +0300
committerEvan Read <eread@gitlab.com>2021-07-09 01:00:22 +0300
commitbe4ba4a26bd315e172eedd28672e0554ddcc87a9 (patch)
tree73e1f0cf1e6ef846f71f9dad0bfbc7a1e79b9bb7
parent93fa4d11d44a19974a103d37efe39b3dec96cbb6 (diff)
Refine search results formatting
-rw-r--r--content/frontend/search/index.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/content/frontend/search/index.js b/content/frontend/search/index.js
index a021643e..f63f6e96 100644
--- a/content/frontend/search/index.js
+++ b/content/frontend/search/index.js
@@ -1,3 +1,4 @@
+/* eslint-disable no-underscore-dangle */
import instantsearch from '@tnir/instantsearch.js';
import { singleIndexQ } from '@tnir/instantsearch.js/es/lib/stateMappings';
import {
@@ -53,7 +54,20 @@ document.addEventListener('DOMContentLoaded', () => {
infiniteHits({
container: '#hits',
templates: {
- item: document.getElementById('hit-template').innerHTML,
+ item(hit) {
+ const content = hit._highlightResult.content.value.replaceAll('&amp;quot;', '"');
+ return `
+ <a href="${hit.url}" class="hit">
+ <div class="hit-content">
+ <h3 class="hit-name lvl0">${hit._highlightResult.hierarchy.lvl0.value}</h3>
+ <h4 class="hit-description lvl1">${hit._highlightResult.hierarchy.lvl1.value}</h4>
+ <h5 class="hit-description lvl2">${hit._highlightResult.hierarchy.lvl2.value}</h5>
+ <div class="hit-text">${content}</div>
+ <div class="hit-tag">${hit.tags}</div>
+ </div>
+ </a>
+ `;
+ },
empty: 'We didn\'t find any results for the search <em>"{{query}}"</em>',
},
escapeHits: true,