Share.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div v-if="url" class="share">
  3. <nuxt-link
  4. v-for="network in networks"
  5. :key="network.name"
  6. :href="network.url"
  7. target="_blank"
  8. :style="{ color: network.colorOnHover }"
  9. >
  10. <v-icon :icon="network.icon"/>
  11. </nuxt-link>
  12. </div>
  13. </template>
  14. <script setup lang="ts">
  15. import type { SocialNetworkShareBtn } from "~/types/interface";
  16. const url: Ref<string | null> = ref(null)
  17. const networks: Ref<Array<SocialNetworkShareBtn>> = ref([])
  18. if (process.client) {
  19. url.value = window.location.href
  20. networks.value = [
  21. {
  22. name: "Facebook",
  23. icon: "fa-brands fa-facebook",
  24. colorOnHover: "#135fc2",
  25. url: `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(url.value)}`
  26. },
  27. {
  28. name: "Twitter",
  29. icon: "fa-brands fa-twitter",
  30. colorOnHover: "#1781c2",
  31. url: `https://twitter.com/intent/tweet?url=${encodeURIComponent(url.value)}`
  32. },
  33. {
  34. name: "Messenger",
  35. icon: "fa-brands fa-facebook-messenger",
  36. colorOnHover: "#0085ff",
  37. url: `https://messenger.com`
  38. },
  39. {
  40. name: "Instagram",
  41. icon: "fa-brands fa-instagram",
  42. colorOnHover: "#d0006a",
  43. url: "https://instagram.com"
  44. },
  45. {
  46. name: "Linkedin",
  47. icon: "fa-brands fa-linkedin",
  48. colorOnHover: "#006291",
  49. url: `https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(url.value)}`
  50. },
  51. {
  52. name: "Email",
  53. icon: "fas fa-envelope",
  54. colorOnHover: "#292929",
  55. url: `mailto:?body=${url.value}`
  56. },
  57. ]
  58. }
  59. </script>
  60. <style scoped lang="scss">
  61. .share {
  62. display: flex;
  63. gap: 10px;
  64. font-family: "Barlow", serif;
  65. font-size: 16px;
  66. font-style: normal;
  67. font-weight: 400;
  68. line-height: 28px;
  69. i {
  70. font-size: 32px;
  71. margin: 0.5rem 0.3rem;
  72. color: #808080;
  73. }
  74. a:hover i {
  75. color: inherit;
  76. }
  77. }
  78. </style>