From b8ce2cd306424eb60f0a9320235087244aac20c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ole=20Volds=C3=A6ter?= <ole.voldsater@uib.no>
Date: Mon, 9 Mar 2020 13:39:33 +0100
Subject: [PATCH] =?UTF-8?q?tospr=C3=A5klige=20s=C3=B8k=20virker,=20men=20"?=
 =?UTF-8?q?alle=20resultater"=20m=C3=A5=20splittes=20i=20to=20deler?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/App.vue                      | 2 +-
 src/components/Preview.vue       | 2 +-
 src/components/SearchResults.vue | 8 ++++----
 src/main.js                      | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/App.vue b/src/App.vue
index f38563b6..cc4ff708 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 415fd5a2..b77dbdca 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 730adc0d..cf9c8aba 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 dfebe186..b2f34b77 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}
   ]
-- 
GitLab