diff --git a/src/.vuepress/components/SearchPage.vue b/src/.vuepress/components/SearchPage.vue index 7614927fbb875a601ad9f577c7b1ebf6a4886a8e..4729c62494f624a6849a6346f3f90b85b32e7e42 100644 --- a/src/.vuepress/components/SearchPage.vue +++ b/src/.vuepress/components/SearchPage.vue @@ -5,7 +5,7 @@ <p v-if="total > 0"> Found a total of <code class="font-weight-black">{{ total }}</code> {{ 'Hit' | numerus(total) }} for <code class="font-weight-black">{{ query }}</code> in - <!-- <code class="font-weight-black">{{ distinctSheets }}</code> {{ 'Sheet' | numerus(distinctSheets) }} and --> + <code class="font-weight-black">{{ distinctSheets }}</code> {{ 'Sheet' | numerus(distinctSheets) }} and <code class="font-weight-black">{{ distinctManuscripts }}</code> {{ 'Manuscript' | numerus(distinctManuscripts) }}. </p> @@ -33,7 +33,7 @@ @click="scrollUp()" > <v-pagination - v-if="total > size" + v-if="distinctSheets > size" v-model="page" :length="pagesAmount" :total-visible="7" @@ -55,6 +55,7 @@ export default { data() { return { distinctManuscripts: 0, + distinctSheets: 0, hitCounter: 0, items: [], loading: false, @@ -82,16 +83,12 @@ export default { }, }, computed: { - distinctSheets() { - const distinct = [...new Set(this.items.map(item => item.n))]; - return distinct.length; - }, invalid() { return this.query.match(/^\s*$/); }, pagesAmount() { - return this.total > 0 - ? Math.ceil(this.total / this.size) + return this.distinctSheets > 0 + ? Math.ceil(this.distinctSheets / this.size) : 1; }, }, @@ -115,6 +112,7 @@ export default { try { this.items = []; this.total = 0; + this.distinctSheets = 0; this.loading = true; @@ -125,12 +123,15 @@ export default { this.items = items.map(x => ({ ...x, searchTerm: value })); this.distinctManuscripts = searchResponse.hits?.total?.manifests || 0; - this.total = searchResponse.hits?.total?.value || 0; + this.distinctSheets = searchResponse.hits?.total?.value || 0; + + this.total = searchResponse.hits?.total?.matches || 0; } if (!this.invalid) this.message = `No search results found for <code>${this.query}</code>.`; } catch(error) { this.items = []; + this.distinctSheets = 0; this.total = 0; this.message = 'Please enter a valid search term.';