Skip to content
Snippets Groups Projects
Commit d8ee2873 authored by Henrik Askjer's avatar Henrik Askjer
Browse files

Add share button

parent 0d657899
No related branches found
No related tags found
No related merge requests found
...@@ -9,10 +9,7 @@ ...@@ -9,10 +9,7 @@
<span v-else> <span v-else>
<button class="share_button"> <button class="share_button">
<ShareNetwork network="facebook" <ShareNetwork network="facebook"
:url="share_link" :url="share_link">
title="TITLE"
description="DESCRIPTION"
quote="QUOTE">
<font-awesome-icon :icon="['fab', 'facebook-square']" size="lg" /> <font-awesome-icon :icon="['fab', 'facebook-square']" size="lg" />
</ShareNetwork> </ShareNetwork>
</button> </button>
...@@ -20,9 +17,8 @@ ...@@ -20,9 +17,8 @@
<ShareNetwork <ShareNetwork
network="twitter" network="twitter"
:url="share_link" :url="share_link"
title="TITLE" :title="dict_label"
description="DESCRIPTION" hashtags="#ordbøkene">
hashtags="Ordbøkene.no">
<font-awesome-icon :icon="['fab', 'twitter-square']" size="lg" /> <font-awesome-icon :icon="['fab', 'twitter-square']" size="lg" />
</ShareNetwork> </ShareNetwork>
</button> </button>
...@@ -39,20 +35,26 @@ export default { ...@@ -39,20 +35,26 @@ export default {
article: Object article: Object
}, },
computed: { computed: {
dict_label: function() { // TODO: reuse code used in header
return {
'bob': 'Fra bokmålsordboka',
'nob': 'Frå nynorskordboka'
}[this.article.dictionary] + ': ' + this.article.lemmas[0].lemma || ''
},
webShareApiSupported() { webShareApiSupported() {
return navigator.share && !(navigator.platform==="Win64" || navigator.platform==="Win32") return navigator.share && !(navigator.platform==="Win64" || navigator.platform==="Win32")
}, },
share_link: function() { share_link: function() {
let host = window.location.hostname === 'localhost'? 'https://dev.ordbok.uib.no' : 'https://' + window.location.host let host = window.location.hostname === 'localhost'? 'https://dev.ordbok.uib.no/' : window.location.href
return host + "/" + this.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma) return host + this.article.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma)
} }
}, },
methods: { methods: {
shareViaWebShare() { shareViaWebShare() {
navigator.share({ navigator.share({
title: 'Title to be shared', title: "Ordbøkene.no: " + encodeURIComponent(this.article.lemmas[0].lemma),
text: 'Text to be shared', text: "",
url: 'URL to be shared' url: "/" + this.article.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma)
}) })
} }
} }
......
...@@ -2,5 +2,8 @@ module.exports = { ...@@ -2,5 +2,8 @@ module.exports = {
runtimeCompiler: true, runtimeCompiler: true,
transpileDependencies: [ transpileDependencies: [
'vuetify' 'vuetify'
] ],
devServer: {
https: false
}
} }
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