1 import { Component } from "inferno";
2 import { Link } from "inferno-router";
3 import { CommunitySafe } from "lemmy-js-client";
4 import { hostname, showAvatars } from "../utils";
5 import { PictrsImage } from "./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 name_ = `${community.name}@${hostname(community.actor_id)}`;
31 title = `${community.title}@${hostname(community.actor_id)}`;
32 link = !this.props.realLink
33 ? `/community/${community.id}`
37 let apubName = `!${name_}`;
38 let displayName = this.props.useApubName ? apubName : title;
42 className={`${this.props.muted ? "text-muted" : ""}`}
45 {!this.props.hideAvatar && community.icon && showAvatars() && (
46 <PictrsImage src={community.icon} icon />
48 <span>{displayName}</span>