1 import { Component } from "inferno";
2 import { Link } from "inferno-router";
3 import { Community } from "lemmy-js-client";
4 import { hostname, relTags, showAvatars } from "../../utils";
5 import { PictrsImage } from "../common/pictrs-image";
7 interface CommunityLinkProps {
10 useApubName?: boolean;
15 export class CommunityLink extends Component<CommunityLinkProps, any> {
16 constructor(props: any, context: any) {
17 super(props, context);
21 let community = this.props.community;
22 let name_: string, title: string, link: string;
23 let local = community.local == null ? true : community.local;
25 name_ = community.name;
26 title = community.title;
27 link = `/c/${community.name}`;
29 let domain = hostname(community.actor_id);
30 name_ = `${community.name}@${domain}`;
31 title = `${community.title}@${domain}`;
32 link = !this.props.realLink ? `/c/${name_}` : community.actor_id;
35 let apubName = `!${name_}`;
36 let displayName = this.props.useApubName ? apubName : title;
37 return !this.props.realLink ? (
40 className={`${this.props.muted ? "text-muted" : ""}`}
43 {this.avatarAndName(displayName)}
48 className={`${this.props.muted ? "text-muted" : ""}`}
52 {this.avatarAndName(displayName)}
57 avatarAndName(displayName: string) {
58 let icon = this.props.community.icon;
61 {!this.props.hideAvatar &&
62 !this.props.community.removed &&
64 icon && <PictrsImage src={icon} icon />}
65 <span className="overflow-wrap-anywhere">{displayName}</span>