1 import { Component } from 'inferno';
2 import { Link } from 'inferno-router';
3 import { CommunitySafe } from 'lemmy-js-client';
4 import { hostname, showAvatars } from '../utils';
5 import { PictrsImage } from './pictrs-image';
7 interface CommunityLinkProps {
8 // TODO figure this out better
9 community: CommunitySafe;
11 useApubName?: boolean;
16 export class CommunityLink extends Component<CommunityLinkProps, any> {
17 constructor(props: any, context: any) {
18 super(props, context);
22 let community = this.props.community;
23 let name_: string, link: string;
24 let local = community.local == null ? true : community.local;
26 name_ = community.name;
27 link = `/c/${community.name}`;
29 name_ = `${community.name}@${hostname(community.actor_id)}`;
30 link = !this.props.realLink
31 ? `/community/${community.id}`
35 let apubName = `!${name_}`;
36 let displayName = this.props.useApubName ? apubName : name_;
40 className={`${this.props.muted ? 'text-muted' : ''}`}
42 target={this.props.realLink ? '_blank' : ''}
44 {!this.props.hideAvatar && community.icon && showAvatars() && (
45 <PictrsImage src={community.icon} icon />
47 <span>{displayName}</span>