diff --git a/src/.vuepress/components/SearchPage.vue b/src/.vuepress/components/SearchPage.vue index a07384080a135ff905096a359d724c6f3352ea2a..f8b8d72469d8bb3e15d7b271f0cb43bbd62ee913 100644 --- a/src/.vuepress/components/SearchPage.vue +++ b/src/.vuepress/components/SearchPage.vue @@ -42,6 +42,7 @@ :items="items" :message="message" :query="query" + :page="page" /> <div @@ -82,19 +83,25 @@ export default { total: 0, showPlaceholder: false, showNoResult: false, + page: 1, }; }, watch:{ - page: function() { + page: function(page) { this.loading = true; - const from = this.size * (this.page - 1); + const from = this.size * (page - 1); + this.$router.push({ query: { ...this.$route.query, searchTerm:this.query.trim(),page } }); this.search(this.query.trim(), from, this.size); }, }, mounted(){ + const page = this.$route.query?.page; + if(page){ + this.page = parseInt(page); + } if(this.$route.query?.searchTerm) { - this.onSearchInput(this.$route.query.searchTerm); + this.onSearchInput(this.$route.query.searchTerm,this.page); } else { this.showPlaceholder = true; } @@ -117,9 +124,8 @@ export default { }, }, methods: { - onSearchInput(query) { + onSearchInput(query,page) { this.query = query; - this.page = 1; this.resetList(); this.showPlaceholder = false; @@ -128,7 +134,7 @@ export default { this.search(this.query.trim(), 0, this.size); if (this.$route.query.searchTerm !== query) { - this.$router.push({ query: { ...this.$route.query, searchTerm:query } }); + this.$router.push({ query: { ...this.$route.query, searchTerm:query,page:page || this.page } }); } }, async search(value, from, size) { @@ -162,13 +168,6 @@ export default { this.loading = false; } }, - scrollUp() { - window.scrollTo({ - top: 0, - left: 0, - behavior: 'smooth', - }); - }, resetList() { this.items = []; this.distinctSheets = 0; diff --git a/src/.vuepress/components/SearchResultList.vue b/src/.vuepress/components/SearchResultList.vue index e6622938d36d66073ec5cf95f5457099f7ae4dc2..69f712d16c6d2e22d29f7cbdd2a5072e6a2263a9 100644 --- a/src/.vuepress/components/SearchResultList.vue +++ b/src/.vuepress/components/SearchResultList.vue @@ -54,6 +54,10 @@ export default { type: Array, default: () => [], }, + page: { + type: Number, + default: () => 1, + }, }, computed: { viewerBaseUrl() { @@ -72,7 +76,7 @@ export default { } else if (item.lang === 'syc') { language = 'syriac'; } - return `${this.viewerBaseUrl}/${language}/#/?itemurl=${item.item}&source=external&searchTerm=${item.searchTerm}&redirectUrl=${this.getPath}`; + return `${this.viewerBaseUrl}/${language}/#/?itemurl=${item.item}&source=external&searchTerm=${item.searchTerm}&redirectUrl=${this.getPath}&page=${this.page}`; }, }, watch: {