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

search_page.vue « components « search « frontend « content - gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ad19418523bfab5d013d03ec53d5f378ad166bae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<script>
import algoliasearch from 'algoliasearch/lite';
import 'instantsearch.css/themes/satellite-min.css';
import { history as historyRouter } from 'instantsearch.js/es/lib/routers';
import { singleIndex as singleIndexMapping } from 'instantsearch.js/es/lib/stateMappings';
import { GlIcon } from '@gitlab/ui';

export default {
  components: {
    GlIcon,
  },
  props: {
    docsVersion: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      searchClient: algoliasearch('3PNCFOU757', '89b85ffae982a7f1adeeed4a90bb0ab1'),
      routing: {
        router: historyRouter(),
        stateMapping: singleIndexMapping('gitlab'),
      },
    };
  },
};
</script>

<template>
  <ais-instant-search
    :search-client="searchClient"
    index-name="gitlab"
    :routing="routing"
    :stalled-search-delay="500"
    class="gl-pb-8"
  >
    <h1>Search</h1>
    <ais-search-box
      placeholder="Search GitLab Documentation"
      show-loading-indicator
      data-testid="docs-search"
    />

    <ais-state-results>
      <template #default="{ results: { hits, query } }">
        <div class="gl-display-flex gl-align-items-bottom gl-mb-6">
          <ais-stats v-show="query.length > 0" class="gl-font-sm" />
          <ais-powered-by
            :class-names="{
              'ais-PoweredBy': 'gl-absolute gl-right-7 gl-mt-2',
              'ais-PoweredBy-link': 'no-attachment-icon gl-border-bottom-0!',
            }"
          />
        </div>

        <ais-infinite-hits v-if="query.length > 0 && hits.length > 0">
          <template #item="{ item }">
            <div>
              <a :href="item.url" class="gl-font-lg">{{ item.hierarchy.lvl0 }}</a>
              <p v-if="item.hierarchy.lvl2" class="gl-mt-2! gl-font-base!">
                <gl-icon name="chevron-right" :size="12" /> {{ item.hierarchy.lvl2 }}
              </p>
            </div>
          </template>
        </ais-infinite-hits>

        <div v-if="query.length > 0 && hits.length < 0">
          No results found for <em>{{ query }}</em
          >.
        </div>
      </template>
    </ais-state-results>

    <ais-configure :hits-per-page.camel="10" :facet-filters.camel="`version:` + docsVersion" />
  </ais-instant-search>
</template>