import { Component, linkEvent } from "inferno"; import { Post } from "lemmy-js-client"; import { i18n } from "../../i18next"; import { relTags } from "../../utils"; import { Icon } from "../common/icon"; interface MetadataCardProps { post: Post; } interface MetadataCardState { expanded: boolean; } export class MetadataCard extends Component< MetadataCardProps, MetadataCardState > { private emptyState: MetadataCardState = { expanded: false, }; constructor(props: any, context: any) { super(props, context); this.state = this.emptyState; } render() { let post = this.props.post; return ( <> {!this.state.expanded && post.embed_title.match({ some: embedTitle => post.url.match({ some: url => (
{post.name !== embedTitle && ( <>
{embedTitle}
{new URL(url).hostname} )} {post.embed_description.match({ some: desc => (
), none: <>, })} {post.embed_html.isSome() && ( )}
), none: <>, }), none: <>, })} {this.state.expanded && post.embed_html.match({ some: html => (
), none: <>, })} ); } handleIframeExpand(i: MetadataCard) { i.setState({ expanded: !i.state.expanded }); } }