@@ -6,22 +6,29 @@ import {
66 type Reactions ,
77} from " @/ts/types/reactions"
88import type { Mentions } from " @/ts/types/mentions"
9+ import { getLangFromUrl , useTranslations } from " @/i18n/utils"
10+ import { urlBuilder } from " @/ts/functions"
911
1012const props = defineProps <{
1113 url: URL
1214 title: string
1315 author: string
16+ instantView? : string
1417}>()
1518
19+ const lang = getLangFromUrl (props .url )
20+ const t = useTranslations (lang )
21+
22+ const apiUrl = " https://webmention.io/api"
23+ const reactions = ref <Reaction []>([])
24+
1625function getMentionsUrl(props : Mentions .Props ): string {
1726 return urlBuilder (` ${props .apiUrl }/mentions.html ` , {
1827 target: props .postUrl ,
1928 " wm-property" : props ?.filter ,
2029 }).toString ()
2130}
2231
23- const apiUrl = " https://webmention.io/api"
24- const reactions = ref <Reaction []>([])
2532const mentions = reactive ({
2633 count: 0 ,
2734 url: getMentionsUrl ({
@@ -31,25 +38,14 @@ const mentions = reactive({
3138 }),
3239})
3340
34- function urlBuilder(
35- baseUrl : string ,
36- queryParameters : Record <string , string | undefined | null >,
37- ): URL {
38- const result = new URL (baseUrl )
39-
40- Object .entries (queryParameters ).forEach (([key , value ]) => {
41- if (value ) result .searchParams .append (key , value )
42- })
43-
44- return result
45- }
46-
47- const twitterLink = computed (() =>
48- urlBuilder (" https://twitter.com/intent/tweet" , {
49- original_referer: ` ${props .url .origin } ` ,
50- text: props .title ,
51- url: props .url .href ,
52- via: props .author ,
41+ const telegramLink = computed (() =>
42+ urlBuilder (" https://t.me/share/url" , {
43+ url: props .instantView
44+ ? urlBuilder (" https://t.me/iv" , {
45+ url: props .url .href ,
46+ rhash: props .instantView ,
47+ }).toString ()
48+ : props .url .href ,
5349 }).toString (),
5450)
5551
@@ -89,11 +85,11 @@ onMounted(() => fetchReactions())
8985
9086 <div class =" flex justify-between items-center" >
9187 <a
92- class =" text-sm bg-[#1da1f2 ] text-white rounded py-1 px-2 flex gap-2"
93- :href =" twitterLink "
88+ class =" text-sm bg-[#54a9eb ] text-white rounded py-1 px-2 flex gap-2 capitalize "
89+ :href =" telegramLink "
9490 >
95- <span class =" icon" ><i class =" fab fa-twitter " ></i ></span >
96- <span >Tweet </span >
91+ <span class =" icon" ><i class =" fab fa-telegram " ></i ></span >
92+ <span >{{ t("compartir") }} </span >
9793 </a >
9894
9995 <div class =" reactions" >
0 commit comments