mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat: add spoiler text
This commit is contained in:
@@ -10,6 +10,7 @@ import CommentMedia from '../comment-media';
|
||||
|
||||
interface MarkdownProps {
|
||||
content: string;
|
||||
spoiler?: boolean;
|
||||
}
|
||||
|
||||
const MAX_LENGTH_FOR_GFM = 10000; // remarkGfm lags with large content
|
||||
@@ -37,7 +38,7 @@ const blockquoteToGreentext = () => (tree: any) => {
|
||||
});
|
||||
};
|
||||
|
||||
const Markdown = ({ content }: MarkdownProps) => {
|
||||
const Markdown = ({ content, spoiler }: MarkdownProps) => {
|
||||
const remarkPlugins: any[] = [[supersub]];
|
||||
|
||||
if (content && content.length <= MAX_LENGTH_FOR_GFM) {
|
||||
@@ -68,6 +69,7 @@ const Markdown = ({ content }: MarkdownProps) => {
|
||||
remarkPlugins={remarkPlugins}
|
||||
rehypePlugins={[[rehypeSanitize, customSchema]]}
|
||||
components={{
|
||||
p: ({ children }) => <p className=''>{spoiler ? <span className={styles.spoiler}>{children}</span> : children}</p>,
|
||||
img: ({ src }) => <span>{src}</span>,
|
||||
video: ({ src }) => <span>{src}</span>,
|
||||
iframe: ({ src }) => <span>{src}</span>,
|
||||
|
||||
Reference in New Issue
Block a user