import { Component, linkEvent } from "inferno"; import { Post } from "lemmy-js-client"; import * as sanitizeHtml from "sanitize-html"; 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 > { state: MetadataCardState = { expanded: false, }; constructor(props: any, context: any) { super(props, context); } render() { const post = this.props.post; return ( <> {!this.state.expanded && post.embed_title && post.url && (
{post.name !== post.embed_title && ( <>
{post.embed_title}
{new URL(post.url).hostname} )} {post.embed_description && (
)} {post.embed_video_url && ( )}
)} {this.state.expanded && post.embed_video_url && (
)} ); } handleIframeExpand(i: MetadataCard) { i.setState({ expanded: !i.state.expanded }); } }