mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(catalog post): don't render markdown embeds and hr
This commit is contained in:
@@ -6,9 +6,11 @@ import supersub from 'remark-supersub';
|
|||||||
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
|
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
|
||||||
import { useDismiss, useFloating, useFocus, useHover, useInteractions, offset, shift, size, autoUpdate, Placement, FloatingPortal } from '@floating-ui/react';
|
import { useDismiss, useFloating, useFocus, useHover, useInteractions, offset, shift, size, autoUpdate, Placement, FloatingPortal } from '@floating-ui/react';
|
||||||
import { getLinkMediaInfo, getHasThumbnail } from '../../lib/utils/media-utils';
|
import { getLinkMediaInfo, getHasThumbnail } from '../../lib/utils/media-utils';
|
||||||
|
import { isCatalogView } from '../../lib/utils/view-utils';
|
||||||
import useIsMobile from '../../hooks/use-is-mobile';
|
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';
|
||||||
|
|
||||||
interface ContentLinkEmbedProps {
|
interface ContentLinkEmbedProps {
|
||||||
children: any;
|
children: any;
|
||||||
@@ -146,6 +148,8 @@ const Markdown = ({ content, spoiler }: MarkdownProps) => {
|
|||||||
|
|
||||||
remarkPlugins.push([blockquoteToGreentext]);
|
remarkPlugins.push([blockquoteToGreentext]);
|
||||||
|
|
||||||
|
const isInCatalogView = isCatalogView(useLocation().pathname, useParams());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={styles.markdown}>
|
<span className={styles.markdown}>
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
@@ -158,13 +162,14 @@ const Markdown = ({ content, spoiler }: MarkdownProps) => {
|
|||||||
video: ({ src }) => <span>{src}</span>,
|
video: ({ src }) => <span>{src}</span>,
|
||||||
iframe: ({ src }) => <span>{src}</span>,
|
iframe: ({ src }) => <span>{src}</span>,
|
||||||
source: ({ src }) => <span>{src}</span>,
|
source: ({ src }) => <span>{src}</span>,
|
||||||
hr: () => (
|
hr: () =>
|
||||||
<div className={styles.hrWrapper}>
|
!isInCatalogView && (
|
||||||
<hr />
|
<div className={styles.hrWrapper}>
|
||||||
</div>
|
<hr />
|
||||||
),
|
</div>
|
||||||
|
),
|
||||||
a: ({ href, children }) => {
|
a: ({ href, children }) => {
|
||||||
if (href) {
|
if (href && !isInCatalogView) {
|
||||||
const linkMediaInfo = getLinkMediaInfo(href);
|
const linkMediaInfo = getLinkMediaInfo(href);
|
||||||
if (getHasThumbnail(linkMediaInfo, href)) {
|
if (getHasThumbnail(linkMediaInfo, href)) {
|
||||||
return <ContentLinkEmbed children={children} href={href} linkMediaInfo={linkMediaInfo} />;
|
return <ContentLinkEmbed children={children} href={href} linkMediaInfo={linkMediaInfo} />;
|
||||||
|
|||||||
Reference in New Issue
Block a user