1 import { Component } from "inferno";
2 import { Link } from "inferno-router";
3 import { CommunitySafe } from "lemmy-js-client";
4 import { hostname, relTags, showAvatars } from "../../utils";
5 import { PictrsImage } from "../common/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, title: string, link: string;
24 let local = community.local == null ? true : community.local;
26 name_ = community.name;
27 title = community.title;
28 link = `/c/${community.name}`;
30 let domain = hostname(community.actor_id);
31 name_ = `${community.name}@${domain}`;
32 title = `${community.title}@${domain}`;
33 link = !this.props.realLink ? `/c/${name_}` : community.actor_id;
36 let apubName = `!${name_}`;
37 let displayName = this.props.useApubName ? apubName : title;
38 return !this.props.realLink ? (
41 className={`${this.props.muted ? "text-muted" : ""}`}
44 {this.avatarAndName(displayName)}
49 className={`${this.props.muted ? "text-muted" : ""}`}
53 {this.avatarAndName(displayName)}
58 avatarAndName(displayName: string) {
61 {!this.props.hideAvatar &&
63 this.props.community.icon.match({
64 some: icon => <PictrsImage src={icon} icon />,
67 <span class="overflow-wrap-anywhere">{displayName}</span>