From a93ffe511cf7f2b914169e44a442f5fd081e3c13 Mon Sep 17 00:00:00 2001 From: ManikanthDindigala <dindigala@sub.uni-goettingen.de> Date: Thu, 22 Jul 2021 10:53:48 +0200 Subject: [PATCH] feat: implementing of search in header and navigating to home or search page accordingly --- src/.vuepress/components/Bar.vue | 4 ++-- src/.vuepress/components/SearchInput.vue | 10 ++++++++++ src/.vuepress/components/SearchPage.vue | 12 +++++++++++- src/.vuepress/components/SearchResultList.vue | 4 ++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/.vuepress/components/Bar.vue b/src/.vuepress/components/Bar.vue index 9a589b5..433ce0e 100644 --- a/src/.vuepress/components/Bar.vue +++ b/src/.vuepress/components/Bar.vue @@ -89,8 +89,8 @@ export default { data: () => ({ editions: [ - { title: 'Syriac Texts', to: 'https://ahikar-dev.sub.uni-goettingen.de/syriac' }, - { title: 'Arabic and Kashuni Texts', to: 'https://ahikar-dev.sub.uni-goettingen.de/arabic-karshuni' }, + { title: 'Syriac Texts', to: 'https://ahikar-dev.sub.uni-goettingen.de/syriac/?source=external' }, + { title: 'Arabic and Kashuni Texts', to: 'https://ahikar-dev.sub.uni-goettingen.de/arabic-karshuni/?source=external' }, ], metaEdition: [ { title: 'Manuscripts', to: '/manuscripts.html' }, diff --git a/src/.vuepress/components/SearchInput.vue b/src/.vuepress/components/SearchInput.vue index 9c10e98..d98f010 100644 --- a/src/.vuepress/components/SearchInput.vue +++ b/src/.vuepress/components/SearchInput.vue @@ -75,6 +75,16 @@ export default { keyboardLayouts: ['arabic', 'syriac'] } }, + watch:{ + '$route.query': { + handler(query) { + if (query.searchTerm) { + this.input = query.searchTerm; + } + }, + immediate: true, + }, + }, methods: { emitSearch() { this.$emit('search', this.input); diff --git a/src/.vuepress/components/SearchPage.vue b/src/.vuepress/components/SearchPage.vue index 87b0213..27309cd 100644 --- a/src/.vuepress/components/SearchPage.vue +++ b/src/.vuepress/components/SearchPage.vue @@ -22,6 +22,16 @@ export default { items: [] } }, + watch:{ + '$route.query': { + handler(query) { + if (query.searchTerm) { + this.onSearch(query.searchTerm); + } + }, + immediate: true, + }, + }, methods: { async onSearch(value) { const searchResponse = await apiService.search(value); @@ -29,7 +39,7 @@ export default { if (searchResponse) { const items = searchResponse.hits?.hits; if (items) { - this.items = items; + this.items = items.map(x=>({...x, searchTerm: value})); } } } diff --git a/src/.vuepress/components/SearchResultList.vue b/src/.vuepress/components/SearchResultList.vue index 57b751e..bfb1074 100644 --- a/src/.vuepress/components/SearchResultList.vue +++ b/src/.vuepress/components/SearchResultList.vue @@ -64,8 +64,8 @@ export default { } else if (item.lang === 'syc') { language = 'syriac' } - return this.viewerBaseUrl + '/' + language + '/#/?itemurl=' + item.item - }, + return `${this.viewerBaseUrl}/${language}/#/?itemurl=${item.item}&source=external&searchTerm=${item.searchTerm}` + } } } </script> -- GitLab