diff --git a/src/App.vue b/src/App.vue index f38563b62f6f01782c44cdc0ae9b6eda6ad5e143..cc4ff708f3dda7729319d69e0be056e136877f9a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -95,7 +95,7 @@ export default { self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}} axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + event.q + ' ' + event.q + '*&sort=_score') .then(function(response){ - self.$router.push('/' + self.lang + '/search?q=' + event.q) + self.$router.push('/' + `/search?q=${event.q}&lang=${self.lang}`) self.search_results = response.data.hits.hits self.waiting = false history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '') diff --git a/src/components/Preview.vue b/src/components/Preview.vue index 415fd5a24ce8b879488bd2e6f3056ef45251c756..b77dbdca3619c3f0c0e1a9dea5114e6a2c2a8e71 100644 --- a/src/components/Preview.vue +++ b/src/components/Preview.vue @@ -20,7 +20,7 @@ export default { }, computed: { previewHeader: function(){ - return this.searchHit.text || + return this.searchHit.text && this.searchHit.text + " (" + (this.searchHit._index == "nob" ? "bokmål" : "nynorsk") + ")" || (this.searchHit._source && this.searchHit._source.lemmas.map(l => `<span class="homograph">${l.hgno ? String.fromCharCode(0x215f + l.hgno) + ' ' : ''}</span>${l.lemma}`) || []).join(',') || "Alle søkeresultater..." }, diff --git a/src/components/SearchResults.vue b/src/components/SearchResults.vue index 730adc0de12d54e46086e2b0a367783e989ca5a9..cf9c8aba2c13cb4e3f08f8434e9c4d6ff9892fd2 100644 --- a/src/components/SearchResults.vue +++ b/src/components/SearchResults.vue @@ -2,7 +2,7 @@ <section> <h2 v-if="hits.length">Søkeresultater</h2> <ul class="hits"> - <Preview v-for="(result, index) in hits" :key="index" :searchHit="result" @click.native="article_link_click(result._source)"> + <Preview v-for="(result, index) in hits" :key="index" :searchHit="result" @click.native="article_link_click(result)"> </Preview> </ul> </section> @@ -32,9 +32,9 @@ export default { } }, methods: { - article_link_click: function(article) { - this.$router.push('' + article.article_id) - this.$emit('search-hit-click', article) + article_link_click: function(result) { + this.$router.push('/' + result._index + '/' + result._id) + this.$emit('search-hit-click', result._source) } }, components: { diff --git a/src/main.js b/src/main.js index dfebe1861490ca46e8e6d64b29bb97be92e76dc3..b2f34b77b2aa4587c8dd5523d565abb67ee1c2b3 100644 --- a/src/main.js +++ b/src/main.js @@ -20,7 +20,7 @@ const router = new VueRouter({ props: true }, // Pass route.params to props { name: 'search', - path: '/:lang/search', + path: '/search', component: App, props: true} ]