File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <script setup lang="ts">
2+ import { useClipboard } from ' @vueuse/core'
3+ import { useI18n } from ' vue-i18n'
4+
5+ const { title } = defineProps <{
6+ title: string
7+ }>()
8+
9+ const { t } = useI18n ()
10+ const { copy, copied } = useClipboard ()
11+
12+ function currentUrl() {
13+ const url = new URL (window .location .href )
14+ url .hash = ' '
15+ url .search = ' '
16+ return url .toString ()
17+ }
18+
19+ async function share() {
20+ const url = currentUrl ()
21+
22+ if (typeof navigator .share === ' function' ) {
23+ try {
24+ await navigator .share ({
25+ text: title ,
26+ title ,
27+ url ,
28+ })
29+ return
30+ } catch (error ) {
31+ // Closing the native share sheet is not a failed share and should not copy.
32+ if (error instanceof Error && error .name === ' AbortError' ) {
33+ return
34+ }
35+ }
36+ }
37+
38+ await copy (url )
39+ }
40+ </script >
41+
42+ <template >
43+ <button
44+ :aria-label =" copied ? t('copied') : t('share')"
45+ class =" text-sm font-500 px-3 border-2 border-gray-300 rounded bg-gray-100 flex gap-1 h-8 cursor-pointer transition-colors items-center hover:bg-gray-200"
46+ type =" button"
47+ @click =" share"
48+ >
49+ <Icon
50+ class="text-gray-500 h-4 w-4"
51+ :name =" copied ? ' tabler:check' : ' tabler:share-2' "
52+ />
53+ <span class =" hidden sm:inline" >{{ copied ? t('copied') : t('share') }}</span >
54+ </button >
55+ </template >
56+
57+ <i18n lang="yaml">
58+ en :
59+ share : ' Share'
60+ copied : ' Link copied'
61+ zh :
62+ share : ' 分享'
63+ copied : ' 已複製連結'
64+ </i18n >
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ const speakerNames = computed(() =>
4141 <header class =" px-4 sm:px-6" >
4242 <h1
4343 class =" text-xl leading-tight font-bold mb-4 break-words sm:text-2xl"
44- :class =" hasTitleMarginRight ? 'mr-24 sm:mr-34 ' : ''"
44+ :class =" hasTitleMarginRight ? 'mr-36 sm:mr-60 ' : ''"
4545 >
4646 {{ title }}
4747 </h1 >
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type { Ad } from '#shared/types/ad'
33import type { SessionDetail } from ' #shared/types/session'
44import { useMediaQuery } from ' @vueuse/core'
55import { useI18n } from ' vue-i18n'
6+ import CpSessionDetailShareButton from ' ~/components/feature/CpSessionDetailShareButton.vue'
67import CpSessionInfoCard from ' ~/components/feature/CpSessionInfoCard.vue'
78import { useFavorites } from ' ~/composables/useFavorites'
89import { DEFAULT_TRACK_COLOR } from ' ~/utils/tracks'
@@ -237,6 +238,10 @@ onUnmounted(() => {
237238 </div >
238239
239240 <div class =" mr-4 flex gap-2 h-0 top-5 justify-end relative z-content overflow-visible sm:mr-6" >
241+ <CpSessionDetailShareButton
242+ v-if =" sessionInfo "
243+ :title =" sessionInfo .title "
244+ />
240245 <button
241246 :aria-label =" isFavorite(sessionId) ? t('removeFavorite') : t('addFavorite')"
242247 class =" text-sm font-500 px-3 border-2 rounded flex gap-1 h-8 cursor-pointer transition-colors items-center"
You can’t perform that action at this time.
0 commit comments