Skip to content
Snippets Groups Projects
Commit a17d865c authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

refs meta#30 bokmål og nynorsk

parent c7c2c0f6
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,14 @@
<div class="">
<form class="" action="search" method="get">
<input placeholder="Søk..." name="q" />
<select class="" name="lang">
<option value="nob">Bokmål</option>
<option value="nno">Nynorsk</option>
</select>
<input type="submit" name="" value="Yay!">
</form>
</div>
<SearchResults :hits="search_results" />
<SearchResults :hits="search_results" :lang="query_lang" />
<Article :article="article" />
</div>
</template>
......@@ -18,14 +23,18 @@ import SearchResults from './components/SearchResults.vue'
//import Autocomplete from '@trevoreyre/autocomplete-vue'
//import '@trevoreyre/autocomplete-vue/dist/style.css'
var api_endpoint = 'https://ordbok-dev.aws.uib.no/api/dict/nob/article'
var api_endpoint = 'https://ordbok-dev.aws.uib.no/api/dict/'
export default {
name: 'app',
data: function() {
let params = new URLSearchParams(window.location.search.substring(1))
let path = window.location.href.split("/")
return {
article_id: parseInt(window.location.href.split("/").pop()),
search_query: window.location.href.split("?q=")[1],
article_id: parseInt(path.pop()),
search_query: params.get('q'),
query_lang: params.get('lang'),
path_lang: path.pop(),
search_results: [],
article: {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}},
/*search: function(q) {
......@@ -73,14 +82,14 @@ export default {
mounted: function(){
var self = this;
if(this.search_query) {
axios.get(api_endpoint + '?expand_lemmas=true&lemma_text=' + self.search_query)
axios.get(api_endpoint + self.query_lang + '/article' + '?expand_lemmas=true&lemma_text=' + self.search_query)
.then(function(response){
self.search_results = response.data
})
}
else
{
axios.get(api_endpoint + '/' + self.article_id + '?expand_lemmas=true&expand_refs=true')
axios.get(api_endpoint + self.path_lang + '/article' + '/' + self.article_id + '?expand_lemmas=true&expand_refs=true')
.then(function(response){
self.article = response.data
})
......
......@@ -2,8 +2,8 @@
<div class="">
<h2 v-if="hits.length">Søkeresultater</h2>
<ul>
<li v-for="result in extended_results">
<a :href="result.id">{{result.label}}</a> ({{result.classification}})
<li v-for="(result, index) in extended_results" :key="index">
<a :href="lang + '/' + result.id">{{result.label}}</a> ({{result.classification}})
</li>
</ul>
</div>
......@@ -14,7 +14,8 @@ import helpers from '../utils/helpers.js'
export default {
name: 'SearchResults',
props: {
hits: Array
hits: Array,
lang: String
},
computed: {
extended_results: function(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment