diff options
author | Dessalines <tyhou13@gmx.com> | 2020-04-14 19:18:13 -0400 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-04-14 19:18:13 -0400 |
commit | fcf1c65fc131478632525ce44a792f1578932f4a (patch) | |
tree | b778be542d06aa374fd5eb9d36b40b2b7fb05536 /ui/src/components/community-link.tsx | |
parent | 1336b4ed6023e7fcf0fd40be63569966ee4b1b45 (diff) |
Front end federation names and links for users, posts, and communities.
Diffstat (limited to 'ui/src/components/community-link.tsx')
-rw-r--r-- | ui/src/components/community-link.tsx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ui/src/components/community-link.tsx b/ui/src/components/community-link.tsx new file mode 100644 index 00000000..bcfa0534 --- /dev/null +++ b/ui/src/components/community-link.tsx @@ -0,0 +1,35 @@ +import { Component } from 'inferno'; +import { Link } from 'inferno-router'; +import { Community } from '../interfaces'; +import { hostname } from '../utils'; + +interface CommunityOther { + name: string; + id?: number; // Necessary if its federated + local?: boolean; + actor_id?: string; +} + +interface CommunityLinkProps { + community: Community | CommunityOther; +} + +export class CommunityLink extends Component<CommunityLinkProps, any> { + constructor(props: any, context: any) { + super(props, context); + } + + render() { + let community = this.props.community; + let name_: string, link: string; + let local = community.local == null ? true : community.local; + if (local) { + name_ = community.name; + link = `/c/${community.name}`; + } else { + name_ = `${hostname(community.actor_id)}/${community.name}`; + link = `/community/${community.id}`; + } + return <Link to={link}>{name_}</Link>; + } +} |