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

Add sharing with Web Share API

parent eeee2276
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,12 @@
</router-link>
</div>
</div>
<div class="share">
<div class="share" v-if="webShareApiSupported">
<button @click="shareViaWebShare">
Del ordet <font-awesome-icon icon="share-alt-square" size = "lg"/>
</button>
</div>
<div class="share" v-else>
<button class="share-button">
<ShareNetwork network="facebook"
:url="share_link"
......@@ -96,7 +101,10 @@ export default {
props: {
article: Object
},
computed: {
computed: {
webShareApiSupported() {
return navigator.share
},
link_to_self: function() {
return {
ref: '/' + this.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma),
......@@ -129,6 +137,13 @@ export default {
Header
},
methods: {
shareViaWebShare() {
navigator.share({
title: 'Title to be shared',
text: 'Text to be shared',
url: 'URL to be shared'
})
},
article_link_click: function(item) {
this.$emit('article-click', item)
},
......
......@@ -12,9 +12,10 @@ Vue.use(VueSocialSharing);
import { library } from '@fortawesome/fontawesome-svg-core'
import { faShareAltSquare } from '@fortawesome/free-solid-svg-icons'
import { faFacebookSquare, faTwitterSquare } from '@fortawesome/free-brands-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(faFacebookSquare, faTwitterSquare)
library.add(faFacebookSquare, faTwitterSquare, faShareAltSquare)
Vue.component('font-awesome-icon', FontAwesomeIcon);
......
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