1 import { showAvatars } from "@utils/app";
2 import { hostname } from "@utils/helpers";
3 import { Component } from "inferno";
4 import { Link } from "inferno-router";
5 import { Community } from "lemmy-js-client";
6 import { relTags } from "../../config";
7 import { PictrsImage } from "../common/pictrs-image";
9 interface CommunityLinkProps {
12 useApubName?: boolean;
17 export class CommunityLink extends Component<CommunityLinkProps, any> {
18 constructor(props: any, context: any) {
19 super(props, context);
23 const community = this.props.community;
24 let name_: string, title: string, link: string;
25 const local = community.local == null ? true : community.local;
27 name_ = community.name;
28 title = community.title;
29 link = `/c/${community.name}`;
31 const domain = hostname(community.actor_id);
32 name_ = `${community.name}@${domain}`;
33 title = `${community.title}@${domain}`;
34 link = !this.props.realLink ? `/c/${name_}` : community.actor_id;
37 const apubName = `!${name_}`;
38 const displayName = this.props.useApubName ? apubName : title;
39 return !this.props.realLink ? (
42 className={`community-link ${this.props.muted ? "text-muted" : ""}`}
45 {this.avatarAndName(displayName)}
50 className={`community-link ${this.props.muted ? "text-muted" : ""}`}
54 {this.avatarAndName(displayName)}
59 avatarAndName(displayName: string) {
60 const icon = this.props.community.icon;
63 {!this.props.hideAvatar &&
64 !this.props.community.removed &&
66 icon && <PictrsImage src={icon} icon />}
67 <span className="overflow-wrap-anywhere">{displayName}</span>