mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(post): show embed of link in post content even if it doesn't have a thumbnail
This commit is contained in:
@@ -11,6 +11,7 @@ import useIsMobile from '../../hooks/use-is-mobile';
|
|||||||
import CommentMedia from '../comment-media';
|
import CommentMedia from '../comment-media';
|
||||||
import styles from './markdown.module.css';
|
import styles from './markdown.module.css';
|
||||||
import { useLocation, useParams } from 'react-router-dom';
|
import { useLocation, useParams } from 'react-router-dom';
|
||||||
|
import { canEmbed } from '../embed';
|
||||||
|
|
||||||
interface ContentLinkEmbedProps {
|
interface ContentLinkEmbedProps {
|
||||||
children: any;
|
children: any;
|
||||||
@@ -86,6 +87,7 @@ const ContentLinkEmbed = ({ children, href, linkMediaInfo }: ContentLinkEmbedPro
|
|||||||
<CommentMedia isReply={false} setShowThumbnail={setShowMedia} commentMediaInfo={linkMediaInfo} showThumbnail={false} />
|
<CommentMedia isReply={false} setShowThumbnail={setShowMedia} commentMediaInfo={linkMediaInfo} showThumbnail={false} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{getHasThumbnail(linkMediaInfo, href) && (
|
||||||
<FloatingPortal>
|
<FloatingPortal>
|
||||||
{isOpen && !isMobile && (
|
{isOpen && !isMobile && (
|
||||||
<div className={styles.floatingEmbed} ref={refs.setFloating} style={floatingStyles} {...getFloatingProps()}>
|
<div className={styles.floatingEmbed} ref={refs.setFloating} style={floatingStyles} {...getFloatingProps()}>
|
||||||
@@ -93,6 +95,7 @@ const ContentLinkEmbed = ({ children, href, linkMediaInfo }: ContentLinkEmbedPro
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</FloatingPortal>
|
</FloatingPortal>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -172,7 +175,8 @@ const Markdown = ({ content, title }: MarkdownProps) => {
|
|||||||
a: ({ href, children }) => {
|
a: ({ href, children }) => {
|
||||||
if (href && !isInCatalogView) {
|
if (href && !isInCatalogView) {
|
||||||
const linkMediaInfo = getLinkMediaInfo(href);
|
const linkMediaInfo = getLinkMediaInfo(href);
|
||||||
if (getHasThumbnail(linkMediaInfo, href)) {
|
const embedUrl = new URL(href);
|
||||||
|
if (canEmbed(embedUrl) || getHasThumbnail(linkMediaInfo, href)) {
|
||||||
return <ContentLinkEmbed children={children} href={href} linkMediaInfo={linkMediaInfo} />;
|
return <ContentLinkEmbed children={children} href={href} linkMediaInfo={linkMediaInfo} />;
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user