mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-02 02:29:59 +00:00
043b522ff1
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update src/shared/utils/app/convert-comment-sort-type.ts Co-authored-by: SleeplessOne1917 <abias1122@gmail.com> * prettier pass --------- Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>
71 lines
2 KiB
TypeScript
71 lines
2 KiB
TypeScript
import { showAvatars } from "@utils/app";
|
|
import { hostname } from "@utils/helpers";
|
|
import { Component } from "inferno";
|
|
import { Link } from "inferno-router";
|
|
import { Community } from "lemmy-js-client";
|
|
import { relTags } from "../../config";
|
|
import { PictrsImage } from "../common/pictrs-image";
|
|
|
|
interface CommunityLinkProps {
|
|
community: Community;
|
|
realLink?: boolean;
|
|
useApubName?: boolean;
|
|
muted?: boolean;
|
|
hideAvatar?: boolean;
|
|
}
|
|
|
|
export class CommunityLink extends Component<CommunityLinkProps, any> {
|
|
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 ? (
|
|
<Link
|
|
title={apubName}
|
|
className={`community-link ${this.props.muted ? "text-muted" : ""}`}
|
|
to={link}
|
|
>
|
|
{this.avatarAndName(displayName)}
|
|
</Link>
|
|
) : (
|
|
<a
|
|
title={apubName}
|
|
className={`community-link ${this.props.muted ? "text-muted" : ""}`}
|
|
href={link}
|
|
rel={relTags}
|
|
>
|
|
{this.avatarAndName(displayName)}
|
|
</a>
|
|
);
|
|
}
|
|
|
|
avatarAndName(displayName: string) {
|
|
const icon = this.props.community.icon;
|
|
return (
|
|
<>
|
|
{!this.props.hideAvatar &&
|
|
!this.props.community.removed &&
|
|
showAvatars() &&
|
|
icon && <PictrsImage src={icon} icon />}
|
|
<span className="overflow-wrap-anywhere">{displayName}</span>
|
|
</>
|
|
);
|
|
}
|
|
}
|