1 import { Component } from 'inferno';
2 import { Link } from 'inferno-router';
3 import { Community } from 'lemmy-js-client';
4 import { hostname, showAvatars } from '../utils';
5 import { PictrsImage } from './pictrs-image';
7 interface CommunityOther {
9 id?: number; // Necessary if its federated
15 interface CommunityLinkProps {
16 community: Community | CommunityOther;
18 useApubName?: boolean;
23 export class CommunityLink extends Component<CommunityLinkProps, any> {
24 constructor(props: any, context: any) {
25 super(props, context);
29 let community = this.props.community;
30 let name_: string, link: string;
31 let local = community.local == null ? true : community.local;
33 name_ = community.name;
34 link = `/c/${community.name}`;
36 name_ = `${community.name}@${hostname(community.actor_id)}`;
37 link = !this.props.realLink
38 ? `/community/${community.id}`
42 let apubName = `!${name_}`;
43 let displayName = this.props.useApubName ? apubName : name_;
47 className={`${this.props.muted ? 'text-muted' : ''}`}
49 target={this.props.realLink ? '_blank' : ''}
51 {!this.props.hideAvatar && community.icon && showAvatars() && (
52 <PictrsImage src={community.icon} icon />
54 <span>{displayName}</span>