1
1
import { Component , h , Prop } from '@stencil/core' ;
2
- import { getTgUrl } from '../viewers/util/tgUrl' ;
3
2
4
3
const X_POST_URL = "https://x.com/intent/tweet" ;
5
4
5
+ function buildTlinkToShareOnTwitter ( ) {
6
+ const url = new URL ( document . location . href ) ;
7
+ // change host to tlink.store/tapp
8
+ const newUrl = new URL ( 'tapp' , 'https://tlink.store' ) ;
9
+
10
+ url . searchParams . forEach ( ( value , key ) => {
11
+ newUrl . searchParams . set ( key , value ) ;
12
+ } ) ;
13
+
14
+ // add tokenId to the new url
15
+ const tokenIdMatch = url . hash . match ( / t o k e n I d = ( [ ^ & ] + ) / ) ;
16
+ if ( tokenIdMatch ) {
17
+ newUrl . searchParams . set ( 'tokenId' , tokenIdMatch [ 1 ] ) ;
18
+ }
19
+
20
+ newUrl . hash = url . hash ;
21
+
22
+ return newUrl . toString ( ) ;
23
+ }
24
+
6
25
function getXPostUrl ( ) {
7
- return `${ X_POST_URL } ?text=${ encodeURIComponent ( document . location . href ) + " #SmartLayer #Tapps" } &related=SmartLayer` ;
26
+ return `${ X_POST_URL } ?text=${ encodeURIComponent ( buildTlinkToShareOnTwitter ( ) ) + ' #SmartLayer #Tapps' } &related=SmartLayer` ;
8
27
}
9
28
10
29
@Component ( {
@@ -25,7 +44,7 @@ export class XShareButton {
25
44
title = "Share on Telegram"
26
45
>
27
46
< img alt = "Share to X.com" title = "Share to X.com"
28
- src = "/assets/icon/x-icon.png" style = { { width : '100%' , height : '100%' } } />
47
+ src = "/assets/icon/x-icon.png" style = { { width : '100%' , height : '100%' , borderRadius : '9999px' } } />
29
48
</ a >
30
49
</ div >
31
50
) ;
0 commit comments