Skip to content

Commit 27b7c15

Browse files
committed
feat: 🎸 update share to x link
1 parent 896a0f1 commit 27b7c15

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed
-79.9 KB
Loading

javascript/tokenscript-viewer/src/components/common/share-to-x-button.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
import { Component, h, Prop } from '@stencil/core';
2-
import { getTgUrl } from '../viewers/util/tgUrl';
32

43
const X_POST_URL = "https://x.com/intent/tweet";
54

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(/tokenId=([^&]+)/);
16+
if (tokenIdMatch) {
17+
newUrl.searchParams.set('tokenId', tokenIdMatch[1]);
18+
}
19+
20+
newUrl.hash = url.hash;
21+
22+
return newUrl.toString();
23+
}
24+
625
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`;
827
}
928

1029
@Component({
@@ -25,7 +44,7 @@ export class XShareButton {
2544
title="Share on Telegram"
2645
>
2746
<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' }} />
2948
</a>
3049
</div>
3150
);

0 commit comments

Comments
 (0)