From 41e80782315ef4db1697a6edf3d93ddbebd6813d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ole=20Volds=C3=A6ter?= <ole.voldsater@uib.no>
Date: Tue, 25 Feb 2020 13:23:33 +0100
Subject: [PATCH] fikset noen routing-feil

---
 src/App.vue                   | 13 ++++++++-----
 src/components/SubArticle.vue |  2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/App.vue b/src/App.vue
index 38b76a52..8c99a0d6 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -27,6 +27,7 @@ window.onpopstate = function (event) {
   if (event.state) {
     app.__vue__._data.article = event.state.article
     app.__vue__._data.search_results = event.state.search_results
+    app.__vue__._data.lang = event.state.lang
   }
 }
 
@@ -80,17 +81,19 @@ export default {
       this.$refs.search.value = ''
       document.activeElement.blur()
       if(event._source){
+        this.$router.push('/' + this.lang + '/' + event._id)
+        history.replaceState({article: this.article, search_results: this.search_results, lang: this.lang}, '')
         this.search_results = []
         this.article = event._source
-        history.pushState({article: this.article, search_results: this.search_results}, '', '/' + this.lang + '/' + event._id)
       }else{
         var self = this
         self.waiting = true
         self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}}
         axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + event.q)
         .then(function(response){
+          self.$router.push('/' + self.lang + '/_search?q=' + event.q)
+          history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '')
           self.search_results = response.data.hits.hits
-          history.pushState({article: self.article, search_results: self.search_results}, '', '/' + self.lang + '/_search?q=' + event.q)
           self.waiting = false
         })
       }
@@ -102,13 +105,13 @@ export default {
       .then(function(response){
         self.article = response.data._source
         self.waiting = false
-        history.replaceState({article: self.article, search_results: self.search_results}, '')
+        history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '')
       })
     },
     search_hit_click: function(article){
       this.search_results = []
       this.article = article
-      history.replaceState({article: article, search_results: []}, '')
+      history.replaceState({article: article, search_results: [], lang: this.lang}, '')
     }
   },
   mounted: function(){
@@ -126,7 +129,7 @@ export default {
       .then(function(response){
         self.article = response.data._source
         self.waiting = false
-        history.replaceState({article: self.article, search_results: self.search_results}, '')
+        history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '')
       })
     }
     else {
diff --git a/src/components/SubArticle.vue b/src/components/SubArticle.vue
index f56ab1f4..13189b8b 100644
--- a/src/components/SubArticle.vue
+++ b/src/components/SubArticle.vue
@@ -1,7 +1,7 @@
 <template>
   <li class="sub_article">
     <span class="sub_article_header">
-      <router-link :to="'' + body.article_id"  @click.native="article_link_click(body)">
+      <router-link :to="'./' + body.article_id"  @click.native="article_link_click(body)">
         {{body.lemmas[0]}}
       </router-link>
     </span>
-- 
GitLab