From 09a14416c8bcbd722ebeb3bbc0b158bf12c1190b Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Sat, 31 Aug 2024 14:22:02 +0200 Subject: [PATCH] feat(post): show embed of link in post content even if it doesn't have a thumbnail --- src/components/markdown/markdown.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/markdown/markdown.tsx b/src/components/markdown/markdown.tsx index d355a130..8ba27587 100644 --- a/src/components/markdown/markdown.tsx +++ b/src/components/markdown/markdown.tsx @@ -11,6 +11,7 @@ import useIsMobile from '../../hooks/use-is-mobile'; import CommentMedia from '../comment-media'; import styles from './markdown.module.css'; import { useLocation, useParams } from 'react-router-dom'; +import { canEmbed } from '../embed'; interface ContentLinkEmbedProps { children: any; @@ -86,13 +87,15 @@ const ContentLinkEmbed = ({ children, href, linkMediaInfo }: ContentLinkEmbedPro )} - - {isOpen && !isMobile && ( -
- -
- )} -
+ {getHasThumbnail(linkMediaInfo, href) && ( + + {isOpen && !isMobile && ( +
+ +
+ )} +
+ )} ); }; @@ -172,7 +175,8 @@ const Markdown = ({ content, title }: MarkdownProps) => { a: ({ href, children }) => { if (href && !isInCatalogView) { const linkMediaInfo = getLinkMediaInfo(href); - if (getHasThumbnail(linkMediaInfo, href)) { + const embedUrl = new URL(href); + if (canEmbed(embedUrl) || getHasThumbnail(linkMediaInfo, href)) { return ; } else { return (