1 import { Component } from 'inferno';
2 import { Link } from 'inferno-router';
3 import { Community } from 'lemmy-js-client';
4 import { hostname, pictrsAvatarThumbnail, showAvatars } from '../utils';
6 interface CommunityOther {
8 id?: number; // Necessary if its federated
14 interface CommunityLinkProps {
15 community: Community | CommunityOther;
17 useApubName?: boolean;
22 export class CommunityLink extends Component<CommunityLinkProps, any> {
23 constructor(props: any, context: any) {
24 super(props, context);
28 let community = this.props.community;
29 let name_: string, link: string;
30 let local = community.local == null ? true : community.local;
32 name_ = community.name;
33 link = `/c/${community.name}`;
35 name_ = `${community.name}@${hostname(community.actor_id)}`;
36 link = !this.props.realLink
37 ? `/community/${community.id}`
41 let apubName = `!${name_}`;
42 let displayName = this.props.useApubName ? apubName : name_;
46 className={`${this.props.muted ? 'text-muted' : ''}`}
49 {!this.props.hideAvatar && community.icon && showAvatars() && (
51 style="width: 2rem; height: 2rem;"
52 src={pictrsAvatarThumbnail(community.icon)}
53 class="rounded-circle mr-2"
56 <span>{displayName}</span>