@@ -2456,6 +2456,22 @@ function MediaFirstContainer(props) {
2456
2456
) ;
2457
2457
}
2458
2458
2459
+ function getDomain ( url ) {
2460
+ return punycode . toUnicode (
2461
+ URL . parse ( url )
2462
+ . hostname . replace ( / ^ w w w \. / , '' )
2463
+ . replace ( / \/ $ / , '' ) ,
2464
+ ) ;
2465
+ }
2466
+
2467
+ // "Post": Quote post + card link preview combo
2468
+ // Assume all links from these domains are "posts"
2469
+ // Mastodon links are "posts" too but they are converted to real quote posts and there's too many domains to check
2470
+ // This is just "Progressive Enhancement"
2471
+ function isCardPost ( domain ) {
2472
+ return [ 'x.com' , 'twitter.com' , 'threads.net' , 'bsky.app' ] . includes ( domain ) ;
2473
+ }
2474
+
2459
2475
function Card ( { card, selfReferential, instance } ) {
2460
2476
const snapStates = useSnapshot ( states ) ;
2461
2477
const {
@@ -2534,11 +2550,7 @@ function Card({ card, selfReferential, instance }) {
2534
2550
) ;
2535
2551
2536
2552
if ( hasText && ( image || ( type === 'photo' && blurhash ) ) ) {
2537
- const domain = punycode . toUnicode (
2538
- URL . parse ( url )
2539
- . hostname . replace ( / ^ w w w \. / , '' )
2540
- . replace ( / \/ $ / , '' ) ,
2541
- ) ;
2553
+ const domain = getDomain ( url ) ;
2542
2554
let blurhashImage ;
2543
2555
const rgbAverageColor =
2544
2556
image && blurhash ? getBlurHashAverageColor ( blurhash ) : null ;
@@ -2559,11 +2571,7 @@ function Card({ card, selfReferential, instance }) {
2559
2571
blurhashImage = canvas . toDataURL ( ) ;
2560
2572
}
2561
2573
2562
- // "Post": Quote post + card link preview combo
2563
- // Assume all links from these domains are "posts"
2564
- // Mastodon links are "posts" too but they are converted to real quote posts and there's too many domains to check
2565
- // This is just "Progressive Enhancement"
2566
- const isPost = [ 'x.com' , 'twitter.com' , 'threads.net' ] . includes ( domain ) ;
2574
+ const isPost = isCardPost ( domain ) ;
2567
2575
2568
2576
return (
2569
2577
< a
@@ -2669,15 +2677,14 @@ function Card({ card, selfReferential, instance }) {
2669
2677
// );
2670
2678
}
2671
2679
if ( hasText && ! image ) {
2672
- const domain = punycode . toUnicode (
2673
- URL . parse ( url ) . hostname . replace ( / ^ w w w \. / , '' ) ,
2674
- ) ;
2680
+ const domain = getDomain ( url ) ;
2681
+ const isPost = isCardPost ( domain ) ;
2675
2682
return (
2676
2683
< a
2677
2684
href = { cardStatusURL || url }
2678
2685
target = { cardStatusURL ? null : '_blank' }
2679
2686
rel = "nofollow noopener noreferrer"
2680
- class = { `card link no-image` }
2687
+ class = { `card link ${ isPost ? 'card-post' : '' } no-image` }
2681
2688
lang = { language }
2682
2689
onClick = { handleClick }
2683
2690
>
0 commit comments