import { Component } from "inferno"; import { Link } from "inferno-router"; import { Community } from "lemmy-js-client"; import { hostname, relTags, showAvatars } from "../../utils"; import { PictrsImage } from "../common/pictrs-image"; interface CommunityLinkProps { community: Community; realLink?: boolean; useApubName?: boolean; muted?: boolean; hideAvatar?: boolean; } export class CommunityLink extends Component { constructor(props: any, context: any) { super(props, context); } render() { const community = this.props.community; let name_: string, title: string, link: string; const local = community.local == null ? true : community.local; if (local) { name_ = community.name; title = community.title; link = `/c/${community.name}`; } else { const domain = hostname(community.actor_id); name_ = `${community.name}@${domain}`; title = `${community.title}@${domain}`; link = !this.props.realLink ? `/c/${name_}` : community.actor_id; } const apubName = `!${name_}`; const displayName = this.props.useApubName ? apubName : title; return !this.props.realLink ? ( {this.avatarAndName(displayName)} ) : ( {this.avatarAndName(displayName)} ); } avatarAndName(displayName: string) { const icon = this.props.community.icon; return ( <> {!this.props.hideAvatar && !this.props.community.removed && showAvatars() && icon && } {displayName} ); } }