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

Recommit after botched merge

parent 5c2d4c64
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.35",
"@fortawesome/free-brands-svg-icons": "^5.15.3",
"@fortawesome/free-solid-svg-icons": "^5.15.3",
"@fortawesome/vue-fontawesome": "^2.0.2",
"axios": "^0.19.2", "axios": "^0.19.2",
"core-js": "~3.6.5", "core-js": "~3.6.5",
"debounce": "^1.2.1", "debounce": "^1.2.1",
...@@ -16,6 +20,7 @@ ...@@ -16,6 +20,7 @@
"vue-material-design-icons": "^4.11.0", "vue-material-design-icons": "^4.11.0",
"vue-plausible": "^1.1.4", "vue-plausible": "^1.1.4",
"vue-router": "^3.5.1", "vue-router": "^3.5.1",
"vue-social-sharing": "^3.0.8",
"vuetify": "^2.4.8" "vuetify": "^2.4.8"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -32,9 +32,36 @@ ...@@ -32,9 +32,36 @@
</router-link> </router-link>
</div> </div>
</div> </div>
</article> <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"
title="TITLE"
description="DESCRIPTION"
quote="QUOTE">
<font-awesome-icon :icon="['fab', 'facebook-square']" size="lg" />
</ShareNetwork>
</button>
<button class="share-button">
<ShareNetwork
network="twitter"
:url="share_link"
title="TITLE"
description="DESCRIPTION"
hashtags="Ordbøkene">
<font-awesome-icon :icon="['fab', 'twitter-square']" size="lg" />
</ShareNetwork>
</button>
</div>
</article>
</template> </template>
<script src="/dist/vue-social-sharing.js"></script>
<script> <script>
import DefElement from './DefElement.vue' import DefElement from './DefElement.vue'
import Definition from './Definition.vue' import Definition from './Definition.vue'
...@@ -74,13 +101,20 @@ export default { ...@@ -74,13 +101,20 @@ export default {
props: { props: {
article: Object article: Object
}, },
computed: { computed: {
webShareApiSupported() {
return navigator.share
},
link_to_self: function() { link_to_self: function() {
return { return {
ref: '/' + this.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma), ref: '/' + this.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma),
article: this.article article: this.article
} }
}, },
share_link: function() {
let host = window.location.hostname === 'localhost'? 'https://dev.ordbok.uib.no' : 'https://' + window.location.host
return host + "/" + this.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma)
},
dictionary: function() { dictionary: function() {
return this.article.dictionary return this.article.dictionary
}, },
...@@ -104,6 +138,13 @@ export default { ...@@ -104,6 +138,13 @@ export default {
Header Header
}, },
methods: { methods: {
shareViaWebShare() {
navigator.share({
title: 'Title to be shared',
text: 'Text to be shared',
url: 'URL to be shared'
})
},
article_link_click: function(item) { article_link_click: function(item) {
this.$emit('article-click', item) this.$emit('article-click', item)
}, },
...@@ -141,6 +182,15 @@ h3 { ...@@ -141,6 +182,15 @@ h3 {
font-variant: small-caps; font-variant: small-caps;
} }
div.share {
color: #560027;
padding-top: 24px;
}
.share-button {
padding-right: 4px;
}
section.etymology > h3, section.pronunciation > h3 { section.etymology > h3, section.pronunciation > h3 {
display: inline; display: inline;
font-size: 14px; font-size: 14px;
......
...@@ -7,6 +7,18 @@ import VueRouter from 'vue-router' ...@@ -7,6 +7,18 @@ import VueRouter from 'vue-router'
import { VuePlausible } from 'vue-plausible' import { VuePlausible } from 'vue-plausible'
import vuetify from './plugins/vuetify' import vuetify from './plugins/vuetify'
import VueSocialSharing from 'vue-social-sharing'
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, faShareAltSquare)
Vue.component('font-awesome-icon', FontAwesomeIcon);
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(VueRouter) Vue.use(VueRouter)
Vue.use(VuePlausible, { Vue.use(VuePlausible, {
......
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